mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into ownJsonParsing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[](https://travis-ci.org/Microsoft/TypeScript)
|
||||
[](https://www.npmjs.com/package/typescript)
|
||||
[](https://www.npmjs.com/package/typescript)
|
||||
[](https://www.npmjs.com/package/typescript)
|
||||
|
||||
# TypeScript
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ function createCancellationToken(args) {
|
||||
return {
|
||||
isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); },
|
||||
setRequest: function (requestId) {
|
||||
currentRequestId_1 = currentRequestId_1;
|
||||
currentRequestId_1 = requestId;
|
||||
perRequestPipeName_1 = namePrefix_1 + requestId;
|
||||
},
|
||||
resetRequest: function (requestId) {
|
||||
|
||||
Vendored
+549
-329
File diff suppressed because it is too large
Load Diff
Vendored
+240
-121
@@ -98,8 +98,8 @@ interface ConstrainLongRange extends LongRange {
|
||||
}
|
||||
|
||||
interface ConstrainVideoFacingModeParameters {
|
||||
exact?: string | string[];
|
||||
ideal?: string | string[];
|
||||
exact?: VideoFacingModeEnum | VideoFacingModeEnum[];
|
||||
ideal?: VideoFacingModeEnum | VideoFacingModeEnum[];
|
||||
}
|
||||
|
||||
interface CustomEventInit extends EventInit {
|
||||
@@ -328,7 +328,7 @@ interface MSAudioSendSignal {
|
||||
}
|
||||
|
||||
interface MSConnectivity {
|
||||
iceType?: string;
|
||||
iceType?: MSIceType;
|
||||
iceWarningFlags?: MSIceWarningFlags;
|
||||
relayAddress?: MSRelayAddress;
|
||||
}
|
||||
@@ -338,11 +338,11 @@ interface MSCredentialFilter {
|
||||
}
|
||||
|
||||
interface MSCredentialParameters {
|
||||
type?: string;
|
||||
type?: MSCredentialType;
|
||||
}
|
||||
|
||||
interface MSCredentialSpec {
|
||||
type?: string;
|
||||
type?: MSCredentialType;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ interface MSDelay {
|
||||
|
||||
interface MSDescription extends RTCStats {
|
||||
connectivity?: MSConnectivity;
|
||||
transport?: string;
|
||||
transport?: RTCIceProtocol;
|
||||
networkconnectivity?: MSNetworkConnectivityInfo;
|
||||
localAddr?: MSIPAddressInfo;
|
||||
remoteAddr?: MSIPAddressInfo;
|
||||
@@ -477,11 +477,11 @@ interface MSTransportDiagnosticsStats extends RTCStats {
|
||||
numConsentRespReceived?: number;
|
||||
interfaces?: MSNetworkInterfaceType;
|
||||
baseInterface?: MSNetworkInterfaceType;
|
||||
protocol?: string;
|
||||
protocol?: RTCIceProtocol;
|
||||
localInterface?: MSNetworkInterfaceType;
|
||||
localAddrType?: string;
|
||||
remoteAddrType?: string;
|
||||
iceRole?: string;
|
||||
localAddrType?: MSIceAddrType;
|
||||
remoteAddrType?: MSIceAddrType;
|
||||
iceRole?: RTCIceRole;
|
||||
rtpRtcpMux?: boolean;
|
||||
allocationTimeInMs?: number;
|
||||
msRtcEngineVersion?: string;
|
||||
@@ -554,7 +554,7 @@ interface MediaEncryptedEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface MediaKeyMessageEventInit extends EventInit {
|
||||
messageType?: string;
|
||||
messageType?: MediaKeyMessageType;
|
||||
message?: ArrayBuffer;
|
||||
}
|
||||
|
||||
@@ -562,8 +562,8 @@ interface MediaKeySystemConfiguration {
|
||||
initDataTypes?: string[];
|
||||
audioCapabilities?: MediaKeySystemMediaCapability[];
|
||||
videoCapabilities?: MediaKeySystemMediaCapability[];
|
||||
distinctiveIdentifier?: string;
|
||||
persistentState?: string;
|
||||
distinctiveIdentifier?: MediaKeysRequirement;
|
||||
persistentState?: MediaKeysRequirement;
|
||||
}
|
||||
|
||||
interface MediaKeySystemMediaCapability {
|
||||
@@ -687,7 +687,7 @@ interface MutationObserverInit {
|
||||
}
|
||||
|
||||
interface NotificationOptions {
|
||||
dir?: string;
|
||||
dir?: NotificationDirection;
|
||||
lang?: string;
|
||||
body?: string;
|
||||
tag?: string;
|
||||
@@ -786,8 +786,8 @@ interface PushSubscriptionOptionsInit {
|
||||
|
||||
interface RTCConfiguration {
|
||||
iceServers?: RTCIceServer[];
|
||||
iceTransportPolicy?: string;
|
||||
bundlePolicy?: string;
|
||||
iceTransportPolicy?: RTCIceTransportPolicy;
|
||||
bundlePolicy?: RTCBundlePolicy;
|
||||
peerIdentity?: string;
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ interface RTCDtlsFingerprint {
|
||||
}
|
||||
|
||||
interface RTCDtlsParameters {
|
||||
role?: string;
|
||||
role?: RTCDtlsRole;
|
||||
fingerprints?: RTCDtlsFingerprint[];
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ interface RTCIceCandidateAttributes extends RTCStats {
|
||||
ipAddress?: string;
|
||||
portNumber?: number;
|
||||
transport?: string;
|
||||
candidateType?: string;
|
||||
candidateType?: RTCStatsIceCandidateType;
|
||||
priority?: number;
|
||||
addressSourceUrl?: string;
|
||||
}
|
||||
@@ -821,10 +821,10 @@ interface RTCIceCandidateDictionary {
|
||||
foundation?: string;
|
||||
priority?: number;
|
||||
ip?: string;
|
||||
protocol?: string;
|
||||
protocol?: RTCIceProtocol;
|
||||
port?: number;
|
||||
type?: string;
|
||||
tcpType?: string;
|
||||
type?: RTCIceCandidateType;
|
||||
tcpType?: RTCIceTcpCandidateType;
|
||||
relatedAddress?: string;
|
||||
relatedPort?: number;
|
||||
msMTurnSessionId?: string;
|
||||
@@ -845,7 +845,7 @@ interface RTCIceCandidatePairStats extends RTCStats {
|
||||
transportId?: string;
|
||||
localCandidateId?: string;
|
||||
remoteCandidateId?: string;
|
||||
state?: string;
|
||||
state?: RTCStatsIceCandidatePairState;
|
||||
priority?: number;
|
||||
nominated?: boolean;
|
||||
writable?: boolean;
|
||||
@@ -858,7 +858,7 @@ interface RTCIceCandidatePairStats extends RTCStats {
|
||||
}
|
||||
|
||||
interface RTCIceGatherOptions {
|
||||
gatherPolicy?: string;
|
||||
gatherPolicy?: RTCIceGatherPolicy;
|
||||
iceservers?: RTCIceServer[];
|
||||
portRange?: MSPortRange;
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ interface RTCRtpParameters {
|
||||
headerExtensions?: RTCRtpHeaderExtensionParameters[];
|
||||
encodings?: RTCRtpEncodingParameters[];
|
||||
rtcp?: RTCRtcpParameters;
|
||||
degradationPreference?: string;
|
||||
degradationPreference?: RTCDegradationPreference;
|
||||
}
|
||||
|
||||
interface RTCRtpRtxParameters {
|
||||
@@ -1037,7 +1037,7 @@ interface RTCRtpUnhandled {
|
||||
}
|
||||
|
||||
interface RTCSessionDescriptionInit {
|
||||
type?: string;
|
||||
type?: RTCSdpType;
|
||||
sdp?: string;
|
||||
}
|
||||
|
||||
@@ -1063,9 +1063,9 @@ interface RTCSsrcRange {
|
||||
|
||||
interface RTCStats {
|
||||
timestamp?: number;
|
||||
type?: string;
|
||||
type?: RTCStatsType;
|
||||
id?: string;
|
||||
msType?: string;
|
||||
msType?: MSStatsType;
|
||||
}
|
||||
|
||||
interface RTCStatsReport {
|
||||
@@ -1090,11 +1090,11 @@ interface RequestInit {
|
||||
headers?: any;
|
||||
body?: any;
|
||||
referrer?: string;
|
||||
referrerPolicy?: string;
|
||||
mode?: string;
|
||||
credentials?: string;
|
||||
cache?: string;
|
||||
redirect?: string;
|
||||
referrerPolicy?: ReferrerPolicy;
|
||||
mode?: RequestMode;
|
||||
credentials?: RequestCredentials;
|
||||
cache?: RequestCache;
|
||||
redirect?: RequestRedirect;
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
window?: any;
|
||||
@@ -1107,9 +1107,9 @@ interface ResponseInit {
|
||||
}
|
||||
|
||||
interface ScopedCredentialDescriptor {
|
||||
type?: string;
|
||||
type?: ScopedCredentialType;
|
||||
id?: any;
|
||||
transports?: string[];
|
||||
transports?: Transport[];
|
||||
}
|
||||
|
||||
interface ScopedCredentialOptions {
|
||||
@@ -1120,7 +1120,7 @@ interface ScopedCredentialOptions {
|
||||
}
|
||||
|
||||
interface ScopedCredentialParameters {
|
||||
type?: string;
|
||||
type?: ScopedCredentialType;
|
||||
algorithm?: string | Algorithm;
|
||||
}
|
||||
|
||||
@@ -1350,7 +1350,7 @@ interface AudioContextBase extends EventTarget {
|
||||
readonly listener: AudioListener;
|
||||
onstatechange: (this: AudioContext, ev: Event) => any;
|
||||
readonly sampleRate: number;
|
||||
readonly state: string;
|
||||
readonly state: AudioContextState;
|
||||
close(): Promise<void>;
|
||||
createAnalyser(): AnalyserNode;
|
||||
createBiquadFilter(): BiquadFilterNode;
|
||||
@@ -1410,12 +1410,13 @@ declare var AudioListener: {
|
||||
|
||||
interface AudioNode extends EventTarget {
|
||||
channelCount: number;
|
||||
channelCountMode: string;
|
||||
channelInterpretation: string;
|
||||
channelCountMode: ChannelCountMode;
|
||||
channelInterpretation: ChannelInterpretation;
|
||||
readonly context: AudioContext;
|
||||
readonly numberOfInputs: number;
|
||||
readonly numberOfOutputs: number;
|
||||
connect(destination: AudioNode, output?: number, input?: number): AudioNode;
|
||||
connect(destination: AudioParam, output?: number): void;
|
||||
disconnect(output?: number): void;
|
||||
disconnect(destination: AudioNode, output?: number, input?: number): void;
|
||||
disconnect(destination: AudioParam, output?: number): void;
|
||||
@@ -1513,7 +1514,7 @@ interface BiquadFilterNode extends AudioNode {
|
||||
readonly detune: AudioParam;
|
||||
readonly frequency: AudioParam;
|
||||
readonly gain: AudioParam;
|
||||
type: string;
|
||||
type: BiquadFilterType;
|
||||
getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void;
|
||||
}
|
||||
|
||||
@@ -2153,7 +2154,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods {
|
||||
lineJoin: string;
|
||||
lineWidth: number;
|
||||
miterLimit: number;
|
||||
msFillRule: string;
|
||||
msFillRule: CanvasFillRule;
|
||||
shadowBlur: number;
|
||||
shadowColor: string;
|
||||
shadowOffsetX: number;
|
||||
@@ -2166,19 +2167,21 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods {
|
||||
oImageSmoothingEnabled: boolean;
|
||||
beginPath(): void;
|
||||
clearRect(x: number, y: number, w: number, h: number): void;
|
||||
clip(fillRule?: string): void;
|
||||
clip(fillRule?: CanvasFillRule): void;
|
||||
createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData;
|
||||
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
||||
createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
||||
drawFocusIfNeeded(element: Element): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
fill(fillRule?: string): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void;
|
||||
fill(fillRule?: CanvasFillRule): void;
|
||||
fillRect(x: number, y: number, w: number, h: number): void;
|
||||
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
|
||||
getLineDash(): number[];
|
||||
isPointInPath(x: number, y: number, fillRule?: string): boolean;
|
||||
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
|
||||
measureText(text: string): TextMetrics;
|
||||
putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void;
|
||||
restore(): void;
|
||||
@@ -2469,10 +2472,10 @@ declare var DOMException: {
|
||||
}
|
||||
|
||||
interface DOMImplementation {
|
||||
createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document;
|
||||
createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document;
|
||||
createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType;
|
||||
createHTMLDocument(title: string): Document;
|
||||
hasFeature(): boolean;
|
||||
hasFeature(feature: string | null, version: string | null): boolean;
|
||||
}
|
||||
|
||||
declare var DOMImplementation: {
|
||||
@@ -2555,6 +2558,7 @@ interface DataTransfer {
|
||||
clearData(format?: string): boolean;
|
||||
getData(format: string): string;
|
||||
setData(format: string, data: string): boolean;
|
||||
setDragImage(image: Element, x: number, y: number): void;
|
||||
}
|
||||
|
||||
declare var DataTransfer: {
|
||||
@@ -2591,7 +2595,7 @@ declare var DataTransferItemList: {
|
||||
|
||||
interface DeferredPermissionRequest {
|
||||
readonly id: number;
|
||||
readonly type: string;
|
||||
readonly type: MSWebViewPermissionType;
|
||||
readonly uri: string;
|
||||
allow(): void;
|
||||
deny(): void;
|
||||
@@ -3209,7 +3213,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* Contains the title of the document.
|
||||
*/
|
||||
title: string;
|
||||
readonly visibilityState: string;
|
||||
readonly visibilityState: VisibilityState;
|
||||
/**
|
||||
* Sets or gets the color of the links that the user has visited.
|
||||
*/
|
||||
@@ -3224,7 +3228,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* Gets or sets the version attribute specified in the declaration of an XML document.
|
||||
*/
|
||||
xmlVersion: string | null;
|
||||
adoptNode(source: Node): Node;
|
||||
adoptNode<T extends Node>(source: T): T;
|
||||
captureEvents(): void;
|
||||
caretRangeFromPoint(x: number, y: number): Range;
|
||||
clear(): void;
|
||||
@@ -3401,7 +3405,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* Gets a value indicating whether the object currently has focus.
|
||||
*/
|
||||
hasFocus(): boolean;
|
||||
importNode(importedNode: Node, deep: boolean): Node;
|
||||
importNode<T extends Node>(importedNode: T, deep: boolean): T;
|
||||
msElementsFromPoint(x: number, y: number): NodeListOf<Element>;
|
||||
msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf<Element>;
|
||||
/**
|
||||
@@ -3469,6 +3473,7 @@ declare var Document: {
|
||||
}
|
||||
|
||||
interface DocumentFragment extends Node, NodeSelector, ParentNode {
|
||||
getElementById(elementId: string): HTMLElement | null;
|
||||
}
|
||||
|
||||
declare var DocumentFragment: {
|
||||
@@ -3716,9 +3721,9 @@ declare var Event: {
|
||||
}
|
||||
|
||||
interface EventTarget {
|
||||
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
dispatchEvent(evt: Event): boolean;
|
||||
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
}
|
||||
|
||||
declare var EventTarget: {
|
||||
@@ -3797,7 +3802,7 @@ declare var FocusEvent: {
|
||||
}
|
||||
|
||||
interface FocusNavigationEvent extends Event {
|
||||
readonly navigationReason: string;
|
||||
readonly navigationReason: NavigationReason;
|
||||
readonly originHeight: number;
|
||||
readonly originLeft: number;
|
||||
readonly originTop: number;
|
||||
@@ -3811,7 +3816,12 @@ declare var FocusNavigationEvent: {
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
append(name: any, value: any, blobName?: string): void;
|
||||
append(name: string, value: string | Blob, fileName?: string): void;
|
||||
delete(name: string): void;
|
||||
get(name: string): FormDataEntryValue | null;
|
||||
getAll(name: string): FormDataEntryValue[];
|
||||
has(name: string): boolean;
|
||||
set(name: string, value: string | Blob, fileName?: string): void;
|
||||
}
|
||||
|
||||
declare var FormData: {
|
||||
@@ -6973,7 +6983,7 @@ declare var History: {
|
||||
}
|
||||
|
||||
interface IDBCursor {
|
||||
readonly direction: string;
|
||||
readonly direction: IDBCursorDirection;
|
||||
key: IDBKeyRange | IDBValidKey;
|
||||
readonly primaryKey: any;
|
||||
source: IDBObjectStore | IDBIndex;
|
||||
@@ -7125,7 +7135,7 @@ interface IDBRequest extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
onerror: (this: IDBRequest, ev: Event) => any;
|
||||
onsuccess: (this: IDBRequest, ev: Event) => any;
|
||||
readonly readyState: string;
|
||||
readonly readyState: IDBRequestReadyState;
|
||||
readonly result: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
readonly transaction: IDBTransaction;
|
||||
@@ -7147,7 +7157,7 @@ interface IDBTransactionEventMap {
|
||||
interface IDBTransaction extends EventTarget {
|
||||
readonly db: IDBDatabase;
|
||||
readonly error: DOMError;
|
||||
readonly mode: string;
|
||||
readonly mode: IDBTransactionMode;
|
||||
onabort: (this: IDBTransaction, ev: Event) => any;
|
||||
oncomplete: (this: IDBTransaction, ev: Event) => any;
|
||||
onerror: (this: IDBTransaction, ev: Event) => any;
|
||||
@@ -7265,7 +7275,7 @@ declare var KeyboardEvent: {
|
||||
|
||||
interface ListeningStateChangedEvent extends Event {
|
||||
readonly label: string;
|
||||
readonly state: string;
|
||||
readonly state: ListeningState;
|
||||
}
|
||||
|
||||
declare var ListeningStateChangedEvent: {
|
||||
@@ -7356,7 +7366,7 @@ declare var MSAppAsyncOperation: {
|
||||
|
||||
interface MSAssertion {
|
||||
readonly id: string;
|
||||
readonly type: string;
|
||||
readonly type: MSCredentialType;
|
||||
}
|
||||
|
||||
declare var MSAssertion: {
|
||||
@@ -7388,7 +7398,7 @@ interface MSFIDOCredentialAssertion extends MSAssertion {
|
||||
readonly algorithm: string | Algorithm;
|
||||
readonly attestation: any;
|
||||
readonly publicKey: string;
|
||||
readonly transportHints: string[];
|
||||
readonly transportHints: MSTransportType[];
|
||||
}
|
||||
|
||||
declare var MSFIDOCredentialAssertion: {
|
||||
@@ -7492,7 +7502,7 @@ interface MSHTMLWebViewElement extends HTMLElement {
|
||||
goForward(): void;
|
||||
invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation;
|
||||
navigate(uri: string): void;
|
||||
navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void;
|
||||
navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void;
|
||||
navigateToLocalStreamUri(source: string, streamResolver: any): void;
|
||||
navigateToString(contents: string): void;
|
||||
navigateWithHttpRequestMessage(requestMessage: any): void;
|
||||
@@ -7747,7 +7757,7 @@ declare var MSWebViewSettings: {
|
||||
interface MediaDeviceInfo {
|
||||
readonly deviceId: string;
|
||||
readonly groupId: string;
|
||||
readonly kind: string;
|
||||
readonly kind: MediaDeviceKind;
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
@@ -7814,7 +7824,7 @@ declare var MediaError: {
|
||||
|
||||
interface MediaKeyMessageEvent extends Event {
|
||||
readonly message: ArrayBuffer;
|
||||
readonly messageType: string;
|
||||
readonly messageType: MediaKeyMessageType;
|
||||
}
|
||||
|
||||
declare var MediaKeyMessageEvent: {
|
||||
@@ -7842,7 +7852,7 @@ declare var MediaKeySession: {
|
||||
interface MediaKeyStatusMap {
|
||||
readonly size: number;
|
||||
forEach(callback: ForEachCallback): void;
|
||||
get(keyId: any): string;
|
||||
get(keyId: any): MediaKeyStatus;
|
||||
has(keyId: any): boolean;
|
||||
}
|
||||
|
||||
@@ -7863,7 +7873,7 @@ declare var MediaKeySystemAccess: {
|
||||
}
|
||||
|
||||
interface MediaKeys {
|
||||
createSession(sessionType?: string): MediaKeySession;
|
||||
createSession(sessionType?: MediaKeySessionType): MediaKeySession;
|
||||
setServerCertificate(serverCertificate: any): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -8001,7 +8011,7 @@ interface MediaStreamTrack extends EventTarget {
|
||||
onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any;
|
||||
onunmute: (this: MediaStreamTrack, ev: Event) => any;
|
||||
readonly readonly: boolean;
|
||||
readonly readyState: string;
|
||||
readonly readyState: MediaStreamTrackState;
|
||||
readonly remote: boolean;
|
||||
applyConstraints(constraints: MediaTrackConstraints): Promise<void>;
|
||||
clone(): MediaStreamTrack;
|
||||
@@ -8222,7 +8232,7 @@ declare var NavigationEventWithReferrer: {
|
||||
interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia {
|
||||
readonly authentication: WebAuthentication;
|
||||
readonly cookieEnabled: boolean;
|
||||
gamepadInputEmulation: string;
|
||||
gamepadInputEmulation: GamepadInputEmulationType;
|
||||
readonly language: string;
|
||||
readonly maxTouchPoints: number;
|
||||
readonly mimeTypes: MimeTypeArray;
|
||||
@@ -8269,15 +8279,15 @@ interface Node extends EventTarget {
|
||||
contains(child: Node): boolean;
|
||||
hasAttributes(): boolean;
|
||||
hasChildNodes(): boolean;
|
||||
insertBefore(newChild: Node, refChild: Node | null): Node;
|
||||
insertBefore<T extends Node>(newChild: T, refChild: Node | null): T;
|
||||
isDefaultNamespace(namespaceURI: string | null): boolean;
|
||||
isEqualNode(arg: Node): boolean;
|
||||
isSameNode(other: Node): boolean;
|
||||
lookupNamespaceURI(prefix: string | null): string | null;
|
||||
lookupPrefix(namespaceURI: string | null): string | null;
|
||||
normalize(): void;
|
||||
removeChild(oldChild: Node): Node;
|
||||
replaceChild(newChild: Node, oldChild: Node): Node;
|
||||
removeChild<T extends Node>(oldChild: T): T;
|
||||
replaceChild<T extends Node>(newChild: Node, oldChild: T): T;
|
||||
readonly ATTRIBUTE_NODE: number;
|
||||
readonly CDATA_SECTION_NODE: number;
|
||||
readonly COMMENT_NODE: number;
|
||||
@@ -8379,14 +8389,14 @@ interface NotificationEventMap {
|
||||
|
||||
interface Notification extends EventTarget {
|
||||
readonly body: string;
|
||||
readonly dir: string;
|
||||
readonly dir: NotificationDirection;
|
||||
readonly icon: string;
|
||||
readonly lang: string;
|
||||
onclick: (this: Notification, ev: Event) => any;
|
||||
onclose: (this: Notification, ev: Event) => any;
|
||||
onerror: (this: Notification, ev: Event) => any;
|
||||
onshow: (this: Notification, ev: Event) => any;
|
||||
readonly permission: string;
|
||||
readonly permission: NotificationPermission;
|
||||
readonly tag: string;
|
||||
readonly title: string;
|
||||
close(): void;
|
||||
@@ -8397,7 +8407,7 @@ interface Notification extends EventTarget {
|
||||
declare var Notification: {
|
||||
prototype: Notification;
|
||||
new(title: string, options?: NotificationOptions): Notification;
|
||||
requestPermission(callback?: NotificationPermissionCallback): Promise<string>;
|
||||
requestPermission(callback?: NotificationPermissionCallback): Promise<NotificationPermission>;
|
||||
}
|
||||
|
||||
interface OES_element_index_uint {
|
||||
@@ -8487,7 +8497,7 @@ interface OscillatorNode extends AudioNode {
|
||||
readonly detune: AudioParam;
|
||||
readonly frequency: AudioParam;
|
||||
onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any;
|
||||
type: string;
|
||||
type: OscillatorType;
|
||||
setPeriodicWave(periodicWave: PeriodicWave): void;
|
||||
start(when?: number): void;
|
||||
stop(when?: number): void;
|
||||
@@ -8530,9 +8540,9 @@ interface PannerNode extends AudioNode {
|
||||
coneInnerAngle: number;
|
||||
coneOuterAngle: number;
|
||||
coneOuterGain: number;
|
||||
distanceModel: string;
|
||||
distanceModel: DistanceModelType;
|
||||
maxDistance: number;
|
||||
panningModel: string;
|
||||
panningModel: PanningModelType;
|
||||
refDistance: number;
|
||||
rolloffFactor: number;
|
||||
setOrientation(x: number, y: number, z: number): void;
|
||||
@@ -8583,7 +8593,7 @@ interface PaymentRequest extends EventTarget {
|
||||
onshippingoptionchange: (this: PaymentRequest, ev: Event) => any;
|
||||
readonly shippingAddress: PaymentAddress | null;
|
||||
readonly shippingOption: string | null;
|
||||
readonly shippingType: string | null;
|
||||
readonly shippingType: PaymentShippingType | null;
|
||||
abort(): Promise<void>;
|
||||
show(): Promise<PaymentResponse>;
|
||||
addEventListener<K extends keyof PaymentRequestEventMap>(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void;
|
||||
@@ -8612,7 +8622,7 @@ interface PaymentResponse {
|
||||
readonly payerPhone: string | null;
|
||||
readonly shippingAddress: PaymentAddress | null;
|
||||
readonly shippingOption: string | null;
|
||||
complete(result?: string): Promise<void>;
|
||||
complete(result?: PaymentComplete): Promise<void>;
|
||||
toJSON(): any;
|
||||
}
|
||||
|
||||
@@ -8740,7 +8750,7 @@ interface PerformanceNavigationTiming extends PerformanceEntry {
|
||||
readonly requestStart: number;
|
||||
readonly responseEnd: number;
|
||||
readonly responseStart: number;
|
||||
readonly type: string;
|
||||
readonly type: NavigationType;
|
||||
readonly unloadEventEnd: number;
|
||||
readonly unloadEventStart: number;
|
||||
}
|
||||
@@ -8809,7 +8819,7 @@ declare var PeriodicWave: {
|
||||
}
|
||||
|
||||
interface PermissionRequest extends DeferredPermissionRequest {
|
||||
readonly state: string;
|
||||
readonly state: MSWebViewPermissionState;
|
||||
defer(): void;
|
||||
}
|
||||
|
||||
@@ -8939,7 +8949,7 @@ declare var ProgressEvent: {
|
||||
|
||||
interface PushManager {
|
||||
getSubscription(): Promise<PushSubscription>;
|
||||
permissionState(options?: PushSubscriptionOptionsInit): Promise<string>;
|
||||
permissionState(options?: PushSubscriptionOptionsInit): Promise<PushPermissionState>;
|
||||
subscribe(options?: PushSubscriptionOptionsInit): Promise<PushSubscription>;
|
||||
}
|
||||
|
||||
@@ -8951,7 +8961,7 @@ declare var PushManager: {
|
||||
interface PushSubscription {
|
||||
readonly endpoint: USVString;
|
||||
readonly options: PushSubscriptionOptions;
|
||||
getKey(name: string): ArrayBuffer | null;
|
||||
getKey(name: PushEncryptionKeyName): ArrayBuffer | null;
|
||||
toJSON(): any;
|
||||
unsubscribe(): Promise<boolean>;
|
||||
}
|
||||
@@ -8988,7 +8998,7 @@ interface RTCDtlsTransportEventMap {
|
||||
interface RTCDtlsTransport extends RTCStatsProvider {
|
||||
ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null;
|
||||
onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null;
|
||||
readonly state: string;
|
||||
readonly state: RTCDtlsTransportState;
|
||||
readonly transport: RTCIceTransport;
|
||||
getLocalParameters(): RTCDtlsParameters;
|
||||
getRemoteCertificates(): ArrayBuffer[];
|
||||
@@ -9005,7 +9015,7 @@ declare var RTCDtlsTransport: {
|
||||
}
|
||||
|
||||
interface RTCDtlsTransportStateChangedEvent extends Event {
|
||||
readonly state: string;
|
||||
readonly state: RTCDtlsTransportState;
|
||||
}
|
||||
|
||||
declare var RTCDtlsTransportStateChangedEvent: {
|
||||
@@ -9061,7 +9071,7 @@ interface RTCIceGathererEventMap {
|
||||
}
|
||||
|
||||
interface RTCIceGatherer extends RTCStatsProvider {
|
||||
readonly component: string;
|
||||
readonly component: RTCIceComponent;
|
||||
onerror: ((this: RTCIceGatherer, ev: Event) => any) | null;
|
||||
onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null;
|
||||
createAssociatedGatherer(): RTCIceGatherer;
|
||||
@@ -9091,19 +9101,19 @@ interface RTCIceTransportEventMap {
|
||||
}
|
||||
|
||||
interface RTCIceTransport extends RTCStatsProvider {
|
||||
readonly component: string;
|
||||
readonly component: RTCIceComponent;
|
||||
readonly iceGatherer: RTCIceGatherer | null;
|
||||
oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null;
|
||||
onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null;
|
||||
readonly role: string;
|
||||
readonly state: string;
|
||||
readonly role: RTCIceRole;
|
||||
readonly state: RTCIceTransportState;
|
||||
addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void;
|
||||
createAssociatedTransport(): RTCIceTransport;
|
||||
getNominatedCandidatePair(): RTCIceCandidatePair | null;
|
||||
getRemoteCandidates(): RTCIceCandidateDictionary[];
|
||||
getRemoteParameters(): RTCIceParameters | null;
|
||||
setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void;
|
||||
start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void;
|
||||
start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void;
|
||||
stop(): void;
|
||||
addEventListener<K extends keyof RTCIceTransportEventMap>(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -9115,7 +9125,7 @@ declare var RTCIceTransport: {
|
||||
}
|
||||
|
||||
interface RTCIceTransportStateChangedEvent extends Event {
|
||||
readonly state: string;
|
||||
readonly state: RTCIceTransportState;
|
||||
}
|
||||
|
||||
declare var RTCIceTransportStateChangedEvent: {
|
||||
@@ -9135,8 +9145,8 @@ interface RTCPeerConnectionEventMap {
|
||||
|
||||
interface RTCPeerConnection extends EventTarget {
|
||||
readonly canTrickleIceCandidates: boolean | null;
|
||||
readonly iceConnectionState: string;
|
||||
readonly iceGatheringState: string;
|
||||
readonly iceConnectionState: RTCIceConnectionState;
|
||||
readonly iceGatheringState: RTCIceGatheringState;
|
||||
readonly localDescription: RTCSessionDescription | null;
|
||||
onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any;
|
||||
onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any;
|
||||
@@ -9146,7 +9156,7 @@ interface RTCPeerConnection extends EventTarget {
|
||||
onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any;
|
||||
onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any;
|
||||
readonly remoteDescription: RTCSessionDescription | null;
|
||||
readonly signalingState: string;
|
||||
readonly signalingState: RTCSignalingState;
|
||||
addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise<void>;
|
||||
addStream(stream: MediaStream): void;
|
||||
close(): void;
|
||||
@@ -9229,7 +9239,7 @@ declare var RTCRtpSender: {
|
||||
|
||||
interface RTCSessionDescription {
|
||||
sdp: string | null;
|
||||
type: string | null;
|
||||
type: RTCSdpType | null;
|
||||
toJSON(): any;
|
||||
}
|
||||
|
||||
@@ -9288,7 +9298,7 @@ interface Range {
|
||||
createContextualFragment(fragment: string): DocumentFragment;
|
||||
deleteContents(): void;
|
||||
detach(): void;
|
||||
expand(Unit: string): boolean;
|
||||
expand(Unit: ExpandGranularity): boolean;
|
||||
extractContents(): DocumentFragment;
|
||||
getBoundingClientRect(): ClientRect;
|
||||
getClientRects(): ClientRectList;
|
||||
@@ -9341,18 +9351,18 @@ declare var ReadableStreamReader: {
|
||||
}
|
||||
|
||||
interface Request extends Object, Body {
|
||||
readonly cache: string;
|
||||
readonly credentials: string;
|
||||
readonly destination: string;
|
||||
readonly cache: RequestCache;
|
||||
readonly credentials: RequestCredentials;
|
||||
readonly destination: RequestDestination;
|
||||
readonly headers: Headers;
|
||||
readonly integrity: string;
|
||||
readonly keepalive: boolean;
|
||||
readonly method: string;
|
||||
readonly mode: string;
|
||||
readonly redirect: string;
|
||||
readonly mode: RequestMode;
|
||||
readonly redirect: RequestRedirect;
|
||||
readonly referrer: string;
|
||||
readonly referrerPolicy: string;
|
||||
readonly type: string;
|
||||
readonly referrerPolicy: ReferrerPolicy;
|
||||
readonly type: RequestType;
|
||||
readonly url: string;
|
||||
clone(): Request;
|
||||
}
|
||||
@@ -9368,7 +9378,7 @@ interface Response extends Object, Body {
|
||||
readonly ok: boolean;
|
||||
readonly status: number;
|
||||
readonly statusText: string;
|
||||
readonly type: string;
|
||||
readonly type: ResponseType;
|
||||
readonly url: string;
|
||||
clone(): Response;
|
||||
}
|
||||
@@ -11168,7 +11178,7 @@ declare var SVGZoomEvent: {
|
||||
|
||||
interface ScopedCredential {
|
||||
readonly id: ArrayBuffer;
|
||||
readonly type: string;
|
||||
readonly type: ScopedCredentialType;
|
||||
}
|
||||
|
||||
declare var ScopedCredential: {
|
||||
@@ -11285,7 +11295,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
|
||||
interface ServiceWorker extends EventTarget, AbstractWorker {
|
||||
onstatechange: (this: ServiceWorker, ev: Event) => any;
|
||||
readonly scriptURL: USVString;
|
||||
readonly state: string;
|
||||
readonly state: ServiceWorkerState;
|
||||
postMessage(message: any, transfer?: any[]): void;
|
||||
addEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -11361,7 +11371,7 @@ interface SourceBuffer extends EventTarget {
|
||||
appendWindowStart: number;
|
||||
readonly audioTracks: AudioTrackList;
|
||||
readonly buffered: TimeRanges;
|
||||
mode: string;
|
||||
mode: AppendMode;
|
||||
timestampOffset: number;
|
||||
readonly updating: boolean;
|
||||
readonly videoTracks: VideoTrackList;
|
||||
@@ -11597,7 +11607,7 @@ interface Text extends CharacterData {
|
||||
|
||||
declare var Text: {
|
||||
prototype: Text;
|
||||
new(): Text;
|
||||
new(data?: string): Text;
|
||||
}
|
||||
|
||||
interface TextEvent extends UIEvent {
|
||||
@@ -11780,7 +11790,7 @@ interface TouchEvent extends UIEvent {
|
||||
|
||||
declare var TouchEvent: {
|
||||
prototype: TouchEvent;
|
||||
new(): TouchEvent;
|
||||
new(type: string, touchEventInit?: TouchEventInit): TouchEvent;
|
||||
}
|
||||
|
||||
interface TouchList {
|
||||
@@ -11857,7 +11867,7 @@ interface URL {
|
||||
protocol: string;
|
||||
search: string;
|
||||
username: string;
|
||||
readonly searchparams: URLSearchParams;
|
||||
readonly searchParams: URLSearchParams;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
@@ -11986,7 +11996,7 @@ declare var WEBGL_depth_texture: {
|
||||
|
||||
interface WaveShaperNode extends AudioNode {
|
||||
curve: Float32Array | null;
|
||||
oversample: string;
|
||||
oversample: OverSampleType;
|
||||
}
|
||||
|
||||
declare var WaveShaperNode: {
|
||||
@@ -12181,12 +12191,12 @@ interface WebGLRenderingContext {
|
||||
stencilMaskSeparate(face: number, mask: number): void;
|
||||
stencilOp(fail: number, zfail: number, zpass: number): void;
|
||||
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels?: ArrayBufferView): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
|
||||
texParameterf(target: number, pname: number, param: number): void;
|
||||
texParameteri(target: number, pname: number, param: number): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels?: ArrayBufferView): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
|
||||
uniform1f(location: WebGLUniformLocation | null, x: number): void;
|
||||
uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void;
|
||||
uniform1i(location: WebGLUniformLocation | null, x: number): void;
|
||||
@@ -13247,6 +13257,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
readonly top: Window;
|
||||
readonly window: Window;
|
||||
URL: typeof URL;
|
||||
URLSearchParams: typeof URLSearchParams;
|
||||
Blob: typeof Blob;
|
||||
customElements: CustomElementRegistry;
|
||||
alert(message?: any): void;
|
||||
@@ -13255,7 +13266,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
captureEvents(): void;
|
||||
close(): void;
|
||||
confirm(message?: string): boolean;
|
||||
departFocus(navigationReason: string, origin: FocusNavigationOrigin): void;
|
||||
departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void;
|
||||
focus(): void;
|
||||
getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration;
|
||||
getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList;
|
||||
@@ -13280,6 +13291,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint;
|
||||
webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint;
|
||||
webkitRequestAnimationFrame(callback: FrameRequestCallback): number;
|
||||
createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
scroll(options?: ScrollToOptions): void;
|
||||
scrollTo(options?: ScrollToOptions): void;
|
||||
scrollBy(options?: ScrollToOptions): void;
|
||||
@@ -13328,7 +13341,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
responseType: string;
|
||||
responseType: XMLHttpRequestResponseType;
|
||||
readonly responseURL: string;
|
||||
readonly responseXML: Document | null;
|
||||
readonly status: number;
|
||||
@@ -13493,6 +13506,7 @@ interface Body {
|
||||
blob(): Promise<Blob>;
|
||||
json(): Promise<any>;
|
||||
text(): Promise<string>;
|
||||
formData(): Promise<FormData>;
|
||||
}
|
||||
|
||||
interface CanvasPathMethods {
|
||||
@@ -13855,6 +13869,21 @@ interface Canvas2DContextAttributes {
|
||||
[attribute: string]: boolean | string | undefined;
|
||||
}
|
||||
|
||||
interface ImageBitmapOptions {
|
||||
imageOrientation?: "none" | "flipY";
|
||||
premultiplyAlpha?: "none" | "premultiply" | "default";
|
||||
colorSpaceConversion?: "none" | "default";
|
||||
resizeWidth?: number;
|
||||
resizeHeight?: number;
|
||||
resizeQuality?: "pixelated" | "low" | "medium" | "high";
|
||||
}
|
||||
|
||||
interface ImageBitmap {
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Appends a specified key/value pair as a new search parameter.
|
||||
@@ -13899,6 +13928,7 @@ interface NodeListOf<TNode extends Node> extends NodeList {
|
||||
interface HTMLCollectionOf<T extends Element> extends HTMLCollection {
|
||||
item(index: number): T;
|
||||
namedItem(name: string): T;
|
||||
[index: number]: T;
|
||||
}
|
||||
|
||||
interface BlobPropertyBag {
|
||||
@@ -14168,6 +14198,21 @@ interface PromiseRejectionEventInit extends EventInit {
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
interface EventListenerOptions {
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
interface AddEventListenerOptions extends EventListenerOptions {
|
||||
passive?: boolean;
|
||||
once?: boolean;
|
||||
}
|
||||
|
||||
interface TouchEventInit extends EventModifierInit {
|
||||
touches?: Touch[];
|
||||
targetTouches?: Touch[];
|
||||
changedTouches?: Touch[];
|
||||
}
|
||||
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
@@ -14225,10 +14270,10 @@ interface NavigatorUserMediaErrorCallback {
|
||||
(error: MediaStreamError): void;
|
||||
}
|
||||
interface ForEachCallback {
|
||||
(keyId: any, status: string): void;
|
||||
(keyId: any, status: MediaKeyStatus): void;
|
||||
}
|
||||
interface NotificationPermissionCallback {
|
||||
(permission: string): void;
|
||||
(permission: NotificationPermission): void;
|
||||
}
|
||||
interface IntersectionObserverCallback {
|
||||
(entries: IntersectionObserverEntry[], observer: IntersectionObserver): void;
|
||||
@@ -14835,7 +14880,7 @@ declare function cancelAnimationFrame(handle: number): void;
|
||||
declare function captureEvents(): void;
|
||||
declare function close(): void;
|
||||
declare function confirm(message?: string): boolean;
|
||||
declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void;
|
||||
declare function departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void;
|
||||
declare function focus(): void;
|
||||
declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration;
|
||||
declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList;
|
||||
@@ -14860,12 +14905,14 @@ declare function webkitCancelAnimationFrame(handle: number): void;
|
||||
declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint;
|
||||
declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint;
|
||||
declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number;
|
||||
declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
declare function scroll(options?: ScrollToOptions): void;
|
||||
declare function scrollTo(options?: ScrollToOptions): void;
|
||||
declare function scrollBy(options?: ScrollToOptions): void;
|
||||
declare function toString(): string;
|
||||
declare function dispatchEvent(evt: Event): boolean;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
declare function clearInterval(handle: number): void;
|
||||
declare function clearTimeout(handle: number): void;
|
||||
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
|
||||
@@ -14934,4 +14981,76 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type MouseWheelEvent = WheelEvent;
|
||||
type ScrollRestoration = "auto" | "manual";
|
||||
type ScrollRestoration = "auto" | "manual";
|
||||
type FormDataEntryValue = string | File;
|
||||
type AppendMode = "segments" | "sequence";
|
||||
type AudioContextState = "suspended" | "running" | "closed";
|
||||
type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass";
|
||||
type CanvasFillRule = "nonzero" | "evenodd";
|
||||
type ChannelCountMode = "max" | "clamped-max" | "explicit";
|
||||
type ChannelInterpretation = "speakers" | "discrete";
|
||||
type DistanceModelType = "linear" | "inverse" | "exponential";
|
||||
type ExpandGranularity = "character" | "word" | "sentence" | "textedit";
|
||||
type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad";
|
||||
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
|
||||
type IDBRequestReadyState = "pending" | "done";
|
||||
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
|
||||
type ListeningState = "inactive" | "active" | "disambiguation";
|
||||
type MSCredentialType = "FIDO_2_0";
|
||||
type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived";
|
||||
type MSIceType = "failed" | "direct" | "relay";
|
||||
type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics";
|
||||
type MSTransportType = "Embedded" | "USB" | "NFC" | "BT";
|
||||
type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny";
|
||||
type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications";
|
||||
type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput";
|
||||
type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request";
|
||||
type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message";
|
||||
type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error";
|
||||
type MediaKeysRequirement = "required" | "optional" | "not-allowed";
|
||||
type MediaStreamTrackState = "live" | "ended";
|
||||
type NavigationReason = "up" | "down" | "left" | "right";
|
||||
type NavigationType = "navigate" | "reload" | "back_forward" | "prerender";
|
||||
type NotificationDirection = "auto" | "ltr" | "rtl";
|
||||
type NotificationPermission = "default" | "denied" | "granted";
|
||||
type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom";
|
||||
type OverSampleType = "none" | "2x" | "4x";
|
||||
type PanningModelType = "equalpower";
|
||||
type PaymentComplete = "success" | "fail" | "";
|
||||
type PaymentShippingType = "shipping" | "delivery" | "pickup";
|
||||
type PushEncryptionKeyName = "p256dh" | "auth";
|
||||
type PushPermissionState = "granted" | "denied" | "prompt";
|
||||
type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle";
|
||||
type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced";
|
||||
type RTCDtlsRole = "auto" | "client" | "server";
|
||||
type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed";
|
||||
type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay";
|
||||
type RTCIceComponent = "RTP" | "RTCP";
|
||||
type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed";
|
||||
type RTCIceGatherPolicy = "all" | "nohost" | "relay";
|
||||
type RTCIceGathererState = "new" | "gathering" | "complete";
|
||||
type RTCIceGatheringState = "new" | "gathering" | "complete";
|
||||
type RTCIceProtocol = "udp" | "tcp";
|
||||
type RTCIceRole = "controlling" | "controlled";
|
||||
type RTCIceTcpCandidateType = "active" | "passive" | "so";
|
||||
type RTCIceTransportPolicy = "none" | "relay" | "all";
|
||||
type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed";
|
||||
type RTCSdpType = "offer" | "pranswer" | "answer";
|
||||
type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed";
|
||||
type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled";
|
||||
type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed";
|
||||
type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate";
|
||||
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
|
||||
type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache";
|
||||
type RequestCredentials = "omit" | "same-origin" | "include";
|
||||
type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker";
|
||||
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
|
||||
type RequestRedirect = "follow" | "error" | "manual";
|
||||
type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video";
|
||||
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
|
||||
type ScopedCredentialType = "ScopedCred";
|
||||
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
|
||||
type Transport = "usb" | "nfc" | "ble";
|
||||
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
|
||||
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
|
||||
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
|
||||
Vendored
+96
-2
@@ -24,10 +24,104 @@ interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[string, string | File]>;
|
||||
/**
|
||||
* Returns a list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<string | File>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<string | File>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all key/value pairs contained in this object.
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all keys f the key/value pairs contained in this object.
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[number, Node]>;
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
|
||||
* @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.
|
||||
*/
|
||||
forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<Node>;
|
||||
|
||||
|
||||
[Symbol.iterator](): IterableIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): IterableIterator<[number, TNode]>;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
|
||||
* @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.
|
||||
*/
|
||||
forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf<TNode>) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): IterableIterator<TNode>;
|
||||
|
||||
[Symbol.iterator](): IterableIterator<TNode>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the search params
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns a list of keys in the search params
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the search params
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
/**
|
||||
* iterate over key/value pairs
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -37,7 +37,7 @@ declare var Map: MapConstructor;
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V|undefined;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
@@ -50,9 +50,9 @@ interface WeakMap<K extends object, V> {
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new (): WeakMap<object, any>;
|
||||
new <K extends object, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
readonly prototype: WeakMap<object, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
@@ -85,8 +85,8 @@ interface WeakSet<T> {
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new (): WeakSet<any>;
|
||||
new <T>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<any>;
|
||||
new (): WeakSet<object>;
|
||||
new <T extends object>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<object>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
Vendored
+293
-283
@@ -22,69 +22,75 @@ declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @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: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T | undefined;
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @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: T, index: number, obj: Array<T>) => boolean, thisArg?: any): number;
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: T, start?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
* Returns the this object after copying a section of the array identified by start and end
|
||||
* to the same array starting at position target
|
||||
* @param target If target is negative, it is treated as length+target where length is the
|
||||
* length of the array.
|
||||
* @param start If start is negative, it is treated as length+start. If end is negative, it
|
||||
* is treated as length+end.
|
||||
* @param end If not specified, length of the this object is used as its default value.
|
||||
*/
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
* @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: (v: T, k: number) => U, thisArg?: any): Array<U>;
|
||||
* Creates an array from an array-like object.
|
||||
* @param arrayLike An array-like object to convert to an array.
|
||||
* @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.
|
||||
*/
|
||||
* 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>;
|
||||
|
||||
/**
|
||||
* Returns a new array from a set of elements.
|
||||
* @param items A set of elements to include in the new array object.
|
||||
*/
|
||||
* 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>;
|
||||
}
|
||||
|
||||
@@ -94,328 +100,332 @@ interface DateConstructor {
|
||||
|
||||
interface Function {
|
||||
/**
|
||||
* Returns the name of the function. Function names are read-only and can not be changed.
|
||||
*/
|
||||
* Returns the name of the function. Function names are read-only and can not be changed.
|
||||
*/
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/**
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
clz32(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the result of 32-bit multiplication of two numbers.
|
||||
* @param x First number
|
||||
* @param y Second number
|
||||
*/
|
||||
* Returns the result of 32-bit multiplication of two numbers.
|
||||
* @param x First number
|
||||
* @param y Second number
|
||||
*/
|
||||
imul(x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Returns the sign of the x, indicating whether x is positive, negative or zero.
|
||||
* @param x The numeric expression to test
|
||||
*/
|
||||
* Returns the sign of the x, indicating whether x is positive, negative or zero.
|
||||
* @param x The numeric expression to test
|
||||
*/
|
||||
sign(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the base 10 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the base 10 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log10(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the base 2 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the base 2 logarithm of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log2(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the natural logarithm of 1 + x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the natural logarithm of 1 + x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
log1p(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
|
||||
* the natural logarithms).
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of
|
||||
* the natural logarithms).
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
expm1(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
cosh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
sinh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
tanh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the inverse hyperbolic cosine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
acosh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the inverse hyperbolic sine of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
asinh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the inverse hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
* Returns the inverse hyperbolic tangent of a number.
|
||||
* @param x A numeric expression that contains an angle measured in radians.
|
||||
*/
|
||||
atanh(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the square root of the sum of squares of its arguments.
|
||||
* @param values Values to compute the square root for.
|
||||
* If no arguments are passed, the result is +0.
|
||||
* If there is only one argument, the result is the absolute value.
|
||||
* If any argument is +Infinity or -Infinity, the result is +Infinity.
|
||||
* If any argument is NaN, the result is NaN.
|
||||
* If all arguments are either +0 or −0, the result is +0.
|
||||
*/
|
||||
* Returns the square root of the sum of squares of its arguments.
|
||||
* @param values Values to compute the square root for.
|
||||
* If no arguments are passed, the result is +0.
|
||||
* If there is only one argument, the result is the absolute value.
|
||||
* If any argument is +Infinity or -Infinity, the result is +Infinity.
|
||||
* If any argument is NaN, the result is NaN.
|
||||
* If all arguments are either +0 or −0, the result is +0.
|
||||
*/
|
||||
hypot(...values: number[] ): number;
|
||||
|
||||
/**
|
||||
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
|
||||
* If x is already an integer, the result is x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the integral part of the a numeric expression, x, removing any fractional digits.
|
||||
* If x is already an integer, the result is x.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
trunc(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns the nearest single precision float representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns the nearest single precision float representation of a number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
fround(x: number): number;
|
||||
|
||||
/**
|
||||
* Returns an implementation-dependent approximation to the cube root of number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
* Returns an implementation-dependent approximation to the cube root of number.
|
||||
* @param x A numeric expression.
|
||||
*/
|
||||
cbrt(x: number): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
/**
|
||||
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
|
||||
* that is representable as a Number value, which is approximately:
|
||||
* 2.2204460492503130808472633361816 x 10−16.
|
||||
*/
|
||||
* The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1
|
||||
* that is representable as a Number value, which is approximately:
|
||||
* 2.2204460492503130808472633361816 x 10−16.
|
||||
*/
|
||||
readonly EPSILON: number;
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isFinite(number: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is an integer, false otherwise.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
* Returns true if the value passed is an integer, false otherwise.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isInteger(number: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
|
||||
* to a number. Only values of the type number, that are also NaN, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
* number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter
|
||||
* to a number. Only values of the type number, that are also NaN, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isNaN(number: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is a safe integer.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
* Returns true if the value passed is a safe integer.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isSafeInteger(number: number): boolean;
|
||||
|
||||
/**
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
|
||||
*/
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1.
|
||||
*/
|
||||
readonly MAX_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
|
||||
*/
|
||||
* The value of the smallest integer n such that n and n − 1 are both exactly representable as
|
||||
* a Number value.
|
||||
* The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)).
|
||||
*/
|
||||
readonly MIN_SAFE_INTEGER: number;
|
||||
|
||||
/**
|
||||
* Converts a string to a floating-point number.
|
||||
* @param string A string that contains a floating-point number.
|
||||
*/
|
||||
* Converts a string to a floating-point number.
|
||||
* @param string A string that contains a floating-point number.
|
||||
*/
|
||||
parseFloat(string: string): number;
|
||||
|
||||
/**
|
||||
* Converts A string to an integer.
|
||||
* @param s A string to convert into a number.
|
||||
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
|
||||
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
|
||||
* All other strings are considered decimal.
|
||||
*/
|
||||
* Converts A string to an integer.
|
||||
* @param s A string to convert into a number.
|
||||
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
|
||||
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
|
||||
* All other strings are considered decimal.
|
||||
*/
|
||||
parseInt(string: string, radix?: number): number;
|
||||
}
|
||||
|
||||
interface Object {
|
||||
/**
|
||||
* Determines whether an object has a property with the specified name.
|
||||
* @param v A property name.
|
||||
*/
|
||||
hasOwnProperty(v: PropertyKey): boolean
|
||||
* Determines whether an object has a property with the specified name.
|
||||
* @param v A property name.
|
||||
*/
|
||||
hasOwnProperty(v: PropertyKey): boolean;
|
||||
|
||||
/**
|
||||
* Determines whether a specified property is enumerable.
|
||||
* @param v A property name.
|
||||
*/
|
||||
* Determines whether a specified property is enumerable.
|
||||
* @param v A property name.
|
||||
*/
|
||||
propertyIsEnumerable(v: PropertyKey): boolean;
|
||||
}
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source The source object from which to copy properties.
|
||||
*/
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source The source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U>(target: T, source: U): T & U;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
*/
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
* @param source3 The third source object from which to copy properties.
|
||||
*/
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
* @param source3 The third source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param sources One or more source objects from which to copy properties
|
||||
*/
|
||||
assign(target: any, ...sources: any[]): any;
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param sources One or more source objects from which to copy properties
|
||||
*/
|
||||
assign(target: object, ...sources: any[]): any;
|
||||
|
||||
/**
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
* Returns an array of all symbol properties found directly on object o.
|
||||
* @param o Object to retrieve the symbols from.
|
||||
*/
|
||||
getOwnPropertySymbols(o: any): symbol[];
|
||||
|
||||
/**
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
* @param value1 The first value.
|
||||
* @param value2 The second value.
|
||||
*/
|
||||
* Returns true if the values are the same value, false otherwise.
|
||||
* @param value1 The first value.
|
||||
* @param value2 The second value.
|
||||
*/
|
||||
is(value1: any, value2: any): boolean;
|
||||
|
||||
/**
|
||||
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
|
||||
* @param o The object to change its prototype.
|
||||
* @param proto The value of the new prototype or null.
|
||||
*/
|
||||
* Sets the prototype of a specified object o to object proto or null. Returns the object o.
|
||||
* @param o The object to change its prototype.
|
||||
* @param proto The value of the new prototype or null.
|
||||
*/
|
||||
setPrototypeOf(o: any, proto: object | null): any;
|
||||
|
||||
/**
|
||||
* Gets the own property descriptor of the specified object.
|
||||
* An own property descriptor is one that is defined directly on the object and is not
|
||||
* inherited from the object's prototype.
|
||||
* @param o Object that contains the property.
|
||||
* @param p Name of the property.
|
||||
*/
|
||||
* Gets the own property descriptor of the specified object.
|
||||
* An own property descriptor is one that is defined directly on the object and is not
|
||||
* inherited from the object's prototype.
|
||||
* @param o Object that contains the property.
|
||||
* @param p Name of the property.
|
||||
*/
|
||||
getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
|
||||
/**
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
* @param o Object on which to add or modify the property. This can be a native JavaScript
|
||||
* object (that is, a user-defined object or a built in object) or a DOM object.
|
||||
* @param p The property name.
|
||||
* @param attributes Descriptor for the property. It can be for a data property or an accessor
|
||||
* property.
|
||||
*/
|
||||
* Adds a property to an object, or modifies attributes of an existing property.
|
||||
* @param o Object on which to add or modify the property. This can be a native JavaScript
|
||||
* object (that is, a user-defined object or a built in object) or a DOM object.
|
||||
* @param p The property name.
|
||||
* @param attributes Descriptor for the property. It can be for a data property or an accessor
|
||||
* property.
|
||||
*/
|
||||
defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @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: T, index: number, obj: ReadonlyArray<T>) => boolean, thisArg?: any): T | undefined;
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @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: T, index: number, obj: Array<T>) => boolean, thisArg?: any): number;
|
||||
/**
|
||||
* Returns the index of the first element in the array where predicate is true, and -1
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found,
|
||||
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
||||
* @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;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
|
||||
* The characters in this string are sequenced and concatenated in the following order:
|
||||
*
|
||||
* - "g" for global
|
||||
* - "i" for ignoreCase
|
||||
* - "m" for multiline
|
||||
* - "u" for unicode
|
||||
* - "y" for sticky
|
||||
*
|
||||
* If no flags are set, the value is the empty string.
|
||||
*/
|
||||
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
|
||||
* The characters in this string are sequenced and concatenated in the following order:
|
||||
*
|
||||
* - "g" for global
|
||||
* - "i" for ignoreCase
|
||||
* - "m" for multiline
|
||||
* - "u" for unicode
|
||||
* - "y" for sticky
|
||||
*
|
||||
* If no flags are set, the value is the empty string.
|
||||
*/
|
||||
readonly flags: string;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly sticky: boolean;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
* Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular
|
||||
* expression. Default is false. Read-only.
|
||||
*/
|
||||
readonly unicode: boolean;
|
||||
}
|
||||
|
||||
@@ -426,64 +436,64 @@ interface RegExpConstructor {
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
* value of the UTF-16 encoded code point starting at the string element at position pos in
|
||||
* the String resulting from converting this object to a String.
|
||||
* If there is no element at that position, the result is undefined.
|
||||
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
|
||||
*/
|
||||
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
|
||||
* value of the UTF-16 encoded code point starting at the string element at position pos in
|
||||
* the String resulting from converting this object to a String.
|
||||
* If there is no element at that position, the result is undefined.
|
||||
* If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
|
||||
*/
|
||||
codePointAt(pos: number): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns true if searchString appears as a substring of the result of converting this
|
||||
* object to a String, at one or more positions that are
|
||||
* greater than or equal to position; otherwise, returns false.
|
||||
* @param searchString search string
|
||||
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
||||
*/
|
||||
* Returns true if searchString appears as a substring of the result of converting this
|
||||
* object to a String, at one or more positions that are
|
||||
* greater than or equal to position; otherwise, returns false.
|
||||
* @param searchString search string
|
||||
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
||||
*/
|
||||
includes(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* endPosition – length(this). Otherwise returns false.
|
||||
*/
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* endPosition – length(this). Otherwise returns false.
|
||||
*/
|
||||
endsWith(searchString: string, endPosition?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
|
||||
|
||||
/**
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
* Returns the String value result of normalizing the string into the normalization form
|
||||
* named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms.
|
||||
* @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default
|
||||
* is "NFC"
|
||||
*/
|
||||
normalize(form?: string): string;
|
||||
|
||||
/**
|
||||
* Returns a String value that is made from count copies appended together. If count is 0,
|
||||
* T is the empty String is returned.
|
||||
* @param count number of copies to append
|
||||
*/
|
||||
* Returns a String value that is made from count copies appended together. If count is 0,
|
||||
* T is the empty String is returned.
|
||||
* @param count number of copies to append
|
||||
*/
|
||||
repeat(count: number): string;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* position. Otherwise returns false.
|
||||
*/
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* position. Otherwise returns false.
|
||||
*/
|
||||
startsWith(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns an <a> HTML anchor element and sets the name attribute to the text value
|
||||
* @param name
|
||||
*/
|
||||
* Returns an <a> HTML anchor element and sets the name attribute to the text value
|
||||
* @param name
|
||||
*/
|
||||
anchor(name: string): string;
|
||||
|
||||
/** Returns a <big> HTML element */
|
||||
@@ -496,10 +506,10 @@ interface String {
|
||||
bold(): string;
|
||||
|
||||
/** Returns a <tt> HTML element */
|
||||
fixed(): string
|
||||
fixed(): string;
|
||||
|
||||
/** Returns a <font> HTML element and sets the color attribute value */
|
||||
fontcolor(color: string): string
|
||||
fontcolor(color: string): string;
|
||||
|
||||
/** Returns a <font> HTML element and sets the size attribute value */
|
||||
fontsize(size: number): string;
|
||||
@@ -528,17 +538,17 @@ interface String {
|
||||
|
||||
interface StringConstructor {
|
||||
/**
|
||||
* Return the String value whose elements are, in order, the elements in the List elements.
|
||||
* If length is 0, the empty string is returned.
|
||||
*/
|
||||
* Return the String value whose elements are, in order, the elements in the List elements.
|
||||
* If length is 0, the empty string is returned.
|
||||
*/
|
||||
fromCodePoint(...codePoints: number[]): string;
|
||||
|
||||
/**
|
||||
* String.raw is intended for use as a tag function of a Tagged Template String. When called
|
||||
* as such the first argument will be a well formed template call site object and the rest
|
||||
* parameter will contain the substitution values.
|
||||
* @param template A well-formed template string call site representation.
|
||||
* @param substitutions A set of substitution values.
|
||||
*/
|
||||
* String.raw is intended for use as a tag function of a Tagged Template String. When called
|
||||
* as such the first argument will be a well formed template call site object and the rest
|
||||
* parameter will contain the substitution values.
|
||||
* @param template A well-formed template string call site representation.
|
||||
* @param substitutions A set of substitution values.
|
||||
*/
|
||||
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
|
||||
}
|
||||
|
||||
Vendored
+44
-4
@@ -18,15 +18,55 @@ and limitations under the License.
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface GeneratorFunction extends Function { }
|
||||
interface Generator extends Iterator<any> { }
|
||||
|
||||
interface GeneratorFunction {
|
||||
/**
|
||||
* Creates a new Generator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: any[]): Generator;
|
||||
/**
|
||||
* Creates a new Generator object.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: any[]): Generator;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Generator;
|
||||
}
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: string[]): GeneratorFunction;
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
(...args: string[]): GeneratorFunction;
|
||||
/**
|
||||
* The length of the arguments.
|
||||
*/
|
||||
readonly length: number;
|
||||
/**
|
||||
* Returns the name of the function.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: GeneratorFunction;
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
Vendored
+238
-200
@@ -21,10 +21,10 @@ and limitations under the License.
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
}
|
||||
|
||||
@@ -51,35 +51,37 @@ interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
* @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: (v: T, k: number) => U, thisArg?: any): Array<U>;
|
||||
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
* @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.
|
||||
*/
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
*/
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
}
|
||||
|
||||
@@ -87,19 +89,19 @@ interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ interface IArguments {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator](): IterableIterator<[K,V]>;
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
@@ -139,22 +141,22 @@ interface SetConstructor {
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
new <T extends object>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> { }
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
@@ -163,7 +165,7 @@ interface PromiseConstructor {
|
||||
}
|
||||
|
||||
declare namespace Reflect {
|
||||
function enumerate(target: any): IterableIterator<any>;
|
||||
function enumerate(target: object): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
@@ -172,22 +174,22 @@ interface 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -195,31 +197,35 @@ interface Int8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Int8Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -227,33 +233,37 @@ interface Uint8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -262,33 +272,37 @@ interface Uint8ClampedArrayConstructor {
|
||||
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -296,31 +310,35 @@ interface Int16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Int16Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -328,31 +346,35 @@ interface Uint16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -360,31 +382,35 @@ interface Int32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Int32Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -392,31 +418,35 @@ interface Uint32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -424,31 +454,35 @@ interface Float32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Float32Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
* 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>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
@@ -456,10 +490,14 @@ interface Float64ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float64Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @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;
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -20,8 +20,8 @@ and limitations under the License.
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Promise<any>;
|
||||
|
||||
/**
|
||||
@@ -207,10 +207,10 @@ interface PromiseConstructor {
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+4
-4
@@ -18,7 +18,7 @@ and limitations under the License.
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface ProxyHandler<T> {
|
||||
interface ProxyHandler<T extends object> {
|
||||
getPrototypeOf? (target: T): object | null;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
@@ -32,11 +32,11 @@ interface ProxyHandler<T> {
|
||||
enumerate? (target: T): PropertyKey[];
|
||||
ownKeys? (target: T): PropertyKey[];
|
||||
apply? (target: T, thisArg: any, argArray?: any): any;
|
||||
construct? (target: T, argArray: any, newTarget?: any): object
|
||||
construct? (target: T, argArray: any, newTarget?: any): object;
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
new <T>(target: T, handler: ProxyHandler<T>): T
|
||||
revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
new <T extends object>(target: T, handler: ProxyHandler<T>): T;
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;
|
||||
|
||||
Vendored
+12
-12
@@ -21,15 +21,15 @@ and limitations under the License.
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
function getPrototypeOf(target: any): any;
|
||||
function has(target: any, propertyKey: PropertyKey): boolean;
|
||||
function isExtensible(target: any): boolean;
|
||||
function ownKeys(target: any): Array<PropertyKey>;
|
||||
function preventExtensions(target: any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}
|
||||
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 getPrototypeOf(target: object): object;
|
||||
function has(target: object, propertyKey: PropertyKey): boolean;
|
||||
function isExtensible(target: object): boolean;
|
||||
function ownKeys(target: object): Array<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
+15
-15
@@ -27,29 +27,29 @@ interface Symbol {
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Symbol;
|
||||
|
||||
/**
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): symbol;
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string | number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: symbol): string | undefined;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+119
-119
@@ -21,64 +21,64 @@ and limitations under the License.
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
/**
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
readonly hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
readonly isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
*/
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
*/
|
||||
readonly match: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that replaces matched substrings of a string. Called by the
|
||||
* String.prototype.replace method.
|
||||
*/
|
||||
/**
|
||||
* A regular expression method that replaces matched substrings of a string. Called by the
|
||||
* String.prototype.replace method.
|
||||
*/
|
||||
readonly replace: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that returns the index within a string that matches the
|
||||
* regular expression. Called by the String.prototype.search method.
|
||||
*/
|
||||
* A regular expression method that returns the index within a string that matches the
|
||||
* regular expression. Called by the String.prototype.search method.
|
||||
*/
|
||||
readonly search: symbol;
|
||||
|
||||
/**
|
||||
* A function valued property that is the constructor function that is used to create
|
||||
* derived objects.
|
||||
*/
|
||||
/**
|
||||
* A function valued property that is the constructor function that is used to create
|
||||
* derived objects.
|
||||
*/
|
||||
readonly species: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that splits a string at the indices that match the regular
|
||||
* expression. Called by the String.prototype.split method.
|
||||
*/
|
||||
* A regular expression method that splits a string at the indices that match the regular
|
||||
* expression. Called by the String.prototype.split method.
|
||||
*/
|
||||
readonly split: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.
|
||||
* Called by the ToPrimitive abstract operation.
|
||||
*/
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.
|
||||
* Called by the ToPrimitive abstract operation.
|
||||
*/
|
||||
readonly toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
readonly toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the 'with'
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
* An Object whose own property names are property names that are excluded from the 'with'
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
readonly unscopables: symbol;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ interface Function {
|
||||
[Symbol.hasInstance](value: any): boolean;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
interface GeneratorFunction {
|
||||
readonly [Symbol.toStringTag]: "GeneratorFunction";
|
||||
}
|
||||
|
||||
@@ -174,50 +174,50 @@ interface PromiseConstructor {
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.match](string: string): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replaceValue A String object or string literal containing the text to replace for every
|
||||
* successful match of this regular expression.
|
||||
*/
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replaceValue A String object or string literal containing the text to replace for every
|
||||
* successful match of this regular expression.
|
||||
*/
|
||||
[Symbol.replace](string: string, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the position beginning first substring match in a regular expression search
|
||||
* using this regular expression.
|
||||
*
|
||||
* @param string The string to search within.
|
||||
*/
|
||||
* Finds the position beginning first substring match in a regular expression search
|
||||
* using this regular expression.
|
||||
*
|
||||
* @param string The string to search within.
|
||||
*/
|
||||
[Symbol.search](string: string): number;
|
||||
|
||||
/**
|
||||
* Returns an array of substrings that were delimited by strings in the original input that
|
||||
* match against this regular expression.
|
||||
*
|
||||
* If the regular expression contains capturing parentheses, then each time this
|
||||
* regular expression matches, the results (including any undefined results) of the
|
||||
* capturing parentheses are spliced.
|
||||
*
|
||||
* @param string string value to split
|
||||
* @param limit if not undefined, the output array is truncated so that it contains no more
|
||||
* than 'limit' elements.
|
||||
*/
|
||||
* Returns an array of substrings that were delimited by strings in the original input that
|
||||
* match against this regular expression.
|
||||
*
|
||||
* If the regular expression contains capturing parentheses, then each time this
|
||||
* regular expression matches, the results (including any undefined results) of the
|
||||
* capturing parentheses are spliced.
|
||||
*
|
||||
* @param string string value to split
|
||||
* @param limit if not undefined, the output array is truncated so that it contains no more
|
||||
* than 'limit' elements.
|
||||
*/
|
||||
[Symbol.split](string: string, limit?: number): string[];
|
||||
}
|
||||
|
||||
@@ -227,45 +227,45 @@ interface RegExpConstructor {
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
*/
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
*/
|
||||
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
||||
*/
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the first substring match in a regular expression search.
|
||||
* @param searcher An object which supports searching within a string.
|
||||
*/
|
||||
* Finds the first substring match in a regular expression search.
|
||||
* @param searcher An object which supports searching within a string.
|
||||
*/
|
||||
search(searcher: { [Symbol.search](string: string): number; }): number;
|
||||
|
||||
/**
|
||||
* Split a string into substrings using the specified separator and return them as an array.
|
||||
* @param splitter An object that can split a string.
|
||||
* @param limit A value used to limit the number of elements returned in the array.
|
||||
*/
|
||||
* Split a string into substrings using the specified separator and return them as an array.
|
||||
* @param splitter An object that can split a string.
|
||||
* @param limit A value used to limit the number of elements returned in the array.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
* 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";
|
||||
}
|
||||
@@ -275,73 +275,73 @@ interface 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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.
|
||||
*/
|
||||
* 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
+44
-44
@@ -20,99 +20,99 @@ and limitations under the License.
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float64Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
Vendored
+15468
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -21,4 +21,4 @@ and limitations under the License.
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
Vendored
+15470
File diff suppressed because it is too large
Load Diff
Vendored
+12
-12
@@ -20,26 +20,26 @@ and limitations under the License.
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties 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.
|
||||
*/
|
||||
* Returns an array of values of the enumerable properties 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.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties 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.
|
||||
*/
|
||||
* Returns an array of values of the enumerable properties 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.
|
||||
*/
|
||||
values(o: any): any[];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties 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.
|
||||
*/
|
||||
* Returns an array of key/values of the enumerable properties 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.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties 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.
|
||||
*/
|
||||
* Returns an array of key/values of the enumerable properties 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.
|
||||
*/
|
||||
entries(o: any): [string, any][];
|
||||
}
|
||||
|
||||
Vendored
+5
-5
@@ -23,8 +23,8 @@ and limitations under the License.
|
||||
|
||||
interface SharedArrayBuffer {
|
||||
/**
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/*
|
||||
@@ -32,9 +32,9 @@ interface SharedArrayBuffer {
|
||||
*/
|
||||
length: number;
|
||||
/**
|
||||
* Returns a section of an SharedArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): SharedArrayBuffer;
|
||||
* Returns a section of an SharedArrayBuffer.
|
||||
*/
|
||||
slice(begin: number, end?: number): SharedArrayBuffer;
|
||||
readonly [Symbol.species]: SharedArrayBuffer;
|
||||
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
|
||||
}
|
||||
|
||||
Vendored
+20
-20
@@ -20,28 +20,28 @@ and limitations under the License.
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padStart(maxLength: number, fillString?: string): string;
|
||||
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the end (right) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the end (right) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padEnd(maxLength: number, fillString?: string): string;
|
||||
}
|
||||
|
||||
Vendored
+304
-203
File diff suppressed because it is too large
Load Diff
Vendored
+1382
-979
File diff suppressed because it is too large
Load Diff
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.iterable.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default async iterator for an object. Called by the semantics of
|
||||
* the for-await-of statement.
|
||||
*/
|
||||
readonly asyncIterator: symbol;
|
||||
}
|
||||
|
||||
interface AsyncIterator<T> {
|
||||
next(value?: any): Promise<IteratorResult<T>>;
|
||||
return?(value?: any): Promise<IteratorResult<T>>;
|
||||
throw?(e?: any): Promise<IteratorResult<T>>;
|
||||
}
|
||||
|
||||
interface AsyncIterable<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2017.d.ts" />
|
||||
/// <reference path="lib.esnext.asynciterable.d.ts" />
|
||||
Vendored
+15469
File diff suppressed because it is too large
Load Diff
Vendored
+4
-4
@@ -49,7 +49,7 @@ interface TextStreamBase {
|
||||
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
@@ -119,9 +119,9 @@ interface TextStreamReader extends TextStreamBase {
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
||||
* a newline (under CScript.exe).
|
||||
*/
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
||||
* a newline (under CScript.exe).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+146
-34
@@ -74,13 +74,17 @@ interface MessageEventInit extends EventInit {
|
||||
}
|
||||
|
||||
interface NotificationOptions {
|
||||
dir?: string;
|
||||
dir?: NotificationDirection;
|
||||
lang?: string;
|
||||
body?: string;
|
||||
tag?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
interface ObjectURLOptions {
|
||||
oneTimeOnly?: boolean;
|
||||
}
|
||||
|
||||
interface PushSubscriptionOptionsInit {
|
||||
userVisibleOnly?: boolean;
|
||||
applicationServerKey?: any;
|
||||
@@ -91,11 +95,11 @@ interface RequestInit {
|
||||
headers?: any;
|
||||
body?: any;
|
||||
referrer?: string;
|
||||
referrerPolicy?: string;
|
||||
mode?: string;
|
||||
credentials?: string;
|
||||
cache?: string;
|
||||
redirect?: string;
|
||||
referrerPolicy?: ReferrerPolicy;
|
||||
mode?: RequestMode;
|
||||
credentials?: RequestCredentials;
|
||||
cache?: RequestCache;
|
||||
redirect?: RequestRedirect;
|
||||
integrity?: string;
|
||||
keepalive?: boolean;
|
||||
window?: any;
|
||||
@@ -109,7 +113,7 @@ interface ResponseInit {
|
||||
|
||||
interface ClientQueryOptions {
|
||||
includeUncontrolled?: boolean;
|
||||
type?: string;
|
||||
type?: ClientType;
|
||||
}
|
||||
|
||||
interface ExtendableEventInit extends EventInit {
|
||||
@@ -419,9 +423,9 @@ declare var Event: {
|
||||
}
|
||||
|
||||
interface EventTarget {
|
||||
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
dispatchEvent(evt: Event): boolean;
|
||||
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
}
|
||||
|
||||
declare var EventTarget: {
|
||||
@@ -481,7 +485,7 @@ declare var Headers: {
|
||||
}
|
||||
|
||||
interface IDBCursor {
|
||||
readonly direction: string;
|
||||
readonly direction: IDBCursorDirection;
|
||||
key: IDBKeyRange | IDBValidKey;
|
||||
readonly primaryKey: any;
|
||||
source: IDBObjectStore | IDBIndex;
|
||||
@@ -633,7 +637,7 @@ interface IDBRequest extends EventTarget {
|
||||
readonly error: DOMError;
|
||||
onerror: (this: IDBRequest, ev: Event) => any;
|
||||
onsuccess: (this: IDBRequest, ev: Event) => any;
|
||||
readonly readyState: string;
|
||||
readonly readyState: IDBRequestReadyState;
|
||||
readonly result: any;
|
||||
source: IDBObjectStore | IDBIndex | IDBCursor;
|
||||
readonly transaction: IDBTransaction;
|
||||
@@ -655,7 +659,7 @@ interface IDBTransactionEventMap {
|
||||
interface IDBTransaction extends EventTarget {
|
||||
readonly db: IDBDatabase;
|
||||
readonly error: DOMError;
|
||||
readonly mode: string;
|
||||
readonly mode: IDBTransactionMode;
|
||||
onabort: (this: IDBTransaction, ev: Event) => any;
|
||||
oncomplete: (this: IDBTransaction, ev: Event) => any;
|
||||
onerror: (this: IDBTransaction, ev: Event) => any;
|
||||
@@ -748,14 +752,14 @@ interface NotificationEventMap {
|
||||
|
||||
interface Notification extends EventTarget {
|
||||
readonly body: string;
|
||||
readonly dir: string;
|
||||
readonly dir: NotificationDirection;
|
||||
readonly icon: string;
|
||||
readonly lang: string;
|
||||
onclick: (this: Notification, ev: Event) => any;
|
||||
onclose: (this: Notification, ev: Event) => any;
|
||||
onerror: (this: Notification, ev: Event) => any;
|
||||
onshow: (this: Notification, ev: Event) => any;
|
||||
readonly permission: string;
|
||||
readonly permission: NotificationPermission;
|
||||
readonly tag: string;
|
||||
readonly title: string;
|
||||
close(): void;
|
||||
@@ -766,7 +770,7 @@ interface Notification extends EventTarget {
|
||||
declare var Notification: {
|
||||
prototype: Notification;
|
||||
new(title: string, options?: NotificationOptions): Notification;
|
||||
requestPermission(callback?: NotificationPermissionCallback): Promise<string>;
|
||||
requestPermission(callback?: NotificationPermissionCallback): Promise<NotificationPermission>;
|
||||
}
|
||||
|
||||
interface Performance {
|
||||
@@ -883,7 +887,7 @@ declare var ProgressEvent: {
|
||||
|
||||
interface PushManager {
|
||||
getSubscription(): Promise<PushSubscription>;
|
||||
permissionState(options?: PushSubscriptionOptionsInit): Promise<string>;
|
||||
permissionState(options?: PushSubscriptionOptionsInit): Promise<PushPermissionState>;
|
||||
subscribe(options?: PushSubscriptionOptionsInit): Promise<PushSubscription>;
|
||||
}
|
||||
|
||||
@@ -895,7 +899,7 @@ declare var PushManager: {
|
||||
interface PushSubscription {
|
||||
readonly endpoint: USVString;
|
||||
readonly options: PushSubscriptionOptions;
|
||||
getKey(name: string): ArrayBuffer | null;
|
||||
getKey(name: PushEncryptionKeyName): ArrayBuffer | null;
|
||||
toJSON(): any;
|
||||
unsubscribe(): Promise<boolean>;
|
||||
}
|
||||
@@ -938,18 +942,18 @@ declare var ReadableStreamReader: {
|
||||
}
|
||||
|
||||
interface Request extends Object, Body {
|
||||
readonly cache: string;
|
||||
readonly credentials: string;
|
||||
readonly destination: string;
|
||||
readonly cache: RequestCache;
|
||||
readonly credentials: RequestCredentials;
|
||||
readonly destination: RequestDestination;
|
||||
readonly headers: Headers;
|
||||
readonly integrity: string;
|
||||
readonly keepalive: boolean;
|
||||
readonly method: string;
|
||||
readonly mode: string;
|
||||
readonly redirect: string;
|
||||
readonly mode: RequestMode;
|
||||
readonly redirect: RequestRedirect;
|
||||
readonly referrer: string;
|
||||
readonly referrerPolicy: string;
|
||||
readonly type: string;
|
||||
readonly referrerPolicy: ReferrerPolicy;
|
||||
readonly type: RequestType;
|
||||
readonly url: string;
|
||||
clone(): Request;
|
||||
}
|
||||
@@ -965,7 +969,7 @@ interface Response extends Object, Body {
|
||||
readonly ok: boolean;
|
||||
readonly status: number;
|
||||
readonly statusText: string;
|
||||
readonly type: string;
|
||||
readonly type: ResponseType;
|
||||
readonly url: string;
|
||||
clone(): Response;
|
||||
}
|
||||
@@ -982,7 +986,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap {
|
||||
interface ServiceWorker extends EventTarget, AbstractWorker {
|
||||
onstatechange: (this: ServiceWorker, ev: Event) => any;
|
||||
readonly scriptURL: USVString;
|
||||
readonly state: string;
|
||||
readonly state: ServiceWorkerState;
|
||||
postMessage(message: any, transfer?: any[]): void;
|
||||
addEventListener<K extends keyof ServiceWorkerEventMap>(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -1028,6 +1032,29 @@ declare var SyncManager: {
|
||||
new(): SyncManager;
|
||||
}
|
||||
|
||||
interface URL {
|
||||
hash: string;
|
||||
host: string;
|
||||
hostname: string;
|
||||
href: string;
|
||||
readonly origin: string;
|
||||
password: string;
|
||||
pathname: string;
|
||||
port: string;
|
||||
protocol: string;
|
||||
search: string;
|
||||
username: string;
|
||||
readonly searchParams: URLSearchParams;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
declare var URL: {
|
||||
prototype: URL;
|
||||
new(url: string, base?: string): URL;
|
||||
createObjectURL(object: any, options?: ObjectURLOptions): string;
|
||||
revokeObjectURL(url: string): void;
|
||||
}
|
||||
|
||||
interface WebSocketEventMap {
|
||||
"close": CloseEvent;
|
||||
"error": Event;
|
||||
@@ -1091,7 +1118,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
responseType: string;
|
||||
responseType: XMLHttpRequestResponseType;
|
||||
readonly responseURL: string;
|
||||
readonly responseXML: any;
|
||||
readonly status: number;
|
||||
@@ -1242,7 +1269,7 @@ interface XMLHttpRequestEventTarget {
|
||||
}
|
||||
|
||||
interface Client {
|
||||
readonly frameType: string;
|
||||
readonly frameType: FrameType;
|
||||
readonly id: string;
|
||||
readonly url: USVString;
|
||||
postMessage(message: any, transfer?: any[]): void;
|
||||
@@ -1405,7 +1432,7 @@ declare var SyncEvent: {
|
||||
|
||||
interface WindowClient extends Client {
|
||||
readonly focused: boolean;
|
||||
readonly visibilityState: string;
|
||||
readonly visibilityState: VisibilityState;
|
||||
focus(): Promise<WindowClient>;
|
||||
navigate(url: USVString): Promise<WindowClient>;
|
||||
}
|
||||
@@ -1427,6 +1454,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo
|
||||
readonly performance: Performance;
|
||||
readonly self: WorkerGlobalScope;
|
||||
msWriteProfilerMark(profilerMarkName: string): void;
|
||||
createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -1487,6 +1516,56 @@ interface ErrorEventInit {
|
||||
error?: any;
|
||||
}
|
||||
|
||||
interface ImageBitmapOptions {
|
||||
imageOrientation?: "none" | "flipY";
|
||||
premultiplyAlpha?: "none" | "premultiply" | "default";
|
||||
colorSpaceConversion?: "none" | "default";
|
||||
resizeWidth?: number;
|
||||
resizeHeight?: number;
|
||||
resizeQuality?: "pixelated" | "low" | "medium" | "high";
|
||||
}
|
||||
|
||||
interface ImageBitmap {
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Appends a specified key/value pair as a new search parameter.
|
||||
*/
|
||||
append(name: string, value: string): void;
|
||||
/**
|
||||
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
|
||||
*/
|
||||
delete(name: string): void;
|
||||
/**
|
||||
* Returns the first value associated to the given search parameter.
|
||||
*/
|
||||
get(name: string): string | null;
|
||||
/**
|
||||
* Returns all the values association with a given search parameter.
|
||||
*/
|
||||
getAll(name: string): string[];
|
||||
/**
|
||||
* Returns a Boolean indicating if such a search parameter exists.
|
||||
*/
|
||||
has(name: string): boolean;
|
||||
/**
|
||||
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
|
||||
*/
|
||||
set(name: string, value: string): void;
|
||||
}
|
||||
|
||||
declare var URLSearchParams: {
|
||||
prototype: URLSearchParams;
|
||||
/**
|
||||
* Constructor returning a URLSearchParams object.
|
||||
*/
|
||||
new (init?: string | URLSearchParams): URLSearchParams;
|
||||
}
|
||||
|
||||
interface BlobPropertyBag {
|
||||
type?: string;
|
||||
endings?: string;
|
||||
@@ -1681,6 +1760,15 @@ interface JsonWebKey {
|
||||
k?: string;
|
||||
}
|
||||
|
||||
interface EventListenerOptions {
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
interface AddEventListenerOptions extends EventListenerOptions {
|
||||
passive?: boolean;
|
||||
once?: boolean;
|
||||
}
|
||||
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
@@ -1702,10 +1790,10 @@ interface FunctionStringCallback {
|
||||
(data: string): void;
|
||||
}
|
||||
interface ForEachCallback {
|
||||
(keyId: any, status: string): void;
|
||||
(keyId: any, status: MediaKeyStatus): void;
|
||||
}
|
||||
interface NotificationPermissionCallback {
|
||||
(permission: string): void;
|
||||
(permission: NotificationPermission): void;
|
||||
}
|
||||
declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any;
|
||||
declare function close(): void;
|
||||
@@ -1717,8 +1805,10 @@ declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any;
|
||||
declare var performance: Performance;
|
||||
declare var self: WorkerGlobalScope;
|
||||
declare function msWriteProfilerMark(profilerMarkName: string): void;
|
||||
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
|
||||
declare function dispatchEvent(evt: Event): boolean;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
declare var indexedDB: IDBFactory;
|
||||
declare var msIndexedDB: IDBFactory;
|
||||
declare var navigator: WorkerNavigator;
|
||||
@@ -1737,7 +1827,7 @@ declare function btoa(rawString: string): string;
|
||||
declare var console: Console;
|
||||
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
||||
declare function dispatchEvent(evt: Event): boolean;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
type AlgorithmIdentifier = string | Algorithm;
|
||||
@@ -1746,4 +1836,26 @@ type IDBKeyPath = string;
|
||||
type RequestInfo = Request | string;
|
||||
type USVString = string;
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type FormDataEntryValue = string | File;
|
||||
type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique";
|
||||
type IDBRequestReadyState = "pending" | "done";
|
||||
type IDBTransactionMode = "readonly" | "readwrite" | "versionchange";
|
||||
type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error";
|
||||
type NotificationDirection = "auto" | "ltr" | "rtl";
|
||||
type NotificationPermission = "default" | "denied" | "granted";
|
||||
type PushEncryptionKeyName = "p256dh" | "auth";
|
||||
type PushPermissionState = "granted" | "denied" | "prompt";
|
||||
type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url";
|
||||
type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache";
|
||||
type RequestCredentials = "omit" | "same-origin" | "include";
|
||||
type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker";
|
||||
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors";
|
||||
type RequestRedirect = "follow" | "error" | "manual";
|
||||
type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video";
|
||||
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
|
||||
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
|
||||
type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded";
|
||||
type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text";
|
||||
type ClientType = "window" | "worker" | "sharedworker" | "all";
|
||||
type FrameType = "auxiliary" | "top-level" | "nested" | "none";
|
||||
Vendored
+511
-464
File diff suppressed because it is too large
Load Diff
+10412
-7993
File diff suppressed because it is too large
Load Diff
+15828
-11687
File diff suppressed because it is too large
Load Diff
Vendored
+718
-469
File diff suppressed because it is too large
Load Diff
+15683
-11656
File diff suppressed because it is too large
Load Diff
Vendored
+870
-541
File diff suppressed because it is too large
Load Diff
+17302
-12925
File diff suppressed because it is too large
Load Diff
Vendored
+870
-541
File diff suppressed because it is too large
Load Diff
+17302
-12925
File diff suppressed because it is too large
Load Diff
+1066
-835
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
process.exit(1);
|
||||
}
|
||||
var directoryName = process.argv[2];
|
||||
var fs = require("fs");
|
||||
try {
|
||||
var watcher = fs.watch(directoryName, { recursive: true }, function () { return ({}); });
|
||||
watcher.close();
|
||||
}
|
||||
catch (_e) {
|
||||
}
|
||||
process.exit(0);
|
||||
+1
-2
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "2.3.0",
|
||||
"version": "2.4.0",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
@@ -39,7 +39,6 @@
|
||||
"@types/gulp-help": "latest",
|
||||
"@types/gulp-newer": "latest",
|
||||
"@types/gulp-sourcemaps": "latest",
|
||||
"@types/gulp-typescript": "latest",
|
||||
"@types/merge2": "latest",
|
||||
"@types/minimatch": "latest",
|
||||
"@types/minimist": "latest",
|
||||
|
||||
+11
-9
@@ -221,7 +221,7 @@ namespace ts {
|
||||
// other kinds of value declarations take precedence over modules
|
||||
symbol.valueDeclaration = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Should not be called on a declaration with a computed property name,
|
||||
@@ -389,9 +389,9 @@ namespace ts {
|
||||
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
|
||||
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
|
||||
if (symbol.declarations && symbol.declarations.length &&
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1414,6 +1414,7 @@ namespace ts {
|
||||
if (isObjectLiteralOrClassExpressionMethod(node)) {
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
@@ -1715,7 +1716,7 @@ namespace ts {
|
||||
declareModuleMember(node, symbolFlags, symbolExcludes);
|
||||
break;
|
||||
}
|
||||
// fall through.
|
||||
// falls through
|
||||
default:
|
||||
if (!blockScopeContainer.locals) {
|
||||
blockScopeContainer.locals = createMap<Symbol>();
|
||||
@@ -2009,6 +2010,7 @@ namespace ts {
|
||||
bindBlockScopedDeclaration(<Declaration>parentNode, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.ThisKeyword:
|
||||
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
|
||||
node.flowNode = currentFlow;
|
||||
@@ -2184,7 +2186,7 @@ namespace ts {
|
||||
if (!isFunctionLike(node.parent)) {
|
||||
return;
|
||||
}
|
||||
// Fall through
|
||||
// falls through
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return updateStrictModeStatementList((<Block | ModuleBlock>node).statements);
|
||||
}
|
||||
@@ -2209,7 +2211,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindSourceFileAsExternalModule() {
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`);
|
||||
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`);
|
||||
}
|
||||
|
||||
function bindExportAssignment(node: ExportAssignment | BinaryExpression) {
|
||||
@@ -2401,7 +2403,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function lookupSymbolForName(name: string) {
|
||||
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || container.locals.get(name);
|
||||
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name));
|
||||
}
|
||||
|
||||
function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) {
|
||||
@@ -2502,7 +2504,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindParameter(node: ParameterDeclaration) {
|
||||
if (inStrictMode) {
|
||||
if (inStrictMode && !isInAmbientContext(node)) {
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
||||
checkStrictModeEvalOrArguments(node, node.name);
|
||||
|
||||
+760
-467
File diff suppressed because it is too large
Load Diff
+260
-179
@@ -1328,221 +1328,82 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* Parse the contents of a config file from json or json source file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param sourceFile sourceFile corresponding to the Json
|
||||
* @param host Instance of ParseConfigHost used to enumerate files in folder.
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
* @param resolutionStack Only present for backwards-compatibility. Should be empty.
|
||||
*/
|
||||
function parseJsonConfigFileContentWorker(json: any, sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine {
|
||||
function parseJsonConfigFileContentWorker(
|
||||
json: any,
|
||||
sourceFile: JsonSourceFile,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
existingOptions: CompilerOptions = {},
|
||||
configFileName?: string,
|
||||
resolutionStack: Path[] = [],
|
||||
extraFileExtensions: JsFileExtensionInfo[] = [],
|
||||
): ParsedCommandLine {
|
||||
Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
|
||||
const errors: Diagnostic[] = [];
|
||||
basePath = normalizeSlashes(basePath);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
||||
return {
|
||||
options: {},
|
||||
fileNames: [],
|
||||
typeAcquisition: {},
|
||||
raw: json || convertToObject(sourceFile, errors),
|
||||
errors: errors.concat(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))),
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
}
|
||||
|
||||
let options: CompilerOptions;
|
||||
let typeAcquisition: TypeAcquisition;
|
||||
let compileOnSave: boolean;
|
||||
let hasExtendsError: boolean, extendedConfigPath: Path;
|
||||
if (json) {
|
||||
options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
||||
// It should be removed in future releases - use typeAcquisition instead.
|
||||
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
|
||||
typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
||||
}
|
||||
else {
|
||||
options = getDefaultCompilerOptions(configFileName);
|
||||
let typingOptionstypeAcquisition: TypeAcquisition;
|
||||
const optionsIterator: JsonConversionNotifier = {
|
||||
onSetOptionKeyValue(optionsObject: string, option: CommandLineOption, value: CompilerOptionsValue) {
|
||||
Debug.assert(optionsObject === "compilerOptions" || optionsObject === "typeAcquisition" || optionsObject === "typingOptions");
|
||||
const currentOption = optionsObject === "compilerOptions" ? options :
|
||||
optionsObject === "typeAcquisition" ? (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)) ) :
|
||||
(typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
|
||||
|
||||
currentOption[option.name] = normalizeOptionValue(option, basePath, value);
|
||||
},
|
||||
onRootKeyValue(key: string, propertyName: PropertyName, value: CompilerOptionsValue, node: Expression) {
|
||||
switch (key) {
|
||||
case "extends":
|
||||
const extendsDiagnostic = getExtendsConfigPath(<string>value, (message, arg0) =>
|
||||
createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0));
|
||||
if ((<Diagnostic>extendsDiagnostic).messageText) {
|
||||
errors.push(<Diagnostic>extendsDiagnostic);
|
||||
hasExtendsError = true;
|
||||
}
|
||||
else {
|
||||
extendedConfigPath = <Path>extendsDiagnostic;
|
||||
}
|
||||
return;
|
||||
case "excludes":
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, propertyName, Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
return;
|
||||
case "files":
|
||||
if ((<string[]>value).length === 0) {
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, node, Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
||||
}
|
||||
return;
|
||||
case "compileOnSave":
|
||||
compileOnSave = <boolean>value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
json = convertToObjectWorker(sourceFile, errors, getTsconfigRootOptionsMap(), optionsIterator);
|
||||
if (!typeAcquisition) {
|
||||
if (typingOptionstypeAcquisition) {
|
||||
typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
|
||||
{
|
||||
enable: typingOptionstypeAcquisition.enableAutoDiscovery,
|
||||
include: typingOptionstypeAcquisition.include,
|
||||
exclude: typingOptionstypeAcquisition.exclude
|
||||
} :
|
||||
typingOptionstypeAcquisition;
|
||||
}
|
||||
else {
|
||||
typeAcquisition = getDefaultTypeAcquisition(configFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json["extends"]) {
|
||||
let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}];
|
||||
if (!hasExtendsError && typeof json["extends"] === "string") {
|
||||
[include, exclude, files, baseOptions] = (tryExtendsName(json["extends"], extendedConfigPath) || [include, exclude, files, baseOptions]);
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticForJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string");
|
||||
}
|
||||
if (include && !json["include"]) {
|
||||
json["include"] = include;
|
||||
}
|
||||
if (exclude && !json["exclude"]) {
|
||||
json["exclude"] = exclude;
|
||||
}
|
||||
if (files && !json["files"]) {
|
||||
json["files"] = files;
|
||||
}
|
||||
options = assign({}, baseOptions, options);
|
||||
}
|
||||
|
||||
options = extend(existingOptions, options);
|
||||
const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors);
|
||||
const { raw } = parsedConfig;
|
||||
const options = extend(existingOptions, parsedConfig.options || {});
|
||||
options.configFilePath = configFileName;
|
||||
options.configFile = sourceFile;
|
||||
|
||||
const { fileNames, wildcardDirectories } = getFileNames(errors);
|
||||
|
||||
const { fileNames, wildcardDirectories } = getFileNames();
|
||||
return {
|
||||
options,
|
||||
fileNames,
|
||||
typeAcquisition,
|
||||
raw: json,
|
||||
typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
|
||||
raw,
|
||||
errors,
|
||||
wildcardDirectories,
|
||||
compileOnSave
|
||||
compileOnSave: !!raw.compileOnSave
|
||||
};
|
||||
|
||||
function getExtendsConfigPath<T>(extendedConfig: string, createDiagnostic: (message: DiagnosticMessage, arg1?: string) => T): T | Path {
|
||||
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
|
||||
if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) {
|
||||
return createDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig);
|
||||
}
|
||||
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);
|
||||
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) {
|
||||
extendedConfigPath = `${extendedConfigPath}.json` as Path;
|
||||
if (!host.fileExists(extendedConfigPath)) {
|
||||
return createDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig);
|
||||
}
|
||||
}
|
||||
return extendedConfigPath;
|
||||
}
|
||||
|
||||
function tryExtendsName(extendedConfig: string, extendedConfigPath?: Path): [string[], string[], string[], CompilerOptions] {
|
||||
if (!extendedConfigPath) {
|
||||
const result = getExtendsConfigPath(extendedConfig, (message, arg1) => (createCompilerDiagnosticForJson(message, arg1), true));
|
||||
if (result === true) {
|
||||
return;
|
||||
}
|
||||
extendedConfigPath = <Path>result;
|
||||
}
|
||||
|
||||
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) {
|
||||
extendedConfigPath = `${extendedConfigPath}.json` as Path;
|
||||
}
|
||||
|
||||
const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
|
||||
if (extendedResult.parseDiagnostics.length) {
|
||||
errors.push(...extendedResult.parseDiagnostics);
|
||||
return;
|
||||
}
|
||||
const extendedDirname = getDirectoryPath(extendedConfigPath);
|
||||
const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName);
|
||||
const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
|
||||
// Merge configs (copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios)
|
||||
const result = parseJsonSourceFileConfigFileContent(extendedResult, host, extendedDirname, /*existingOptions*/ undefined, getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath]));
|
||||
errors.push(...result.errors);
|
||||
const [include, exclude, files] = map(["include", "exclude", "files"], key => {
|
||||
if (!json[key] && result.raw[key]) {
|
||||
return map(result.raw[key], updatePath);
|
||||
}
|
||||
});
|
||||
return [include, exclude, files, result.options];
|
||||
}
|
||||
|
||||
function getFileNames(errors: Diagnostic[]): ExpandResult {
|
||||
function getFileNames(): ExpandResult {
|
||||
let fileNames: string[];
|
||||
if (hasProperty(json, "files")) {
|
||||
if (isArray(json["files"])) {
|
||||
fileNames = <string[]>json["files"];
|
||||
if (hasProperty(raw, "files")) {
|
||||
if (isArray(raw["files"])) {
|
||||
fileNames = <string[]>raw["files"];
|
||||
if (fileNames.length === 0) {
|
||||
createCompilerDiagnosticForJson(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
|
||||
}
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticForJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
|
||||
}
|
||||
}
|
||||
|
||||
let includeSpecs: string[];
|
||||
if (hasProperty(json, "include")) {
|
||||
if (isArray(json["include"])) {
|
||||
includeSpecs = <string[]>json["include"];
|
||||
if (hasProperty(raw, "include")) {
|
||||
if (isArray(raw["include"])) {
|
||||
includeSpecs = <string[]>raw["include"];
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticForJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
|
||||
}
|
||||
}
|
||||
|
||||
let excludeSpecs: string[];
|
||||
if (hasProperty(json, "exclude")) {
|
||||
if (isArray(json["exclude"])) {
|
||||
excludeSpecs = <string[]>json["exclude"];
|
||||
if (hasProperty(raw, "exclude")) {
|
||||
if (isArray(raw["exclude"])) {
|
||||
excludeSpecs = <string[]>raw["exclude"];
|
||||
}
|
||||
else {
|
||||
createCompilerDiagnosticForJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
|
||||
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
|
||||
}
|
||||
}
|
||||
else if (hasProperty(json, "excludes")) {
|
||||
createCompilerDiagnosticForJson(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude);
|
||||
}
|
||||
else {
|
||||
// If no includes were specified, exclude common package folders and the outDir
|
||||
excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
|
||||
const outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"];
|
||||
if (outDir) {
|
||||
excludeSpecs.push(outDir);
|
||||
}
|
||||
@@ -1554,7 +1415,7 @@ namespace ts {
|
||||
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile);
|
||||
|
||||
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
|
||||
if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) {
|
||||
errors.push(
|
||||
createCompilerDiagnostic(
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
@@ -1566,16 +1427,236 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function createCompilerDiagnosticForJson(message: DiagnosticMessage, arg0?: string, arg1?: string) {
|
||||
function createCompilerDiagnosticOnlyIfJson(message: DiagnosticMessage, arg0?: string, arg1?: string) {
|
||||
if (!sourceFile) {
|
||||
errors.push(createCompilerDiagnostic(message, arg0, arg1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean {
|
||||
interface ParsedTsconfig {
|
||||
raw: any;
|
||||
options?: CompilerOptions;
|
||||
typeAcquisition?: TypeAcquisition;
|
||||
extendedConfigPath?: Path;
|
||||
}
|
||||
|
||||
function isSuccessfulParsedTsconfig(value: ParsedTsconfig) {
|
||||
return !!value.options;
|
||||
}
|
||||
|
||||
/**
|
||||
* This *just* extracts options/include/exclude/files out of a config file.
|
||||
* It does *not* resolve the included files.
|
||||
*/
|
||||
function parseConfig(
|
||||
json: any,
|
||||
sourceFile: JsonSourceFile,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
configFileName: string,
|
||||
resolutionStack: Path[],
|
||||
errors: Diagnostic[],
|
||||
): ParsedTsconfig {
|
||||
basePath = normalizeSlashes(basePath);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
|
||||
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> ")));
|
||||
return { raw: json || convertToObject(sourceFile, errors) };
|
||||
}
|
||||
|
||||
const ownConfig = json ?
|
||||
parseOwnConfigOfJson(json, host, basePath, getCanonicalFileName, configFileName, errors) :
|
||||
parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, getCanonicalFileName, configFileName, errors);
|
||||
|
||||
if (ownConfig.extendedConfigPath) {
|
||||
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
|
||||
resolutionStack = resolutionStack.concat([resolvedPath]);
|
||||
const extendedConfig = getExtendedConfig(ownConfig.extendedConfigPath, host, basePath, getCanonicalFileName,
|
||||
resolutionStack, errors);
|
||||
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
|
||||
const baseRaw = extendedConfig.raw;
|
||||
const raw = ownConfig.raw;
|
||||
const setPropertyInRawIfNotUndefined = (propertyName: string) => {
|
||||
const value = raw[propertyName] || baseRaw[propertyName];
|
||||
if (value) {
|
||||
raw[propertyName] = value;
|
||||
}
|
||||
};
|
||||
setPropertyInRawIfNotUndefined("include");
|
||||
setPropertyInRawIfNotUndefined("exclude");
|
||||
setPropertyInRawIfNotUndefined("files");
|
||||
if (raw.compileOnSave === undefined) {
|
||||
raw.compileOnSave = baseRaw.compileOnSave;
|
||||
}
|
||||
ownConfig.options = assign({}, extendedConfig.options, ownConfig.options);
|
||||
// TODO extend type typeAcquisition
|
||||
}
|
||||
}
|
||||
|
||||
return ownConfig;
|
||||
}
|
||||
|
||||
function parseOwnConfigOfJson(
|
||||
json: any,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
getCanonicalFileName: (fileName: string) => string,
|
||||
configFileName: string,
|
||||
errors: Diagnostic[]
|
||||
): ParsedTsconfig {
|
||||
if (hasProperty(json, "excludes")) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
|
||||
const options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
||||
// It should be removed in future releases - use typeAcquisition instead.
|
||||
const typeAcquisition = convertTypeAcquisitionFromJsonWorker(json["typeAcquisition"] || json["typingOptions"], basePath, errors, configFileName);
|
||||
json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
|
||||
let extendedConfigPath: Path;
|
||||
|
||||
if (json.extends) {
|
||||
if (typeof json.extends !== "string") {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
|
||||
}
|
||||
else {
|
||||
extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, createCompilerDiagnostic);
|
||||
}
|
||||
}
|
||||
return { raw: json, options, typeAcquisition, extendedConfigPath };
|
||||
}
|
||||
|
||||
function parseOwnConfigOfJsonSourceFile(
|
||||
sourceFile: JsonSourceFile,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
getCanonicalFileName: (fileName: string) => string,
|
||||
configFileName: string,
|
||||
errors: Diagnostic[]
|
||||
): ParsedTsconfig {
|
||||
const options = getDefaultCompilerOptions(configFileName);
|
||||
let typeAcquisition: TypeAcquisition, typingOptionstypeAcquisition: TypeAcquisition;
|
||||
let extendedConfigPath: Path;
|
||||
|
||||
const optionsIterator: JsonConversionNotifier = {
|
||||
onSetOptionKeyValue(optionsObject: string, option: CommandLineOption, value: CompilerOptionsValue) {
|
||||
Debug.assert(optionsObject === "compilerOptions" || optionsObject === "typeAcquisition" || optionsObject === "typingOptions");
|
||||
const currentOption = optionsObject === "compilerOptions" ? options :
|
||||
optionsObject === "typeAcquisition" ? (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName))) :
|
||||
(typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
|
||||
|
||||
currentOption[option.name] = normalizeOptionValue(option, basePath, value);
|
||||
},
|
||||
onRootKeyValue(key: string, propertyName: PropertyName, value: CompilerOptionsValue, node: Expression) {
|
||||
switch (key) {
|
||||
case "extends":
|
||||
extendedConfigPath = getExtendsConfigPath(
|
||||
<string>value,
|
||||
host,
|
||||
basePath,
|
||||
getCanonicalFileName,
|
||||
errors,
|
||||
(message, arg0) =>
|
||||
createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0)
|
||||
);
|
||||
return;
|
||||
case "excludes":
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, propertyName, Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
return;
|
||||
case "files":
|
||||
if ((<string[]>value).length === 0) {
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, node, Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
const json = convertToObjectWorker(sourceFile, errors, getTsconfigRootOptionsMap(), optionsIterator);
|
||||
if (!typeAcquisition) {
|
||||
if (typingOptionstypeAcquisition) {
|
||||
typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
|
||||
{
|
||||
enable: typingOptionstypeAcquisition.enableAutoDiscovery,
|
||||
include: typingOptionstypeAcquisition.include,
|
||||
exclude: typingOptionstypeAcquisition.exclude
|
||||
} :
|
||||
typingOptionstypeAcquisition;
|
||||
}
|
||||
else {
|
||||
typeAcquisition = getDefaultTypeAcquisition(configFileName);
|
||||
}
|
||||
}
|
||||
|
||||
return { raw: json, options, typeAcquisition, extendedConfigPath };
|
||||
}
|
||||
|
||||
function getExtendsConfigPath(
|
||||
extendedConfig: string,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
getCanonicalFileName: (fileName: string) => string,
|
||||
errors: Diagnostic[],
|
||||
createDiagnostic: (message: DiagnosticMessage, arg1?: string) => Diagnostic) {
|
||||
extendedConfig = normalizeSlashes(extendedConfig);
|
||||
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
|
||||
if (!(isRootedDiskPath(extendedConfig) || startsWith(extendedConfig, "./") || startsWith(extendedConfig, "../"))) {
|
||||
errors.push(createDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
|
||||
return undefined;
|
||||
}
|
||||
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);
|
||||
if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) {
|
||||
extendedConfigPath = `${extendedConfigPath}.json` as Path;
|
||||
if (!host.fileExists(extendedConfigPath)) {
|
||||
errors.push(createDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return extendedConfigPath;
|
||||
}
|
||||
|
||||
function getExtendedConfig(
|
||||
extendedConfigPath: Path,
|
||||
host: ts.ParseConfigHost,
|
||||
basePath: string,
|
||||
getCanonicalFileName: (fileName: string) => string,
|
||||
resolutionStack: Path[],
|
||||
errors: Diagnostic[],
|
||||
): ParsedTsconfig | undefined {
|
||||
const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
|
||||
if (extendedResult.parseDiagnostics.length) {
|
||||
errors.push(...extendedResult.parseDiagnostics);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const extendedDirname = getDirectoryPath(extendedConfigPath);
|
||||
const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname,
|
||||
getBaseFileName(extendedConfigPath), resolutionStack, errors);
|
||||
|
||||
if (isSuccessfulParsedTsconfig(extendedConfig)) {
|
||||
// Update the paths to reflect base path
|
||||
const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName);
|
||||
const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
|
||||
const mapPropertiesInRawIfNotUndefined = (propertyName: string) => {
|
||||
if (raw[propertyName]) {
|
||||
raw[propertyName] = map(raw[propertyName], updatePath);
|
||||
}
|
||||
};
|
||||
|
||||
const { raw } = extendedConfig;
|
||||
mapPropertiesInRawIfNotUndefined("include");
|
||||
mapPropertiesInRawIfNotUndefined("exclude");
|
||||
mapPropertiesInRawIfNotUndefined("files");
|
||||
}
|
||||
|
||||
return extendedConfig;
|
||||
}
|
||||
|
||||
function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean {
|
||||
if (!hasProperty(jsonOption, compileOnSaveCommandLineOption.name)) {
|
||||
return false;
|
||||
return undefined;
|
||||
}
|
||||
const result = convertJsonOption(compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors);
|
||||
if (typeof result === "boolean" && result) {
|
||||
@@ -2025,4 +2106,4 @@ namespace ts {
|
||||
function caseInsensitiveKeyMapper(key: string) {
|
||||
return key.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = "2.3.0";
|
||||
export const version = "2.4.0";
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -224,6 +224,25 @@ namespace ts {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Iterates through the parent chain of a node and performs the callback on each parent until the callback
|
||||
* returns a truthy value, then returns that value.
|
||||
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
|
||||
* At that point findAncestor returns undefined.
|
||||
*/
|
||||
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node {
|
||||
while (node) {
|
||||
const result = callback(node);
|
||||
if (result === "quit") {
|
||||
return undefined;
|
||||
}
|
||||
else if (result) {
|
||||
return node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function zipWith<T, U>(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void {
|
||||
Debug.assert(arrayA.length === arrayB.length);
|
||||
@@ -232,6 +251,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function zipToMap<T>(keys: string[], values: T[]): Map<T> {
|
||||
Debug.assert(keys.length === values.length);
|
||||
const map = createMap<T>();
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
map.set(keys[i], values[i]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
||||
* returns a falsey value, then returns false.
|
||||
|
||||
@@ -594,12 +594,11 @@ namespace ts {
|
||||
emitLines(node.statements);
|
||||
}
|
||||
|
||||
// Return a temp variable name to be used in `export default` statements.
|
||||
// Return a temp variable name to be used in `export default`/`export class ... extends` statements.
|
||||
// The temp name will be of the form _default_counter.
|
||||
// Note that export default is only allowed at most once in a module, so we
|
||||
// do not need to keep track of created temp names.
|
||||
function getExportDefaultTempVariableName(): string {
|
||||
const baseName = "_default";
|
||||
function getExportTempVariableName(baseName: string): string {
|
||||
if (!currentIdentifiers.has(baseName)) {
|
||||
return baseName;
|
||||
}
|
||||
@@ -613,24 +612,31 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitTempVariableDeclaration(expr: Expression, baseName: string, diagnostic: SymbolAccessibilityDiagnostic): string {
|
||||
const tempVarName = getExportTempVariableName(baseName);
|
||||
if (!noDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
write("const ");
|
||||
write(tempVarName);
|
||||
write(": ");
|
||||
writer.getSymbolAccessibilityDiagnostic = () => diagnostic;
|
||||
resolver.writeTypeOfExpression(expr, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
write(";");
|
||||
writeLine();
|
||||
return tempVarName;
|
||||
}
|
||||
|
||||
function emitExportAssignment(node: ExportAssignment) {
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
writeTextOfNode(currentText, node.expression);
|
||||
}
|
||||
else {
|
||||
// Expression
|
||||
const tempVarName = getExportDefaultTempVariableName();
|
||||
if (!noDeclare) {
|
||||
write("declare ");
|
||||
}
|
||||
write("var ");
|
||||
write(tempVarName);
|
||||
write(": ");
|
||||
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
|
||||
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
write(";");
|
||||
writeLine();
|
||||
const tempVarName = emitTempVariableDeclaration(node.expression, "_default", {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
});
|
||||
write(node.isExportEquals ? "export = " : "export default ");
|
||||
write(tempVarName);
|
||||
}
|
||||
@@ -644,13 +650,6 @@ namespace ts {
|
||||
// write each of these declarations asynchronously
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
}
|
||||
|
||||
function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function isModuleElementVisible(node: Declaration) {
|
||||
@@ -1097,7 +1096,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitHeritageClause(className: Identifier, typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) {
|
||||
function emitHeritageClause(typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) {
|
||||
if (typeReferences) {
|
||||
write(isImplementsList ? " implements " : " extends ");
|
||||
emitCommaList(typeReferences, emitTypeOfTypeReference);
|
||||
@@ -1110,12 +1109,6 @@ namespace ts {
|
||||
else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) {
|
||||
write("null");
|
||||
}
|
||||
else {
|
||||
writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError;
|
||||
errorNameNode = className;
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
errorNameNode = undefined;
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
@@ -1151,23 +1144,43 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
let tempVarName: string;
|
||||
if (baseTypeNode && !isEntityNameExpression(baseTypeNode.expression)) {
|
||||
tempVarName = baseTypeNode.expression.kind === SyntaxKind.NullKeyword ?
|
||||
"null" :
|
||||
emitTempVariableDeclaration(baseTypeNode.expression, `${node.name.text}_base`, {
|
||||
diagnosticMessage: Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
|
||||
errorNode: baseTypeNode,
|
||||
typeName: node.name
|
||||
});
|
||||
}
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (hasModifier(node, ModifierFlags.Abstract)) {
|
||||
write("abstract ");
|
||||
}
|
||||
|
||||
write("class ");
|
||||
writeTextOfNode(currentText, node.name);
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
node.name;
|
||||
emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false);
|
||||
if (!isEntityNameExpression(baseTypeNode.expression)) {
|
||||
write(" extends ");
|
||||
write(tempVarName);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
write("<");
|
||||
emitCommaList(baseTypeNode.typeArguments, emitType);
|
||||
write(">");
|
||||
}
|
||||
}
|
||||
else {
|
||||
emitHeritageClause([baseTypeNode], /*isImplementsList*/ false);
|
||||
}
|
||||
}
|
||||
emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
|
||||
emitHeritageClause(getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
@@ -1189,7 +1202,7 @@ namespace ts {
|
||||
emitTypeParameters(node.typeParameters);
|
||||
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
|
||||
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
|
||||
emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
}
|
||||
write(" {");
|
||||
writeLine();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"Unterminated string literal.": {
|
||||
"category": "Error",
|
||||
"code": 1002
|
||||
@@ -175,7 +175,7 @@
|
||||
"category": "Error",
|
||||
"code": 1057
|
||||
},
|
||||
"Type used as operand to 'await' or the return type of an async function must either be a valid promise or must not contain a callable 'then' member.": {
|
||||
"The return type of an async function must either be a valid promise or must not contain a callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1058
|
||||
},
|
||||
@@ -867,14 +867,26 @@
|
||||
"category": "Error",
|
||||
"code": 1319
|
||||
},
|
||||
"String literal with double quotes expected.": {
|
||||
"Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1320
|
||||
},
|
||||
"Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.": {
|
||||
"Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1321
|
||||
},
|
||||
"Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.": {
|
||||
"category": "Error",
|
||||
"code": 1322
|
||||
},
|
||||
"String literal with double quotes expected.": {
|
||||
"category": "Error",
|
||||
"code": 1323
|
||||
},
|
||||
"Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.": {
|
||||
"category": "Error",
|
||||
"code": 1324
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -1839,6 +1851,14 @@
|
||||
"category": "Error",
|
||||
"code": 2550
|
||||
},
|
||||
"Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?": {
|
||||
"category": "Error",
|
||||
"code": 2551
|
||||
},
|
||||
"Cannot find name '{0}'. Did you mean '{1}'?": {
|
||||
"category": "Error",
|
||||
"code": 2552
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -2115,6 +2135,10 @@
|
||||
"category": "Error",
|
||||
"code": 2709
|
||||
},
|
||||
"'{0}' are specified twice. The attribute named '{0}' will be overwritten.": {
|
||||
"category": "Error",
|
||||
"code": 2710
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -3193,7 +3217,18 @@
|
||||
"category": "Message",
|
||||
"code": 6181
|
||||
},
|
||||
|
||||
"Scoped package detected, looking in '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6182
|
||||
},
|
||||
"Reusing resolution of module '{0}' to file '{1}' from old program.": {
|
||||
"category": "Message",
|
||||
"code": 6183
|
||||
},
|
||||
"Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program.": {
|
||||
"category": "Message",
|
||||
"code": 6184
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
@@ -3298,6 +3333,10 @@
|
||||
"category": "Error",
|
||||
"code": 7034
|
||||
},
|
||||
"Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`": {
|
||||
"category": "Error",
|
||||
"code": 7035
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
@@ -3516,7 +3555,10 @@
|
||||
"category": "Message",
|
||||
"code": 90021
|
||||
},
|
||||
|
||||
"Change spelling to '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 90022
|
||||
},
|
||||
|
||||
"Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -2457,7 +2457,7 @@ namespace ts {
|
||||
let indentation: number;
|
||||
for (const line of lines) {
|
||||
for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) {
|
||||
if (!isWhiteSpace(line.charCodeAt(i))) {
|
||||
if (!isWhiteSpaceLike(line.charCodeAt(i))) {
|
||||
if (indentation === undefined || i < indentation) {
|
||||
indentation = i;
|
||||
break;
|
||||
|
||||
+470
-363
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
/// <reference path="diagnosticInformationMap.generated.ts" />
|
||||
|
||||
namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
|
||||
export function trace(host: ModuleResolutionHost): void {
|
||||
@@ -15,6 +14,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Array that is only intended to be pushed to, never read. */
|
||||
/* @internal */
|
||||
export interface Push<T> {
|
||||
push(value: T): void;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ namespace ts {
|
||||
directoryPathMap.set(parent, result);
|
||||
current = parent;
|
||||
|
||||
if (current == commonPrefix) {
|
||||
if (current === commonPrefix) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -675,12 +675,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations {
|
||||
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false);
|
||||
return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose resolution logic to allow us to use Node module resolution logic from arbitrary locations.
|
||||
* No way to do this with `require()`: https://github.com/nodejs/node/issues/5963
|
||||
* Throws an error if the module can't be resolved.
|
||||
*/
|
||||
/* @internal */
|
||||
export function nodeModuleNameResolverWorker(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, jsOnly = false): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
export function resolveJavaScriptModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string {
|
||||
const { resolvedModule, failedLookupLocations } =
|
||||
nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true);
|
||||
if (!resolvedModule) {
|
||||
throw new Error(`Could not resolve JS module ${moduleName} starting at ${initialDir}. Looked in: ${failedLookupLocations.join(", ")}`);
|
||||
}
|
||||
return resolvedModule.resolvedFileName;
|
||||
}
|
||||
|
||||
function nodeModuleNameResolverWorker(moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, jsOnly: boolean): ResolvedModuleWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
@@ -954,10 +967,25 @@ namespace ts {
|
||||
}
|
||||
nodeModulesAtTypesExists = false;
|
||||
}
|
||||
return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes, nodeModulesAtTypesExists, failedLookupLocations, state);
|
||||
return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes, nodeModulesAtTypesExists, failedLookupLocations, state);
|
||||
}
|
||||
}
|
||||
|
||||
/** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */
|
||||
function mangleScopedPackage(moduleName: string, state: ModuleResolutionState): string {
|
||||
if (startsWith(moduleName, "@")) {
|
||||
const replaceSlash = moduleName.replace(ts.directorySeparator, "__");
|
||||
if (replaceSlash !== moduleName) {
|
||||
const mangled = replaceSlash.slice(1); // Take off the "@"
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Scoped_package_detected_looking_in_0, mangled);
|
||||
}
|
||||
return mangled;
|
||||
}
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
function tryFindNonRelativeModuleNameInCache(cache: PerModuleNameCache | undefined, moduleName: string, containingDirectory: string, traceEnabled: boolean, host: ModuleResolutionHost): SearchResult<Resolved> {
|
||||
const result = cache && cache.get(containingDirectory);
|
||||
if (result) {
|
||||
|
||||
+15
-5
@@ -56,7 +56,7 @@ namespace ts {
|
||||
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray
|
||||
// callback parameters, but that causes a closure allocation for each invocation with noticeable effects
|
||||
// on performance.
|
||||
const visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
|
||||
const visitNodes: (cb: ((node: Node) => T) | ((node: Node[]) => T), nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
|
||||
const cbNodes = cbNodeArray || cbNode;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -3606,6 +3606,7 @@ namespace ts {
|
||||
if (isAwaitExpression()) {
|
||||
return parseAwaitExpression();
|
||||
}
|
||||
// falls through
|
||||
default:
|
||||
return parseIncrementExpression();
|
||||
}
|
||||
@@ -3639,8 +3640,8 @@ namespace ts {
|
||||
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
|
||||
return false;
|
||||
}
|
||||
// We are in JSX context and the token is part of JSXElement.
|
||||
// Fall through
|
||||
// We are in JSX context and the token is part of JSXElement.
|
||||
// falls through
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@@ -3860,6 +3861,7 @@ namespace ts {
|
||||
|
||||
function parseJsxText(): JsxText {
|
||||
const node = <JsxText>createNode(SyntaxKind.JsxText, scanner.getStartPos());
|
||||
node.containsOnlyWhiteSpaces = currentToken === SyntaxKind.JsxTextAllWhiteSpaces;
|
||||
currentToken = scanner.scanJsxToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -3867,6 +3869,7 @@ namespace ts {
|
||||
function parseJsxChild(): JsxChild {
|
||||
switch (token()) {
|
||||
case SyntaxKind.JsxText:
|
||||
case SyntaxKind.JsxTextAllWhiteSpaces:
|
||||
return parseJsxText();
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseJsxExpression(/*inExpressionContext*/ false);
|
||||
@@ -3896,7 +3899,10 @@ namespace ts {
|
||||
else if (token() === SyntaxKind.ConflictMarkerTrivia) {
|
||||
break;
|
||||
}
|
||||
result.push(parseJsxChild());
|
||||
const child = parseJsxChild();
|
||||
if (child) {
|
||||
result.push(child);
|
||||
}
|
||||
}
|
||||
|
||||
result.end = scanner.getTokenPos();
|
||||
@@ -6529,6 +6535,8 @@ namespace ts {
|
||||
case "augments":
|
||||
tag = parseAugmentsTag(atToken, tagName);
|
||||
break;
|
||||
case "arg":
|
||||
case "argument":
|
||||
case "param":
|
||||
tag = parseParamTag(atToken, tagName);
|
||||
break;
|
||||
@@ -6604,7 +6612,8 @@ namespace ts {
|
||||
indent += scanner.getTokenText().length;
|
||||
break;
|
||||
}
|
||||
// FALLTHROUGH otherwise to record the * as a comment
|
||||
// record the * as a comment
|
||||
// falls through
|
||||
default:
|
||||
state = JSDocState.SavingComments; // leading identifiers start recording as well
|
||||
pushComment(scanner.getTokenText());
|
||||
@@ -6830,6 +6839,7 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.Identifier:
|
||||
canParseTag = false;
|
||||
break;
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
break;
|
||||
}
|
||||
|
||||
+149
-101
@@ -298,6 +298,7 @@ namespace ts {
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
let modifiedFilePaths: Path[] | undefined;
|
||||
|
||||
const cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
|
||||
const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
|
||||
@@ -368,7 +369,8 @@ namespace ts {
|
||||
// used to track cases when two file names differ only in casing
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
const structuralIsReused = tryReuseStructureFromOldProgram();
|
||||
if (structuralIsReused !== StructureIsReused.Completely) {
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
|
||||
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
|
||||
@@ -477,89 +479,114 @@ namespace ts {
|
||||
}
|
||||
|
||||
interface OldProgramState {
|
||||
program: Program;
|
||||
program: Program | undefined;
|
||||
file: SourceFile;
|
||||
/** The collection of paths modified *since* the old program. */
|
||||
modifiedFilePaths: Path[];
|
||||
}
|
||||
|
||||
function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState?: OldProgramState) {
|
||||
if (!oldProgramState && !file.ambientModuleNames.length) {
|
||||
// if old program state is not supplied and file does not contain locally defined ambient modules
|
||||
// then the best we can do is fallback to the default logic
|
||||
function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState: OldProgramState) {
|
||||
if (structuralIsReused === StructureIsReused.Not && !file.ambientModuleNames.length) {
|
||||
// If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
|
||||
// the best we can do is fallback to the default logic.
|
||||
return resolveModuleNamesWorker(moduleNames, containingFile);
|
||||
}
|
||||
|
||||
// at this point we know that either
|
||||
const oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile);
|
||||
if (oldSourceFile !== file && file.resolvedModules) {
|
||||
// `file` was created for the new program.
|
||||
//
|
||||
// We only set `file.resolvedModules` via work from the current function,
|
||||
// so it is defined iff we already called the current function on `file`.
|
||||
// That call happened no later than the creation of the `file` object,
|
||||
// which per above occured during the current program creation.
|
||||
// Since we assume the filesystem does not change during program creation,
|
||||
// it is safe to reuse resolutions from the earlier call.
|
||||
const result: ResolvedModuleFull[] = [];
|
||||
for (const moduleName of moduleNames) {
|
||||
const resolvedModule = file.resolvedModules.get(moduleName);
|
||||
result.push(resolvedModule);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// At this point, we know at least one of the following hold:
|
||||
// - file has local declarations for ambient modules
|
||||
// OR
|
||||
// - old program state is available
|
||||
// OR
|
||||
// - both of items above
|
||||
// With this it is possible that we can tell how some module names from the initial list will be resolved
|
||||
// without doing actual resolution (in particular if some name was resolved to ambient module).
|
||||
// Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker`
|
||||
// since we don't want to resolve them again.
|
||||
// With this information, we can infer some module resolutions without performing resolution.
|
||||
|
||||
// this is a list of modules for which we cannot predict resolution so they should be actually resolved
|
||||
/** An ordered list of module names for which we cannot recover the resolution. */
|
||||
let unknownModuleNames: string[];
|
||||
// this is a list of combined results assembles from predicted and resolved results.
|
||||
// Order in this list matches the order in the original list of module names `moduleNames` which is important
|
||||
// so later we can split results to resolutions of modules and resolutions of module augmentations.
|
||||
/**
|
||||
* The indexing of elements in this list matches that of `moduleNames`.
|
||||
*
|
||||
* Before combining results, result[i] is in one of the following states:
|
||||
* * undefined: needs to be recomputed,
|
||||
* * predictedToResolveToAmbientModuleMarker: known to be an ambient module.
|
||||
* Needs to be reset to undefined before returning,
|
||||
* * ResolvedModuleFull instance: can be reused.
|
||||
*/
|
||||
let result: ResolvedModuleFull[];
|
||||
// a transient placeholder that is used to mark predicted resolution in the result list
|
||||
/** A transient placeholder used to mark predicted resolution in the result list. */
|
||||
const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = <any>{};
|
||||
|
||||
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
const moduleName = moduleNames[i];
|
||||
// module name is known to be resolved to ambient module if
|
||||
// - module name is contained in the list of ambient modules that are locally declared in the file
|
||||
// - in the old program module name was resolved to ambient module whose declaration is in non-modified file
|
||||
// If we want to reuse resolutions more aggressively, we can refine this to check for whether the
|
||||
// text of the corresponding modulenames has changed.
|
||||
if (file === oldSourceFile) {
|
||||
const oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName);
|
||||
if (oldResolvedModule) {
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(host, Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile);
|
||||
}
|
||||
(result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// We know moduleName resolves to an ambient module provided that moduleName:
|
||||
// - is in the list of ambient modules locally declared in the current source file.
|
||||
// - resolved to an ambient module in the old program whose declaration is in an unmodified file
|
||||
// (so the same module declaration will land in the new program)
|
||||
let isKnownToResolveToAmbientModule = false;
|
||||
let resolvesToAmbientModuleInNonModifiedFile = false;
|
||||
if (contains(file.ambientModuleNames, moduleName)) {
|
||||
isKnownToResolveToAmbientModule = true;
|
||||
resolvesToAmbientModuleInNonModifiedFile = true;
|
||||
if (isTraceEnabled(options, host)) {
|
||||
trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
|
||||
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState);
|
||||
}
|
||||
|
||||
if (isKnownToResolveToAmbientModule) {
|
||||
if (!unknownModuleNames) {
|
||||
// found a first module name for which result can be prediced
|
||||
// this means that this module name should not be passed to `resolveModuleNamesWorker`.
|
||||
// We'll use a separate list for module names that are definitely unknown.
|
||||
result = new Array(moduleNames.length);
|
||||
// copy all module names that appear before the current one in the list
|
||||
// since they are known to be unknown
|
||||
unknownModuleNames = moduleNames.slice(0, i);
|
||||
}
|
||||
// mark prediced resolution in the result list
|
||||
result[i] = predictedToResolveToAmbientModuleMarker;
|
||||
if (resolvesToAmbientModuleInNonModifiedFile) {
|
||||
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
||||
}
|
||||
else if (unknownModuleNames) {
|
||||
// found unknown module name and we are already using separate list for those - add it to the list
|
||||
unknownModuleNames.push(moduleName);
|
||||
else {
|
||||
// Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
|
||||
(unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!unknownModuleNames) {
|
||||
// we've looked throught the list but have not seen any predicted resolution
|
||||
// use default logic
|
||||
return resolveModuleNamesWorker(moduleNames, containingFile);
|
||||
}
|
||||
|
||||
const resolutions = unknownModuleNames.length
|
||||
const resolutions = unknownModuleNames && unknownModuleNames.length
|
||||
? resolveModuleNamesWorker(unknownModuleNames, containingFile)
|
||||
: emptyArray;
|
||||
|
||||
// combine results of resolutions and predicted results
|
||||
// Combine results of resolutions and predicted results
|
||||
if (!result) {
|
||||
// There were no unresolved/ambient resolutions.
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
return <ResolvedModuleFull[]>resolutions;
|
||||
}
|
||||
|
||||
let j = 0;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (result[i] == predictedToResolveToAmbientModuleMarker) {
|
||||
result[i] = undefined;
|
||||
if (result[i]) {
|
||||
// `result[i]` is either a `ResolvedModuleFull` or a marker.
|
||||
// If it is the former, we can leave it as is.
|
||||
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
||||
result[i] = undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result[i] = resolutions[j];
|
||||
@@ -567,18 +594,18 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
Debug.assert(j === resolutions.length);
|
||||
|
||||
return result;
|
||||
|
||||
function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState?: OldProgramState): boolean {
|
||||
if (!oldProgramState) {
|
||||
return false;
|
||||
}
|
||||
// If we change our policy of rechecking failed lookups on each program create,
|
||||
// we should adjust the value returned here.
|
||||
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState: OldProgramState): boolean {
|
||||
const resolutionToFile = getResolvedModule(oldProgramState.file, moduleName);
|
||||
if (resolutionToFile) {
|
||||
// module used to be resolved to file - ignore it
|
||||
return false;
|
||||
}
|
||||
const ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName);
|
||||
const ambientModule = oldProgramState.program && oldProgramState.program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName);
|
||||
if (!(ambientModule && ambientModule.declarations)) {
|
||||
return false;
|
||||
}
|
||||
@@ -600,99 +627,107 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function tryReuseStructureFromOldProgram(): boolean {
|
||||
function tryReuseStructureFromOldProgram(): StructureIsReused {
|
||||
if (!oldProgram) {
|
||||
return false;
|
||||
return StructureIsReused.Not;
|
||||
}
|
||||
|
||||
// check properties that can affect structure of the program or module resolution strategy
|
||||
// if any of these properties has changed - structure cannot be reused
|
||||
const oldOptions = oldProgram.getCompilerOptions();
|
||||
if (changesAffectModuleResolution(oldOptions, options)) {
|
||||
return false;
|
||||
return oldProgram.structureIsReused = StructureIsReused.Not;
|
||||
}
|
||||
|
||||
Debug.assert(!oldProgram.structureIsReused);
|
||||
Debug.assert(!(oldProgram.structureIsReused & (StructureIsReused.Completely | StructureIsReused.SafeModules)));
|
||||
|
||||
// there is an old program, check if we can reuse its structure
|
||||
const oldRootNames = oldProgram.getRootFileNames();
|
||||
if (!arrayIsEqualTo(oldRootNames, rootNames)) {
|
||||
return false;
|
||||
return oldProgram.structureIsReused = StructureIsReused.Not;
|
||||
}
|
||||
|
||||
if (!arrayIsEqualTo(options.types, oldOptions.types)) {
|
||||
return false;
|
||||
return oldProgram.structureIsReused = StructureIsReused.Not;
|
||||
}
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
const newSourceFiles: SourceFile[] = [];
|
||||
const filePaths: Path[] = [];
|
||||
const modifiedSourceFiles: { oldFile: SourceFile, newFile: SourceFile }[] = [];
|
||||
oldProgram.structureIsReused = StructureIsReused.Completely;
|
||||
|
||||
for (const oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
let newSourceFile = host.getSourceFileByPath
|
||||
const newSourceFile = host.getSourceFileByPath
|
||||
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target)
|
||||
: host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
|
||||
if (!newSourceFile) {
|
||||
return false;
|
||||
return oldProgram.structureIsReused = StructureIsReused.Not;
|
||||
}
|
||||
|
||||
newSourceFile.path = oldSourceFile.path;
|
||||
filePaths.push(newSourceFile.path);
|
||||
|
||||
if (oldSourceFile !== newSourceFile) {
|
||||
// The `newSourceFile` object was created for the new program.
|
||||
|
||||
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
||||
// value of no-default-lib has changed
|
||||
// this will affect if default library is injected into the list of files
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
// check tripleslash references
|
||||
if (!arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
||||
// tripleslash references has changed
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
// check imports and module augmentations
|
||||
collectExternalModuleReferences(newSourceFile);
|
||||
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
||||
// imports has changed
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
||||
// moduleAugmentations has changed
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
// 'types' references has changed
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
}
|
||||
|
||||
// tentatively approve the file
|
||||
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
||||
}
|
||||
else {
|
||||
// file has no changes - use it as is
|
||||
newSourceFile = oldSourceFile;
|
||||
}
|
||||
|
||||
// if file has passed all checks it should be safe to reuse it
|
||||
newSourceFiles.push(newSourceFile);
|
||||
}
|
||||
|
||||
const modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path);
|
||||
if (oldProgram.structureIsReused !== StructureIsReused.Completely) {
|
||||
return oldProgram.structureIsReused;
|
||||
}
|
||||
|
||||
modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path);
|
||||
// try to verify results of module resolution
|
||||
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
|
||||
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
|
||||
if (resolveModuleNamesWorker) {
|
||||
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths });
|
||||
const oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths };
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState);
|
||||
// ensure that module resolution results are still correct
|
||||
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
|
||||
if (resolutionsChanged) {
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions);
|
||||
}
|
||||
else {
|
||||
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
||||
}
|
||||
}
|
||||
if (resolveTypeReferenceDirectiveNamesWorker) {
|
||||
@@ -701,12 +736,17 @@ namespace ts {
|
||||
// ensure that types resolutions are still correct
|
||||
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
|
||||
if (resolutionsChanged) {
|
||||
return false;
|
||||
oldProgram.structureIsReused = StructureIsReused.SafeModules;
|
||||
newSourceFile.resolvedTypeReferenceDirectiveNames = zipToMap(typesReferenceDirectives, resolutions);
|
||||
}
|
||||
else {
|
||||
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
||||
}
|
||||
}
|
||||
// pass the cache of module/types resolutions from the old source file
|
||||
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
||||
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
||||
}
|
||||
|
||||
if (oldProgram.structureIsReused !== StructureIsReused.Completely) {
|
||||
return oldProgram.structureIsReused;
|
||||
}
|
||||
|
||||
// update fileName -> file mapping
|
||||
@@ -721,9 +761,8 @@ namespace ts {
|
||||
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
|
||||
}
|
||||
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
|
||||
oldProgram.structureIsReused = true;
|
||||
|
||||
return true;
|
||||
return oldProgram.structureIsReused = StructureIsReused.Completely;
|
||||
}
|
||||
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
|
||||
@@ -909,6 +948,13 @@ namespace ts {
|
||||
|
||||
function getSemanticDiagnosticsForFileNoCache(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
|
||||
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
|
||||
// '/// <reference no-default-lib="true"/>' directive.
|
||||
if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) {
|
||||
return emptyArray;
|
||||
}
|
||||
|
||||
const typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
@@ -931,20 +977,22 @@ namespace ts {
|
||||
*/
|
||||
function shouldReportDiagnostic(diagnostic: Diagnostic) {
|
||||
const { file, start } = diagnostic;
|
||||
const lineStarts = getLineStarts(file);
|
||||
let { line } = computeLineAndCharacterOfPosition(lineStarts, start);
|
||||
while (line > 0) {
|
||||
const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
|
||||
const result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
|
||||
if (!result) {
|
||||
// non-empty line
|
||||
return true;
|
||||
if (file) {
|
||||
const lineStarts = getLineStarts(file);
|
||||
let { line } = computeLineAndCharacterOfPosition(lineStarts, start);
|
||||
while (line > 0) {
|
||||
const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
|
||||
const result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
|
||||
if (!result) {
|
||||
// non-empty line
|
||||
return true;
|
||||
}
|
||||
if (result[3]) {
|
||||
// @ts-ignore
|
||||
return false;
|
||||
}
|
||||
line--;
|
||||
}
|
||||
if (result[3]) {
|
||||
// @ts-ignore
|
||||
return false;
|
||||
}
|
||||
line--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -968,8 +1016,7 @@ namespace ts {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Pass through
|
||||
// falls through
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -1049,7 +1096,7 @@ namespace ts {
|
||||
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
|
||||
return;
|
||||
}
|
||||
// pass through
|
||||
// falls through
|
||||
case SyntaxKind.VariableStatement:
|
||||
// Check modifiers
|
||||
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration | VariableStatement>parent).modifiers) {
|
||||
@@ -1097,7 +1144,8 @@ namespace ts {
|
||||
if (isConstValid) {
|
||||
continue;
|
||||
}
|
||||
// Fallthrough to report error
|
||||
// to report error,
|
||||
// falls through
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
@@ -1368,7 +1416,7 @@ namespace ts {
|
||||
|
||||
// If the file was previously found via a node_modules search, but is now being processed as a root file,
|
||||
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
|
||||
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) {
|
||||
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
|
||||
sourceFilesFoundSearchingNodeModules.set(file.path, false);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, isDefaultLib);
|
||||
@@ -1523,11 +1571,11 @@ namespace ts {
|
||||
function processImportedModules(file: SourceFile) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
file.resolvedModules = createMap<ResolvedModuleFull>();
|
||||
// Because global augmentation doesn't have string literal name, we can check for global augmentation as such.
|
||||
const nonGlobalAugmentation = filter(file.moduleAugmentations, (moduleAugmentation) => moduleAugmentation.kind === SyntaxKind.StringLiteral);
|
||||
const moduleNames = map(concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral);
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file);
|
||||
const oldProgramState = { program: oldProgram, file, modifiedFilePaths };
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
const resolution = resolutions[i];
|
||||
|
||||
+29
-6
@@ -308,6 +308,7 @@ namespace ts {
|
||||
if (text.charCodeAt(pos) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
// falls through
|
||||
case CharacterCodes.lineFeed:
|
||||
result.push(lineStart);
|
||||
lineStart = pos;
|
||||
@@ -366,7 +367,7 @@ namespace ts {
|
||||
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
||||
}
|
||||
|
||||
export function isWhiteSpace(ch: number): boolean {
|
||||
export function isWhiteSpaceLike(ch: number): boolean {
|
||||
return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
|
||||
}
|
||||
|
||||
@@ -454,6 +455,7 @@ namespace ts {
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
// falls through
|
||||
case CharacterCodes.lineFeed:
|
||||
pos++;
|
||||
if (stopAfterLineBreak) {
|
||||
@@ -510,7 +512,7 @@ namespace ts {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
@@ -625,6 +627,7 @@ namespace ts {
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
// falls through
|
||||
case CharacterCodes.lineFeed:
|
||||
pos++;
|
||||
if (trailing) {
|
||||
@@ -691,7 +694,7 @@ namespace ts {
|
||||
}
|
||||
break scan;
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch))) {
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpaceLike(ch))) {
|
||||
if (hasPendingCommentRange && isLineBreak(ch)) {
|
||||
pendingHasTrailingNewLine = true;
|
||||
}
|
||||
@@ -1072,7 +1075,7 @@ namespace ts {
|
||||
if (pos < end && text.charCodeAt(pos) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.lineSeparator:
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
@@ -1459,6 +1462,7 @@ namespace ts {
|
||||
// This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero
|
||||
// can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being
|
||||
// permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do).
|
||||
// falls through
|
||||
case CharacterCodes._1:
|
||||
case CharacterCodes._2:
|
||||
case CharacterCodes._3:
|
||||
@@ -1723,8 +1727,12 @@ namespace ts {
|
||||
return token = SyntaxKind.OpenBraceToken;
|
||||
}
|
||||
|
||||
// First non-whitespace character on this line.
|
||||
let firstNonWhitespace = 0;
|
||||
// These initial values are special because the first line is:
|
||||
// firstNonWhitespace = 0 to indicate that we want leading whitspace,
|
||||
|
||||
while (pos < end) {
|
||||
pos++;
|
||||
char = text.charCodeAt(pos);
|
||||
if (char === CharacterCodes.openBrace) {
|
||||
break;
|
||||
@@ -1736,8 +1744,23 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces.
|
||||
// i.e (- : whitespace)
|
||||
// <div>----
|
||||
// </div> becomes <div></div>
|
||||
//
|
||||
// <div>----</div> becomes <div>----</div>
|
||||
if (isLineBreak(char) && firstNonWhitespace === 0) {
|
||||
firstNonWhitespace = -1;
|
||||
}
|
||||
else if (!isWhiteSpaceLike(char)) {
|
||||
firstNonWhitespace = pos;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return token = SyntaxKind.JsxText;
|
||||
|
||||
return firstNonWhitespace === -1 ? SyntaxKind.JsxTextAllWhiteSpaces : SyntaxKind.JsxText;
|
||||
}
|
||||
|
||||
// Scans a JSX identifier; these differ from normal identifiers in that
|
||||
|
||||
@@ -813,7 +813,7 @@ namespace ts {
|
||||
|
||||
// Create a synthetic text range for the return statement.
|
||||
const closingBraceLocation = createTokenRange(skipTrivia(currentText, node.members.end), SyntaxKind.CloseBraceToken);
|
||||
const localName = getLocalName(node);
|
||||
const localName = getInternalName(node);
|
||||
|
||||
// The following partially-emitted expression exists purely to align our sourcemap
|
||||
// emit with the original emitter.
|
||||
@@ -870,7 +870,7 @@ namespace ts {
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
getDeclarationName(node),
|
||||
getInternalName(node),
|
||||
/*typeParameters*/ undefined,
|
||||
transformConstructorParameters(constructor, hasSynthesizedSuper),
|
||||
/*type*/ undefined,
|
||||
@@ -2009,13 +2009,14 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
|
||||
setTextRange(assignment, decl);
|
||||
}
|
||||
|
||||
assignments = append(assignments, assignment);
|
||||
}
|
||||
}
|
||||
if (assignments) {
|
||||
updated = setTextRange(createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc))), node);
|
||||
updated = setTextRange(createStatement(inlineExpressions(assignments)), node);
|
||||
}
|
||||
else {
|
||||
// none of declarations has initializer - the entire variable statement can be deleted
|
||||
@@ -2714,9 +2715,8 @@ namespace ts {
|
||||
loopBody = createBlock([loopBody], /*multiline*/ true);
|
||||
}
|
||||
|
||||
const isAsyncBlockContainingAwait =
|
||||
hierarchyFacts & HierarchyFacts.AsyncFunctionBody
|
||||
&& (node.statement.transformFlags & TransformFlags.ContainsYield) !== 0;
|
||||
const containsYield = (node.statement.transformFlags & TransformFlags.ContainsYield) !== 0;
|
||||
const isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & HierarchyFacts.AsyncFunctionBody) !== 0;
|
||||
|
||||
let loopBodyFlags: EmitFlags = 0;
|
||||
if (currentState.containsLexicalThis) {
|
||||
@@ -2739,7 +2739,7 @@ namespace ts {
|
||||
setEmitFlags(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
isAsyncBlockContainingAwait ? createToken(SyntaxKind.AsteriskToken) : undefined,
|
||||
containsYield ? createToken(SyntaxKind.AsteriskToken) : undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
loopParameters,
|
||||
@@ -2833,7 +2833,7 @@ namespace ts {
|
||||
));
|
||||
}
|
||||
|
||||
const convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait);
|
||||
const convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield);
|
||||
|
||||
let loop: Statement;
|
||||
if (convert) {
|
||||
@@ -3181,7 +3181,20 @@ namespace ts {
|
||||
const savedConvertedLoopState = convertedLoopState;
|
||||
convertedLoopState = undefined;
|
||||
const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes);
|
||||
const updated = visitEachChild(node, visitor, context);
|
||||
let updated: AccessorDeclaration;
|
||||
if (node.transformFlags & TransformFlags.ContainsCapturedLexicalThis) {
|
||||
const parameters = visitParameterList(node.parameters, visitor, context);
|
||||
const body = transformFunctionBody(node);
|
||||
if (node.kind === SyntaxKind.GetAccessor) {
|
||||
updated = updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
|
||||
}
|
||||
else {
|
||||
updated = updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
|
||||
}
|
||||
}
|
||||
else {
|
||||
updated = visitEachChild(node, visitor, context);
|
||||
}
|
||||
exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None);
|
||||
convertedLoopState = savedConvertedLoopState;
|
||||
return updated;
|
||||
@@ -3713,7 +3726,7 @@ namespace ts {
|
||||
function substituteIdentifier(node: Identifier) {
|
||||
// Only substitute the identifier if we have enabled substitutions for block-scoped
|
||||
// bindings.
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings && !isInternalName(node)) {
|
||||
const original = getParseTreeNode(node, isIdentifier);
|
||||
if (original && isNameOfDeclarationWithCollidingName(original)) {
|
||||
return setTextRange(getGeneratedNameForNode(original), node);
|
||||
@@ -3766,9 +3779,9 @@ namespace ts {
|
||||
* @param node An Identifier node.
|
||||
*/
|
||||
function substituteExpressionIdentifier(node: Identifier): Identifier {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings && !isInternalName(node)) {
|
||||
const declaration = resolver.getReferencedDeclarationWithCollidingName(node);
|
||||
if (declaration) {
|
||||
if (declaration && !(isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
|
||||
return setTextRange(getGeneratedNameForNode(declaration.name), node);
|
||||
}
|
||||
}
|
||||
@@ -3776,6 +3789,32 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function isPartOfClassBody(declaration: ClassLikeDeclaration, node: Identifier) {
|
||||
let currentNode = getParseTreeNode(node);
|
||||
if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
|
||||
// if the node has no correlation to a parse tree node, its definitely not
|
||||
// part of the body.
|
||||
// if the node is outside of the document range of the declaration, its
|
||||
// definitely not part of the body.
|
||||
return false;
|
||||
}
|
||||
const blockScope = getEnclosingBlockScopeContainer(declaration);
|
||||
while (currentNode) {
|
||||
if (currentNode === blockScope || currentNode === declaration) {
|
||||
// if we are in the enclosing block scope of the declaration, we are definitely
|
||||
// not inside the class body.
|
||||
return false;
|
||||
}
|
||||
if (isClassElement(currentNode) && currentNode.parent === declaration) {
|
||||
// we are in the class body, but we treat static fields as outside of the class body
|
||||
return currentNode.kind !== SyntaxKind.PropertyDeclaration
|
||||
|| (getModifierFlags(currentNode) & ModifierFlags.Static) === 0;
|
||||
}
|
||||
currentNode = currentNode.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes `this` when contained within an arrow function.
|
||||
*
|
||||
@@ -3790,8 +3829,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
const expression = getLocalName(node);
|
||||
return hasModifier(member, ModifierFlags.Static) ? expression : createPropertyAccess(expression, "prototype");
|
||||
return hasModifier(member, ModifierFlags.Static)
|
||||
? getInternalName(node)
|
||||
: createPropertyAccess(getInternalName(node), "prototype");
|
||||
}
|
||||
|
||||
function hasSynthesizedDefaultSuperCall(constructor: ConstructorDeclaration, hasExtendsClause: boolean) {
|
||||
|
||||
@@ -106,15 +106,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function visitAwaitExpression(node: AwaitExpression) {
|
||||
function visitAwaitExpression(node: AwaitExpression): Expression {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
return setOriginalNode(
|
||||
setTextRange(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
createArrayLiteral([createLiteral("await"), expression])
|
||||
),
|
||||
createYield(createAwaitHelper(context, visitNode(node.expression, visitor, isExpression))),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
@@ -124,18 +120,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitYieldExpression(node: YieldExpression) {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) {
|
||||
if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator && node.asteriskToken) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
return updateYield(
|
||||
node,
|
||||
node.asteriskToken,
|
||||
node.asteriskToken
|
||||
? createAsyncDelegatorHelper(context, expression, expression)
|
||||
: createArrayLiteral(
|
||||
expression
|
||||
? [createLiteral("yield"), expression]
|
||||
: [createLiteral("yield")]
|
||||
)
|
||||
return setOriginalNode(
|
||||
setTextRange(
|
||||
createYield(
|
||||
createAwaitHelper(context,
|
||||
updateYield(
|
||||
node,
|
||||
node.asteriskToken,
|
||||
createAsyncDelegatorHelper(
|
||||
context,
|
||||
createAsyncValuesHelper(context, expression, expression),
|
||||
expression
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
node
|
||||
),
|
||||
node
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
@@ -347,6 +351,10 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function awaitAsYield(expression: Expression) {
|
||||
return createYield(/*asteriskToken*/ undefined, enclosingFunctionFlags & FunctionFlags.Generator ? createAwaitHelper(context, expression) : expression);
|
||||
}
|
||||
|
||||
function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined);
|
||||
@@ -354,16 +362,11 @@ namespace ts {
|
||||
const errorRecord = createUniqueName("e");
|
||||
const catchVariable = getGeneratedNameForNode(errorRecord);
|
||||
const returnMethod = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression);
|
||||
const next = createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
enclosingFunctionFlags & FunctionFlags.Generator
|
||||
? createArrayLiteral([
|
||||
createLiteral("await"),
|
||||
createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
|
||||
])
|
||||
: createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
|
||||
);
|
||||
const callValues = createAsyncValuesHelper(context, expression, /*location*/ node.expression);
|
||||
const callNext = createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []);
|
||||
const getDone = createPropertyAccess(result, "done");
|
||||
const getValue = createPropertyAccess(result, "value");
|
||||
const callReturn = createFunctionCall(returnMethod, iterator, []);
|
||||
|
||||
hoistVariableDeclaration(errorRecord);
|
||||
hoistVariableDeclaration(returnMethod);
|
||||
@@ -374,16 +377,19 @@ namespace ts {
|
||||
/*initializer*/ setEmitFlags(
|
||||
setTextRange(
|
||||
createVariableDeclarationList([
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression),
|
||||
createVariableDeclaration(result, /*type*/ undefined, next)
|
||||
setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression),
|
||||
createVariableDeclaration(result)
|
||||
]),
|
||||
node.expression
|
||||
),
|
||||
EmitFlags.NoHoisting
|
||||
),
|
||||
/*condition*/ createLogicalNot(createPropertyAccess(result, "done")),
|
||||
/*incrementor*/ createAssignment(result, next),
|
||||
/*statement*/ convertForOfStatementHead(node, createPropertyAccess(result, "value"))
|
||||
/*condition*/ createComma(
|
||||
createAssignment(result, awaitAsYield(callNext)),
|
||||
createLogicalNot(getDone)
|
||||
),
|
||||
/*incrementor*/ undefined,
|
||||
/*statement*/ convertForOfStatementHead(node, awaitAsYield(getValue))
|
||||
),
|
||||
/*location*/ node
|
||||
),
|
||||
@@ -421,26 +427,14 @@ namespace ts {
|
||||
createLogicalAnd(
|
||||
createLogicalAnd(
|
||||
result,
|
||||
createLogicalNot(
|
||||
createPropertyAccess(result, "done")
|
||||
)
|
||||
createLogicalNot(getDone)
|
||||
),
|
||||
createAssignment(
|
||||
returnMethod,
|
||||
createPropertyAccess(iterator, "return")
|
||||
)
|
||||
),
|
||||
createStatement(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
enclosingFunctionFlags & FunctionFlags.Generator
|
||||
? createArrayLiteral([
|
||||
createLiteral("await"),
|
||||
createFunctionCall(returnMethod, iterator, [])
|
||||
])
|
||||
: createFunctionCall(returnMethod, iterator, [])
|
||||
)
|
||||
)
|
||||
createStatement(awaitAsYield(callReturn))
|
||||
),
|
||||
EmitFlags.SingleLine
|
||||
)
|
||||
@@ -880,27 +874,39 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
const awaitHelper: EmitHelper = {
|
||||
name: "typescript:await",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
`
|
||||
};
|
||||
|
||||
function createAwaitHelper(context: TransformationContext, expression: Expression) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
return createCall(getHelperName("__await"), /*typeArguments*/ undefined, [expression]);
|
||||
}
|
||||
|
||||
const asyncGeneratorHelper: EmitHelper = {
|
||||
name: "typescript:asyncGenerator",
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
|
||||
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
|
||||
function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }
|
||||
function step(r) { r.done ? settle(c[2], r) : r.value[0] === "yield" ? settle(c[2], { value: r.value[1], done: false }) : Promise.resolve(r.value[1]).then(r.value[0] === "delegate" ? delegate : fulfill, reject); }
|
||||
function delegate(r) { step(r.done ? r : { value: ["yield", r.value], done: false }); }
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { c = void 0, f(v), next(); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
context.requestEmitHelper(asyncGeneratorHelper);
|
||||
|
||||
// Mark this node as originally an async function
|
||||
@@ -922,14 +928,15 @@ namespace ts {
|
||||
scoped: false,
|
||||
text: `
|
||||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
||||
var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) };
|
||||
return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; }
|
||||
var i, p;
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
||||
function verb(n) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : v; }; }
|
||||
};
|
||||
`
|
||||
};
|
||||
|
||||
function createAsyncDelegatorHelper(context: TransformationContext, expression: Expression, location?: TextRange) {
|
||||
context.requestEmitHelper(awaitHelper);
|
||||
context.requestEmitHelper(asyncDelegator);
|
||||
return setTextRange(
|
||||
createCall(
|
||||
|
||||
@@ -479,8 +479,8 @@ namespace ts {
|
||||
// module is imported only for side-effects, no emit required
|
||||
break;
|
||||
}
|
||||
// falls through
|
||||
|
||||
// fall-through
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
Debug.assert(importVariableName !== undefined);
|
||||
// save import into the local
|
||||
|
||||
@@ -521,9 +521,10 @@ namespace ts {
|
||||
// emit name if
|
||||
// - node has a name
|
||||
// - node has static initializers
|
||||
// - node has a member that is decorated
|
||||
//
|
||||
let name = node.name;
|
||||
if (!name && staticProperties.length > 0) {
|
||||
if (!name && (staticProperties.length > 0 || childIsDecorated(node))) {
|
||||
name = getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
@@ -1761,23 +1762,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function serializeUnionOrIntersectionType(node: UnionOrIntersectionTypeNode): SerializedTypeNode {
|
||||
// Note when updating logic here also update getEntityNameForDecoratorMetadata
|
||||
// so that aliases can be marked as referenced
|
||||
let serializedUnion: SerializedTypeNode;
|
||||
for (const typeNode of node.types) {
|
||||
const serializedIndividual = serializeTypeNode(typeNode);
|
||||
|
||||
if (isVoidExpression(serializedIndividual)) {
|
||||
// If we dont have any other type already set, set the initial type
|
||||
if (!serializedUnion) {
|
||||
serializedUnion = serializedIndividual;
|
||||
}
|
||||
}
|
||||
else if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") {
|
||||
if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") {
|
||||
// One of the individual is global object, return immediately
|
||||
return serializedIndividual;
|
||||
}
|
||||
// If there exists union that is not void 0 expression, check if the the common type is identifier.
|
||||
// anything more complex and we will just default to Object
|
||||
else if (serializedUnion && !isVoidExpression(serializedUnion)) {
|
||||
else if (serializedUnion) {
|
||||
// Different types
|
||||
if (!isIdentifier(serializedUnion) ||
|
||||
!isIdentifier(serializedIndividual) ||
|
||||
@@ -2600,14 +2597,16 @@ namespace ts {
|
||||
* Adds a leading VariableStatement for a enum or module declaration.
|
||||
*/
|
||||
function addVarForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration) {
|
||||
// Emit a variable statement for the module.
|
||||
// Emit a variable statement for the module. We emit top-level enums as a `var`
|
||||
// declaration to avoid static errors in global scripts scripts due to redeclaration.
|
||||
// enums in any other scope are emitted as a `let` declaration.
|
||||
const statement = createVariableStatement(
|
||||
visitNodes(node.modifiers, modifierVisitor, isModifier),
|
||||
[
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)
|
||||
)
|
||||
]
|
||||
], currentScope.kind === SyntaxKind.SourceFile ? NodeFlags.None : NodeFlags.Let)
|
||||
);
|
||||
|
||||
setOriginalNode(statement, node);
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function reportEmittedFiles(files: string[]): void {
|
||||
if (!files || files.length == 0) {
|
||||
if (!files || files.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace ts {
|
||||
// When the configFileName is just "tsconfig.json", the watched directory should be
|
||||
// the current directory; if there is a given "project" parameter, then the configFileName
|
||||
// is an absolute file name.
|
||||
directory == "" ? "." : directory,
|
||||
directory === "" ? "." : directory,
|
||||
watchedDirectoryChanged, /*recursive*/ true);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ namespace ts {
|
||||
// When the configFileName is just "tsconfig.json", the watched directory should be
|
||||
// the current directory; if there is a given "project" parameter, then the configFileName
|
||||
// is an absolute file name.
|
||||
directory == "" ? "." : directory,
|
||||
directory === "" ? "." : directory,
|
||||
watchedDirectoryChanged, /*recursive*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
+36
-16
@@ -10,7 +10,7 @@ namespace ts {
|
||||
|
||||
/** ES6 Map interface. */
|
||||
export interface Map<T> {
|
||||
get(key: string): T;
|
||||
get(key: string): T | undefined;
|
||||
has(key: string): boolean;
|
||||
set(key: string, value: T): this;
|
||||
delete(key: string): boolean;
|
||||
@@ -65,6 +65,7 @@ namespace ts {
|
||||
NumericLiteral,
|
||||
StringLiteral,
|
||||
JsxText,
|
||||
JsxTextAllWhiteSpaces,
|
||||
RegularExpressionLiteral,
|
||||
NoSubstitutionTemplateLiteral,
|
||||
// Pseudo-literals
|
||||
@@ -1505,7 +1506,7 @@ namespace ts {
|
||||
// for the same reasons we treat NewExpression as a PrimaryExpression.
|
||||
export interface MetaProperty extends PrimaryExpression {
|
||||
kind: SyntaxKind.MetaProperty;
|
||||
keywordToken: SyntaxKind;
|
||||
keywordToken: SyntaxKind.NewKeyword;
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
@@ -1572,6 +1573,7 @@ namespace ts {
|
||||
|
||||
export interface JsxText extends Node {
|
||||
kind: SyntaxKind.JsxText;
|
||||
containsOnlyWhiteSpaces: boolean;
|
||||
parent?: JsxElement;
|
||||
}
|
||||
|
||||
@@ -2410,7 +2412,14 @@ namespace ts {
|
||||
/* @internal */ getResolvedTypeReferenceDirectives(): Map<ResolvedTypeReferenceDirective>;
|
||||
/* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
// For testing purposes only.
|
||||
/* @internal */ structureIsReused?: boolean;
|
||||
/* @internal */ structureIsReused?: StructureIsReused;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export const enum StructureIsReused {
|
||||
Not = 0,
|
||||
SafeModules = 1 << 0,
|
||||
Completely = 1 << 1,
|
||||
}
|
||||
|
||||
export interface CustomTransformers {
|
||||
@@ -2547,6 +2556,9 @@ namespace ts {
|
||||
|
||||
tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string;
|
||||
/* @internal */ getBaseConstraintOfType(type: Type): Type;
|
||||
|
||||
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol;
|
||||
|
||||
@@ -2729,7 +2741,6 @@ namespace ts {
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
||||
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
@@ -3354,6 +3365,7 @@ namespace ts {
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export enum DiagnosticCategory {
|
||||
@@ -3945,14 +3957,15 @@ namespace ts {
|
||||
HelperName = 1 << 12,
|
||||
ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal).
|
||||
LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration.
|
||||
Indented = 1 << 15, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
NoIndentation = 1 << 16, // Do not indent the node.
|
||||
AsyncFunctionBody = 1 << 17,
|
||||
ReuseTempVariableScope = 1 << 18, // Reuse the existing temp variable scope during emit.
|
||||
CustomPrologue = 1 << 19, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
||||
NoHoisting = 1 << 20, // Do not hoist this declaration in --module system
|
||||
HasEndOfDeclarationMarker = 1 << 21, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||
Iterator = 1 << 22, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||
InternalName = 1 << 15, // The name is internal to an ES5 class body function.
|
||||
Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter).
|
||||
NoIndentation = 1 << 17, // Do not indent the node.
|
||||
AsyncFunctionBody = 1 << 18,
|
||||
ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit.
|
||||
CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
|
||||
NoHoisting = 1 << 21, // Do not hoist this declaration in --module system
|
||||
HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration
|
||||
Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable.
|
||||
}
|
||||
|
||||
export interface EmitHelper {
|
||||
@@ -3977,11 +3990,12 @@ namespace ts {
|
||||
Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation)
|
||||
Generator = 1 << 7, // __generator (used by ES2015 generator transformation)
|
||||
Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations)
|
||||
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation)
|
||||
Spread = 1 << 10, // __spread (used by ES2015 array spread and argument list spread transformations)
|
||||
AsyncGenerator = 1 << 11, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncDelegator = 1 << 12, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 13, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
Await = 1 << 11, // __await (used by ES2017 async generator transformation)
|
||||
AsyncGenerator = 1 << 12, // __asyncGenerator (used by ES2017 async generator transformation)
|
||||
AsyncDelegator = 1 << 13, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
|
||||
// Helpers included by ES2015 for..of
|
||||
ForOfIncludes = Values,
|
||||
@@ -3989,6 +4003,12 @@ namespace ts {
|
||||
// Helpers included by ES2017 for..await..of
|
||||
ForAwaitOfIncludes = AsyncValues,
|
||||
|
||||
// Helpers included by ES2017 async generators
|
||||
AsyncGeneratorIncludes = Await | AsyncGenerator,
|
||||
|
||||
// Helpers included by yield* in ES2017 async generators
|
||||
AsyncDelegatorIncludes = Await | AsyncDelegator | AsyncValues,
|
||||
|
||||
// Helpers included by ES2015 spread
|
||||
SpreadIncludes = Read | Spread,
|
||||
|
||||
|
||||
+60
-22
@@ -122,9 +122,8 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function hasChangesInResolutions<T>(names: string[], newResolutions: T[], oldResolutions: Map<T>, comparer: (oldResolution: T, newResolution: T) => boolean): boolean {
|
||||
if (names.length !== newResolutions.length) {
|
||||
return false;
|
||||
}
|
||||
Debug.assert(names.length === newResolutions.length);
|
||||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const newResolution = newResolutions[i];
|
||||
const oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
||||
@@ -674,6 +673,7 @@ namespace ts {
|
||||
// At this point, node is either a qualified name or an identifier
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression,
|
||||
"'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
|
||||
// falls through
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
@@ -783,6 +783,7 @@ namespace ts {
|
||||
if (operand) {
|
||||
traverse(operand);
|
||||
}
|
||||
return;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
@@ -1009,7 +1010,7 @@ namespace ts {
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
}
|
||||
// Fall through
|
||||
// falls through
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
@@ -1068,6 +1069,7 @@ namespace ts {
|
||||
if (!stopOnFunctions) {
|
||||
continue;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -1149,6 +1151,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression {
|
||||
return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression;
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
@@ -1267,7 +1273,7 @@ namespace ts {
|
||||
if (node.parent.kind === SyntaxKind.TypeQuery || isJSXTagName(node)) {
|
||||
return true;
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
@@ -1870,7 +1876,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getAncestor(node: Node | undefined, kind: SyntaxKind): Node {
|
||||
export function getAncestor(node: Node | undefined, kind: SyntaxKind): Node | undefined {
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return node;
|
||||
@@ -1925,16 +1931,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
export const enum FunctionFlags {
|
||||
Normal = 0,
|
||||
Generator = 1 << 0,
|
||||
Async = 1 << 1,
|
||||
AsyncOrAsyncGenerator = Async | Generator,
|
||||
Invalid = 1 << 2,
|
||||
InvalidAsyncOrAsyncGenerator = AsyncOrAsyncGenerator | Invalid,
|
||||
InvalidGenerator = Generator | Invalid,
|
||||
Normal = 0, // Function is a normal function
|
||||
Generator = 1 << 0, // Function is a generator function or async generator function
|
||||
Async = 1 << 1, // Function is an async function or an async generator function
|
||||
Invalid = 1 << 2, // Function is a signature or overload and does not have a body.
|
||||
AsyncGenerator = Async | Generator, // Function is an async generator function
|
||||
}
|
||||
|
||||
export function getFunctionFlags(node: FunctionLikeDeclaration) {
|
||||
export function getFunctionFlags(node: FunctionLikeDeclaration | undefined) {
|
||||
if (!node) {
|
||||
return FunctionFlags.Invalid;
|
||||
}
|
||||
|
||||
let flags = FunctionFlags.Normal;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -1943,7 +1951,7 @@ namespace ts {
|
||||
if (node.asteriskToken) {
|
||||
flags |= FunctionFlags.Generator;
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
flags |= FunctionFlags.Async;
|
||||
@@ -3577,10 +3585,6 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
export function isVoidExpression(node: Node): node is VoidExpression {
|
||||
return node.kind === SyntaxKind.VoidExpression;
|
||||
}
|
||||
|
||||
export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier {
|
||||
// Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`.
|
||||
return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None;
|
||||
@@ -3657,7 +3661,18 @@ namespace ts {
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor
|
||||
|| kind === SyntaxKind.IndexSignature
|
||||
|| kind === SyntaxKind.SemicolonClassElement;
|
||||
|| kind === SyntaxKind.SemicolonClassElement
|
||||
|| kind === SyntaxKind.MissingDeclaration;
|
||||
}
|
||||
|
||||
export function isTypeElement(node: Node): node is TypeElement {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ConstructSignature
|
||||
|| kind === SyntaxKind.CallSignature
|
||||
|| kind === SyntaxKind.PropertySignature
|
||||
|| kind === SyntaxKind.MethodSignature
|
||||
|| kind === SyntaxKind.IndexSignature
|
||||
|| kind === SyntaxKind.MissingDeclaration;
|
||||
}
|
||||
|
||||
export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike {
|
||||
@@ -4449,7 +4464,7 @@ namespace ts {
|
||||
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
|
||||
}
|
||||
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN);
|
||||
}
|
||||
|
||||
export function getTypeParameterOwner(d: Declaration): Declaration {
|
||||
@@ -4625,7 +4640,7 @@ namespace ts {
|
||||
*/
|
||||
export function getParseTreeNode<T extends Node>(node: Node, nodeTest?: (node: Node) => node is T): T;
|
||||
export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node {
|
||||
if (node == undefined || isParseTreeNode(node)) {
|
||||
if (node === undefined || isParseTreeNode(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -4647,4 +4662,27 @@ namespace ts {
|
||||
export function unescapeIdentifier(identifier: string): string {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
export function levenshtein(s1: string, s2: string): number {
|
||||
let previous: number[] = new Array(s2.length + 1);
|
||||
let current: number[] = new Array(s2.length + 1);
|
||||
for (let i = 0; i < s2.length + 1; i++) {
|
||||
previous[i] = i;
|
||||
current[i] = -1;
|
||||
}
|
||||
for (let i = 1; i < s1.length + 1; i++) {
|
||||
current[0] = i;
|
||||
for (let j = 1; j < s2.length + 1; j++) {
|
||||
current[j] = Math.min(
|
||||
previous[j] + 1,
|
||||
current[j - 1] + 1,
|
||||
previous[j - 1] + (s1[i - 1] === s2[j - 1] ? 0 : 2));
|
||||
}
|
||||
// shift current back to previous, and then reuse previous' array
|
||||
const tmp = previous;
|
||||
previous = current;
|
||||
current = tmp;
|
||||
}
|
||||
return previous[previous.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
+153
-119
@@ -218,16 +218,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
case SyntaxKind.EmptyStatement:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.DebuggerStatement:
|
||||
case SyntaxKind.EndOfDeclarationMarker:
|
||||
case SyntaxKind.MissingDeclaration:
|
||||
// No need to visit nodes with no children.
|
||||
return node;
|
||||
|
||||
switch (kind) {
|
||||
// Names
|
||||
case SyntaxKind.QualifiedName:
|
||||
return updateQualifiedName(<QualifiedName>node,
|
||||
@@ -238,45 +229,13 @@ namespace ts {
|
||||
return updateComputedPropertyName(<ComputedPropertyName>node,
|
||||
visitNode((<ComputedPropertyName>node).expression, visitor, isExpression));
|
||||
|
||||
// Signatures and Signature Elements
|
||||
case SyntaxKind.FunctionType:
|
||||
return updateFunctionTypeNode(<FunctionTypeNode>node,
|
||||
nodesVisitor((<FunctionTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
visitParameterList((<FunctionTypeNode>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<FunctionTypeNode>node).type, visitor, isTypeNode));
|
||||
// Signature elements
|
||||
|
||||
case SyntaxKind.ConstructorType:
|
||||
return updateConstructorTypeNode(<ConstructorTypeNode>node,
|
||||
nodesVisitor((<ConstructorTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
visitParameterList((<ConstructorTypeNode>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<ConstructorTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return updateCallSignatureDeclaration(<CallSignatureDeclaration>node,
|
||||
nodesVisitor((<CallSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
visitParameterList((<CallSignatureDeclaration>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<CallSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return updateConstructSignatureDeclaration(<ConstructSignatureDeclaration>node,
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
visitParameterList((<ConstructSignatureDeclaration>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<ConstructSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
return updateMethodSignature(<MethodSignature>node,
|
||||
nodesVisitor((<MethodSignature>node).typeParameters, visitor, isTypeParameter),
|
||||
visitParameterList((<MethodSignature>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<MethodSignature>node).type, visitor, isTypeNode),
|
||||
visitNode((<MethodSignature>node).name, visitor, isPropertyName),
|
||||
visitNode((<MethodSignature>node).questionToken, tokenVisitor, isToken));
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
return updateIndexSignatureDeclaration(<IndexSignatureDeclaration>node,
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).modifiers, visitor, isModifier),
|
||||
visitParameterList((<IndexSignatureDeclaration>node).parameters, visitor, context, nodesVisitor),
|
||||
visitNode((<IndexSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
case SyntaxKind.TypeParameter:
|
||||
return updateTypeParameterDeclaration(<TypeParameterDeclaration>node,
|
||||
visitNode((<TypeParameterDeclaration>node).name, visitor, isIdentifier),
|
||||
visitNode((<TypeParameterDeclaration>node).constraint, visitor, isTypeNode),
|
||||
visitNode((<TypeParameterDeclaration>node).default, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
return updateParameter(<ParameterDeclaration>node,
|
||||
@@ -292,66 +251,7 @@ namespace ts {
|
||||
return updateDecorator(<Decorator>node,
|
||||
visitNode((<Decorator>node).expression, visitor, isExpression));
|
||||
|
||||
// Types
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
return updateTypeReferenceNode(<TypeReferenceNode>node,
|
||||
visitNode((<TypeReferenceNode>node).typeName, visitor, isEntityName),
|
||||
nodesVisitor((<TypeReferenceNode>node).typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
return updateTypePredicateNode(<TypePredicateNode>node,
|
||||
visitNode((<TypePredicateNode>node).parameterName, visitor),
|
||||
visitNode((<TypePredicateNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
return updateTypeQueryNode((<TypeQueryNode>node), visitNode((<TypeQueryNode>node).exprName, visitor, isEntityName));
|
||||
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return updateTypeLiteralNode((<TypeLiteralNode>node), nodesVisitor((<TypeLiteralNode>node).members, visitor));
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
return updateArrayTypeNode(<ArrayTypeNode>node, visitNode((<ArrayTypeNode>node).elementType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TupleType:
|
||||
return updateTypleTypeNode((<TupleTypeNode>node), nodesVisitor((<TupleTypeNode>node).elementTypes, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
return updateUnionOrIntersectionTypeNode(<UnionOrIntersectionTypeNode>node,
|
||||
nodesVisitor((<UnionOrIntersectionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
Debug.fail("not implemented.");
|
||||
|
||||
case SyntaxKind.TypeOperator:
|
||||
return updateTypeOperatorNode(<TypeOperatorNode>node, visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return updateIndexedAccessTypeNode((<IndexedAccessTypeNode>node),
|
||||
visitNode((<IndexedAccessTypeNode>node).objectType, visitor, isTypeNode),
|
||||
visitNode((<IndexedAccessTypeNode>node).indexType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MappedType:
|
||||
return updateMappedTypeNode((<MappedTypeNode>node),
|
||||
visitNode((<MappedTypeNode>node).readonlyToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).typeParameter, visitor, isTypeParameter),
|
||||
visitNode((<MappedTypeNode>node).questionToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.LiteralType:
|
||||
return updateLiteralTypeNode(<LiteralTypeNode>node,
|
||||
visitNode((<LiteralTypeNode>node).literal, visitor, isExpression));
|
||||
|
||||
// Type Declarations
|
||||
|
||||
case SyntaxKind.TypeParameter:
|
||||
return updateTypeParameterDeclaration(<TypeParameterDeclaration>node,
|
||||
visitNode((<TypeParameterDeclaration>node).name, visitor, isIdentifier),
|
||||
visitNode((<TypeParameterDeclaration>node).constraint, visitor, isTypeNode),
|
||||
visitNode((<TypeParameterDeclaration>node).default, visitor, isTypeNode));
|
||||
|
||||
// Type members
|
||||
// Type elements
|
||||
|
||||
case SyntaxKind.PropertySignature:
|
||||
return updatePropertySignature((<PropertySignature>node),
|
||||
@@ -368,6 +268,14 @@ namespace ts {
|
||||
visitNode((<PropertyDeclaration>node).type, visitor, isTypeNode),
|
||||
visitNode((<PropertyDeclaration>node).initializer, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
return updateMethodSignature(<MethodSignature>node,
|
||||
nodesVisitor((<MethodSignature>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<MethodSignature>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<MethodSignature>node).type, visitor, isTypeNode),
|
||||
visitNode((<MethodSignature>node).name, visitor, isPropertyName),
|
||||
visitNode((<MethodSignature>node).questionToken, tokenVisitor, isToken));
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return updateMethod(<MethodDeclaration>node,
|
||||
nodesVisitor((<MethodDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -404,7 +312,99 @@ namespace ts {
|
||||
visitParameterList((<SetAccessorDeclaration>node).parameters, visitor, context, nodesVisitor),
|
||||
visitFunctionBody((<SetAccessorDeclaration>node).body, visitor, context));
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return updateCallSignature(<CallSignatureDeclaration>node,
|
||||
nodesVisitor((<CallSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<CallSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<CallSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return updateConstructSignature(<ConstructSignatureDeclaration>node,
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
return updateIndexSignature(<IndexSignatureDeclaration>node,
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).modifiers, visitor, isModifier),
|
||||
nodesVisitor((<IndexSignatureDeclaration>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<IndexSignatureDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
// Types
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
return updateTypePredicateNode(<TypePredicateNode>node,
|
||||
visitNode((<TypePredicateNode>node).parameterName, visitor),
|
||||
visitNode((<TypePredicateNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
return updateTypeReferenceNode(<TypeReferenceNode>node,
|
||||
visitNode((<TypeReferenceNode>node).typeName, visitor, isEntityName),
|
||||
nodesVisitor((<TypeReferenceNode>node).typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
return updateFunctionTypeNode(<FunctionTypeNode>node,
|
||||
nodesVisitor((<FunctionTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<FunctionTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<FunctionTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ConstructorType:
|
||||
return updateConstructorTypeNode(<ConstructorTypeNode>node,
|
||||
nodesVisitor((<ConstructorTypeNode>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<ConstructorTypeNode>node).parameters, visitor, isParameterDeclaration),
|
||||
visitNode((<ConstructorTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
return updateTypeQueryNode((<TypeQueryNode>node),
|
||||
visitNode((<TypeQueryNode>node).exprName, visitor, isEntityName));
|
||||
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return updateTypeLiteralNode((<TypeLiteralNode>node),
|
||||
nodesVisitor((<TypeLiteralNode>node).members, visitor, isTypeElement));
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
return updateArrayTypeNode(<ArrayTypeNode>node,
|
||||
visitNode((<ArrayTypeNode>node).elementType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TupleType:
|
||||
return updateTypleTypeNode((<TupleTypeNode>node),
|
||||
nodesVisitor((<TupleTypeNode>node).elementTypes, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.UnionType:
|
||||
return updateUnionTypeNode(<UnionTypeNode>node,
|
||||
nodesVisitor((<UnionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IntersectionType:
|
||||
return updateIntersectionTypeNode(<IntersectionTypeNode>node,
|
||||
nodesVisitor((<IntersectionTypeNode>node).types, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return updateParenthesizedType(<ParenthesizedTypeNode>node,
|
||||
visitNode((<ParenthesizedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeOperator:
|
||||
return updateTypeOperatorNode(<TypeOperatorNode>node,
|
||||
visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return updateIndexedAccessTypeNode((<IndexedAccessTypeNode>node),
|
||||
visitNode((<IndexedAccessTypeNode>node).objectType, visitor, isTypeNode),
|
||||
visitNode((<IndexedAccessTypeNode>node).indexType, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.MappedType:
|
||||
return updateMappedTypeNode((<MappedTypeNode>node),
|
||||
visitNode((<MappedTypeNode>node).readonlyToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).typeParameter, visitor, isTypeParameter),
|
||||
visitNode((<MappedTypeNode>node).questionToken, tokenVisitor, isToken),
|
||||
visitNode((<MappedTypeNode>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.LiteralType:
|
||||
return updateLiteralTypeNode(<LiteralTypeNode>node,
|
||||
visitNode((<LiteralTypeNode>node).literal, visitor, isExpression));
|
||||
|
||||
// Binding patterns
|
||||
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return updateObjectBindingPattern(<ObjectBindingPattern>node,
|
||||
nodesVisitor((<ObjectBindingPattern>node).elements, visitor, isBindingElement));
|
||||
@@ -421,6 +421,7 @@ namespace ts {
|
||||
visitNode((<BindingElement>node).initializer, visitor, isExpression));
|
||||
|
||||
// Expression
|
||||
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return updateArrayLiteral(<ArrayLiteralExpression>node,
|
||||
nodesVisitor((<ArrayLiteralExpression>node).elements, visitor, isExpression));
|
||||
@@ -499,11 +500,6 @@ namespace ts {
|
||||
return updateAwait(<AwaitExpression>node,
|
||||
visitNode((<AwaitExpression>node).expression, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return updateBinary(<BinaryExpression>node,
|
||||
visitNode((<BinaryExpression>node).left, visitor, isExpression),
|
||||
visitNode((<BinaryExpression>node).right, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return updatePrefix(<PrefixUnaryExpression>node,
|
||||
visitNode((<PrefixUnaryExpression>node).operand, visitor, isExpression));
|
||||
@@ -512,6 +508,11 @@ namespace ts {
|
||||
return updatePostfix(<PostfixUnaryExpression>node,
|
||||
visitNode((<PostfixUnaryExpression>node).operand, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return updateBinary(<BinaryExpression>node,
|
||||
visitNode((<BinaryExpression>node).left, visitor, isExpression),
|
||||
visitNode((<BinaryExpression>node).right, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return updateConditional(<ConditionalExpression>node,
|
||||
visitNode((<ConditionalExpression>node).condition, visitor, isExpression),
|
||||
@@ -554,13 +555,19 @@ namespace ts {
|
||||
return updateNonNullExpression(<NonNullExpression>node,
|
||||
visitNode((<NonNullExpression>node).expression, visitor, isExpression));
|
||||
|
||||
case SyntaxKind.MetaProperty:
|
||||
return updateMetaProperty(<MetaProperty>node,
|
||||
visitNode((<MetaProperty>node).name, visitor, isIdentifier));
|
||||
|
||||
// Misc
|
||||
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return updateTemplateSpan(<TemplateSpan>node,
|
||||
visitNode((<TemplateSpan>node).expression, visitor, isExpression),
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateMiddleOrTemplateTail));
|
||||
|
||||
// Element
|
||||
|
||||
case SyntaxKind.Block:
|
||||
return updateBlock(<Block>node,
|
||||
nodesVisitor((<Block>node).statements, visitor, isStatement));
|
||||
@@ -677,6 +684,21 @@ namespace ts {
|
||||
nodesVisitor((<ClassDeclaration>node).heritageClauses, visitor, isHeritageClause),
|
||||
nodesVisitor((<ClassDeclaration>node).members, visitor, isClassElement));
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return updateInterfaceDeclaration(<InterfaceDeclaration>node,
|
||||
nodesVisitor((<InterfaceDeclaration>node).decorators, visitor, isDecorator),
|
||||
nodesVisitor((<InterfaceDeclaration>node).modifiers, visitor, isModifier),
|
||||
visitNode((<InterfaceDeclaration>node).name, visitor, isIdentifier),
|
||||
nodesVisitor((<InterfaceDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
nodesVisitor((<InterfaceDeclaration>node).heritageClauses, visitor, isHeritageClause),
|
||||
nodesVisitor((<InterfaceDeclaration>node).members, visitor, isTypeElement));
|
||||
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return updateTypeAliasDeclaration(<TypeAliasDeclaration>node,
|
||||
visitNode((<TypeAliasDeclaration>node).name, visitor, isIdentifier),
|
||||
nodesVisitor((<TypeAliasDeclaration>node).typeParameters, visitor, isTypeParameter),
|
||||
visitNode((<TypeAliasDeclaration>node).type, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return updateEnumDeclaration(<EnumDeclaration>node,
|
||||
nodesVisitor((<EnumDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -699,6 +721,10 @@ namespace ts {
|
||||
return updateCaseBlock(<CaseBlock>node,
|
||||
nodesVisitor((<CaseBlock>node).clauses, visitor, isCaseOrDefaultClause));
|
||||
|
||||
case SyntaxKind.NamespaceExportDeclaration:
|
||||
return updateNamespaceExportDeclaration(<NamespaceExportDeclaration>node,
|
||||
visitNode((<NamespaceExportDeclaration>node).name, visitor, isIdentifier));
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return updateImportEqualsDeclaration(<ImportEqualsDeclaration>node,
|
||||
nodesVisitor((<ImportEqualsDeclaration>node).decorators, visitor, isDecorator),
|
||||
@@ -754,21 +780,19 @@ namespace ts {
|
||||
visitNode((<ExportSpecifier>node).name, visitor, isIdentifier));
|
||||
|
||||
// Module references
|
||||
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
return updateExternalModuleReference(<ExternalModuleReference>node,
|
||||
visitNode((<ExternalModuleReference>node).expression, visitor, isExpression));
|
||||
|
||||
// JSX
|
||||
|
||||
case SyntaxKind.JsxElement:
|
||||
return updateJsxElement(<JsxElement>node,
|
||||
visitNode((<JsxElement>node).openingElement, visitor, isJsxOpeningElement),
|
||||
nodesVisitor((<JsxElement>node).children, visitor, isJsxChild),
|
||||
visitNode((<JsxElement>node).closingElement, visitor, isJsxClosingElement));
|
||||
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return updateJsxAttributes(<JsxAttributes>node,
|
||||
nodesVisitor((<JsxAttributes>node).properties, visitor, isJsxAttributeLike));
|
||||
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
return updateJsxSelfClosingElement(<JsxSelfClosingElement>node,
|
||||
visitNode((<JsxSelfClosingElement>node).tagName, visitor, isJsxTagNameExpression),
|
||||
@@ -788,6 +812,10 @@ namespace ts {
|
||||
visitNode((<JsxAttribute>node).name, visitor, isIdentifier),
|
||||
visitNode((<JsxAttribute>node).initializer, visitor, isStringLiteralOrJsxExpression));
|
||||
|
||||
case SyntaxKind.JsxAttributes:
|
||||
return updateJsxAttributes(<JsxAttributes>node,
|
||||
nodesVisitor((<JsxAttributes>node).properties, visitor, isJsxAttributeLike));
|
||||
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
return updateJsxSpreadAttribute(<JsxSpreadAttribute>node,
|
||||
visitNode((<JsxSpreadAttribute>node).expression, visitor, isExpression));
|
||||
@@ -797,6 +825,7 @@ namespace ts {
|
||||
visitNode((<JsxExpression>node).expression, visitor, isExpression));
|
||||
|
||||
// Clauses
|
||||
|
||||
case SyntaxKind.CaseClause:
|
||||
return updateCaseClause(<CaseClause>node,
|
||||
visitNode((<CaseClause>node).expression, visitor, isExpression),
|
||||
@@ -816,6 +845,7 @@ namespace ts {
|
||||
visitNode((<CatchClause>node).block, visitor, isBlock));
|
||||
|
||||
// Property assignments
|
||||
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return updatePropertyAssignment(<PropertyAssignment>node,
|
||||
visitNode((<PropertyAssignment>node).name, visitor, isPropertyName),
|
||||
@@ -847,8 +877,10 @@ namespace ts {
|
||||
visitNode((<PartiallyEmittedExpression>node).expression, visitor, isExpression));
|
||||
|
||||
default:
|
||||
// No need to visit nodes with no children.
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -885,7 +917,7 @@ namespace ts {
|
||||
return initial;
|
||||
}
|
||||
|
||||
const reduceNodes: (nodes: NodeArray<Node>, f: (memo: T, node: Node | NodeArray<Node>) => T, initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft;
|
||||
const reduceNodes: (nodes: NodeArray<Node>, f: ((memo: T, node: Node) => T) | ((memo: T, node: NodeArray<Node>) => T), initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft;
|
||||
const cbNodes = cbNodeArray || cbNode;
|
||||
const kind = node.kind;
|
||||
|
||||
@@ -1289,6 +1321,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.JsxAttributes:
|
||||
result = reduceNodes((<JsxAttributes>node).properties, cbNodes, result);
|
||||
break;
|
||||
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
result = reduceNode((<JsxClosingElement>node).tagName, cbNode, result);
|
||||
@@ -1310,7 +1343,7 @@ namespace ts {
|
||||
// Clauses
|
||||
case SyntaxKind.CaseClause:
|
||||
result = reduceNode((<CaseClause>node).expression, cbNode, result);
|
||||
// fall-through
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.DefaultClause:
|
||||
result = reduceNodes((<CaseClause | DefaultClause>node).statements, cbNodes, result);
|
||||
@@ -1344,6 +1377,7 @@ namespace ts {
|
||||
case SyntaxKind.EnumMember:
|
||||
result = reduceNode((<EnumMember>node).name, cbNode, result);
|
||||
result = reduceNode((<EnumMember>node).initializer, cbNode, result);
|
||||
break;
|
||||
|
||||
// Top-level nodes
|
||||
case SyntaxKind.SourceFile:
|
||||
|
||||
@@ -2367,13 +2367,13 @@ namespace FourSlash {
|
||||
|
||||
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
|
||||
const ranges = this.getRanges();
|
||||
if (ranges.length == 0) {
|
||||
if (ranges.length === 0) {
|
||||
this.raiseError("At least one range should be specified in the testfile.");
|
||||
}
|
||||
|
||||
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);
|
||||
|
||||
if (!codeFixes || codeFixes.length == 0) {
|
||||
if (!codeFixes || codeFixes.length === 0) {
|
||||
this.raiseError("No codefixes returned.");
|
||||
}
|
||||
|
||||
@@ -2738,7 +2738,7 @@ namespace FourSlash {
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
|
||||
for (const item of items) {
|
||||
if (item.name === name) {
|
||||
if (documentation != undefined || text !== undefined) {
|
||||
if (documentation !== undefined || text !== undefined) {
|
||||
const details = this.getCompletionEntryDetails(item.name);
|
||||
|
||||
if (documentation !== undefined) {
|
||||
@@ -2989,9 +2989,8 @@ ${code}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
}
|
||||
else if (line == "" || lineLength === 0) {
|
||||
else if (line === "" || lineLength === 0) {
|
||||
// Previously blank lines between fourslash content caused it to be considered as 2 files,
|
||||
// Remove this behavior since it just causes errors now
|
||||
}
|
||||
|
||||
@@ -1940,7 +1940,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
const parentDirectory = IO.directoryName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
if (parentDirectory !== "") {
|
||||
createDirectoryStructure(parentDirectory);
|
||||
}
|
||||
IO.createDirectory(dirName);
|
||||
|
||||
@@ -112,8 +112,7 @@ class ProjectRunner extends RunnerBase {
|
||||
else if (url.indexOf(diskProjectPath) === 0) {
|
||||
// Replace the disk specific path into the project root path
|
||||
url = url.substr(diskProjectPath.length);
|
||||
// TODO: should be '!=='?
|
||||
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
|
||||
if (url.charCodeAt(0) !== ts.CharacterCodes.slash) {
|
||||
url = "/" + url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ namespace Harness.SourceMapRecorder {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceMapMappings.charAt(decodingIndex) == ",") {
|
||||
if (sourceMapMappings.charAt(decodingIndex) === ",") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceMapMappings.charAt(decodingIndex) == ";") {
|
||||
if (sourceMapMappings.charAt(decodingIndex) === ";") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Harness.SourceMapRecorder {
|
||||
}
|
||||
|
||||
while (decodingIndex < sourceMapMappings.length) {
|
||||
if (sourceMapMappings.charAt(decodingIndex) == ";") {
|
||||
if (sourceMapMappings.charAt(decodingIndex) === ";") {
|
||||
// New line
|
||||
decodeOfEncodedMapping.emittedLine++;
|
||||
decodeOfEncodedMapping.emittedColumn = 1;
|
||||
@@ -125,7 +125,7 @@ namespace Harness.SourceMapRecorder {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sourceMapMappings.charAt(decodingIndex) == ",") {
|
||||
if (sourceMapMappings.charAt(decodingIndex) === ",") {
|
||||
// Next entry is on same line - no action needed
|
||||
decodingIndex++;
|
||||
continue;
|
||||
|
||||
@@ -201,14 +201,13 @@ namespace ts {
|
||||
assert.isTrue(diags.length === 1, "one diagnostic expected");
|
||||
assert.isTrue(typeof diags[0].messageText === "string" && ((<string>diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message");
|
||||
|
||||
// assert that import will success once file appear on disk
|
||||
fileMap.set(imported.name, imported);
|
||||
fileExistsCalledForBar = false;
|
||||
rootScriptInfo.editContent(0, root.content.length, `import {y} from "bar"`);
|
||||
|
||||
diags = project.getLanguageService().getSemanticDiagnostics(root.name);
|
||||
assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called");
|
||||
assert.isTrue(diags.length === 0);
|
||||
assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called.");
|
||||
assert.isTrue(diags.length === 0, "The import should succeed once the imported file appears on disk.");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -317,6 +317,29 @@ namespace ts.projectSystem {
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, []);
|
||||
});
|
||||
|
||||
it("should save when compileOnSave is enabled in base tsconfig.json", () => {
|
||||
configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{
|
||||
"extends": "/a/tsconfig.json"
|
||||
}`
|
||||
};
|
||||
|
||||
const configFile2: FileOrFolder = {
|
||||
path: "/a/tsconfig.json",
|
||||
content: `{
|
||||
"compileOnSave": true
|
||||
}`
|
||||
};
|
||||
|
||||
const host = createServerHost([moduleFile1, file1Consumer1, file1Consumer2, configFile2, configFile, libFile]);
|
||||
const typingsInstaller = createTestTypingsInstaller(host);
|
||||
const session = createSession(host, typingsInstaller);
|
||||
|
||||
openFilesForSession([moduleFile1, file1Consumer1], session);
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
|
||||
});
|
||||
|
||||
it("should always return the file itself if '--isolatedModules' is specified", () => {
|
||||
configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
|
||||
@@ -241,6 +241,18 @@ namespace ts {
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("argSynonymForParamTag",
|
||||
`/**
|
||||
* @arg {number} name1 Description
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("argumentSynonymForParamTag",
|
||||
`/**
|
||||
* @argument {number} name1 Description
|
||||
*/`);
|
||||
|
||||
|
||||
parsesCorrectly("templateTag",
|
||||
`/**
|
||||
* @template T
|
||||
|
||||
@@ -1042,7 +1042,7 @@ import b = require("./moduleB");
|
||||
assert.equal(diagnostics1.length, 1, "expected one diagnostic");
|
||||
|
||||
createProgram(names, {}, compilerHost, program1);
|
||||
assert.isTrue(program1.structureIsReused);
|
||||
assert.isTrue(program1.structureIsReused === StructureIsReused.Completely);
|
||||
const diagnostics2 = program1.getFileProcessingDiagnostics().getDiagnostics();
|
||||
assert.equal(diagnostics2.length, 1, "expected one diagnostic");
|
||||
assert.equal(diagnostics1[0].messageText, diagnostics2[0].messageText, "expected one diagnostic");
|
||||
|
||||
@@ -159,12 +159,14 @@ namespace ts {
|
||||
return program;
|
||||
}
|
||||
|
||||
function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) {
|
||||
const texts: NamedSourceText[] = (<ProgramWithSourceTexts>oldProgram).sourceTexts.slice(0);
|
||||
updater(texts);
|
||||
const host = createTestCompilerHost(texts, options.target, oldProgram);
|
||||
function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[]) {
|
||||
if (!newTexts) {
|
||||
newTexts = (<ProgramWithSourceTexts>oldProgram).sourceTexts.slice(0);
|
||||
}
|
||||
updater(newTexts);
|
||||
const host = createTestCompilerHost(newTexts, options.target, oldProgram);
|
||||
const program = <ProgramWithSourceTexts>createProgram(rootNames, options, host, oldProgram);
|
||||
program.sourceTexts = texts;
|
||||
program.sourceTexts = newTexts;
|
||||
program.host = host;
|
||||
return program;
|
||||
}
|
||||
@@ -217,13 +219,15 @@ namespace ts {
|
||||
|
||||
describe("Reuse program structure", () => {
|
||||
const target = ScriptTarget.Latest;
|
||||
const files = [
|
||||
{ name: "a.ts", text: SourceText.New(
|
||||
`
|
||||
const files: NamedSourceText[] = [
|
||||
{
|
||||
name: "a.ts", text: SourceText.New(
|
||||
`
|
||||
/// <reference path='b.ts'/>
|
||||
/// <reference path='non-existing-file.ts'/>
|
||||
/// <reference types="typerefs" />
|
||||
`, "", `var x = 1`) },
|
||||
`, "", `var x = 1`)
|
||||
},
|
||||
{ name: "b.ts", text: SourceText.New(`/// <reference path='c.ts'/>`, "", `var y = 2`) },
|
||||
{ name: "c.ts", text: SourceText.New("", "", `var z = 1;`) },
|
||||
{ name: "types/typerefs/index.d.ts", text: SourceText.New("", "", `declare let z: number;`) },
|
||||
@@ -234,7 +238,7 @@ namespace ts {
|
||||
const program_2 = updateProgram(program_1, ["a.ts"], { target }, files => {
|
||||
files[0].text = files[0].text.updateProgram("var x = 100");
|
||||
});
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely);
|
||||
const program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts"));
|
||||
const program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts"));
|
||||
assert.equal(program1Diagnostics.length, program2Diagnostics.length);
|
||||
@@ -245,7 +249,7 @@ namespace ts {
|
||||
const program_2 = updateProgram(program_1, ["a.ts"], { target }, files => {
|
||||
files[0].text = files[0].text.updateProgram("var x = 100");
|
||||
});
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely);
|
||||
const program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts"));
|
||||
const program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts"));
|
||||
assert.equal(program1Diagnostics.length, program2Diagnostics.length);
|
||||
@@ -259,19 +263,19 @@ namespace ts {
|
||||
`;
|
||||
files[0].text = files[0].text.updateReferences(newReferences);
|
||||
});
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules);
|
||||
});
|
||||
|
||||
it("fails if change affects type references", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
|
||||
updateProgram(program_1, ["a.ts"], { types: ["b"] }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Not);
|
||||
});
|
||||
|
||||
it("succeeds if change doesn't affect type references", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
|
||||
updateProgram(program_1, ["a.ts"], { types: ["a"] }, noop);
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely);
|
||||
});
|
||||
|
||||
it("fails if change affects imports", () => {
|
||||
@@ -279,7 +283,7 @@ namespace ts {
|
||||
updateProgram(program_1, ["a.ts"], { target }, files => {
|
||||
files[2].text = files[2].text.updateImportsAndExports("import x from 'b'");
|
||||
});
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules);
|
||||
});
|
||||
|
||||
it("fails if change affects type directives", () => {
|
||||
@@ -291,25 +295,25 @@ namespace ts {
|
||||
/// <reference types="typerefs1" />`;
|
||||
files[0].text = files[0].text.updateReferences(newReferences);
|
||||
});
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules);
|
||||
});
|
||||
|
||||
it("fails if module kind changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Not);
|
||||
});
|
||||
|
||||
it("fails if rootdir changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Not);
|
||||
});
|
||||
|
||||
it("fails if config path changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Not);
|
||||
});
|
||||
|
||||
it("resolution cache follows imports", () => {
|
||||
@@ -328,7 +332,7 @@ namespace ts {
|
||||
const program_2 = updateProgram(program_1, ["a.ts"], options, files => {
|
||||
files[0].text = files[0].text.updateProgram("var x = 2");
|
||||
});
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely);
|
||||
|
||||
// content of resolution cache should not change
|
||||
checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") }));
|
||||
@@ -338,7 +342,7 @@ namespace ts {
|
||||
const program_3 = updateProgram(program_2, ["a.ts"], options, files => {
|
||||
files[0].text = files[0].text.updateImportsAndExports("");
|
||||
});
|
||||
assert.isTrue(!program_2.structureIsReused);
|
||||
assert.isTrue(program_2.structureIsReused === StructureIsReused.SafeModules);
|
||||
checkResolvedModulesCache(program_3, "a.ts", /*expectedContent*/ undefined);
|
||||
|
||||
const program_4 = updateProgram(program_3, ["a.ts"], options, files => {
|
||||
@@ -347,7 +351,7 @@ namespace ts {
|
||||
`;
|
||||
files[0].text = files[0].text.updateImportsAndExports(newImports);
|
||||
});
|
||||
assert.isTrue(!program_3.structureIsReused);
|
||||
assert.isTrue(program_3.structureIsReused === StructureIsReused.SafeModules);
|
||||
checkResolvedModulesCache(program_4, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts"), "c": undefined }));
|
||||
});
|
||||
|
||||
@@ -365,7 +369,7 @@ namespace ts {
|
||||
const program_2 = updateProgram(program_1, ["/a.ts"], options, files => {
|
||||
files[0].text = files[0].text.updateProgram("var x = 2");
|
||||
});
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely);
|
||||
|
||||
// content of resolution cache should not change
|
||||
checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
|
||||
@@ -376,7 +380,7 @@ namespace ts {
|
||||
files[0].text = files[0].text.updateReferences("");
|
||||
});
|
||||
|
||||
assert.isTrue(!program_2.structureIsReused);
|
||||
assert.isTrue(program_2.structureIsReused === StructureIsReused.SafeModules);
|
||||
checkResolvedTypeDirectivesCache(program_3, "/a.ts", /*expectedContent*/ undefined);
|
||||
|
||||
updateProgram(program_3, ["/a.ts"], options, files => {
|
||||
@@ -385,10 +389,74 @@ namespace ts {
|
||||
`;
|
||||
files[0].text = files[0].text.updateReferences(newReferences);
|
||||
});
|
||||
assert.isTrue(!program_3.structureIsReused);
|
||||
assert.isTrue(program_3.structureIsReused === StructureIsReused.SafeModules);
|
||||
checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
|
||||
});
|
||||
|
||||
it("fetches imports after npm install", () => {
|
||||
const file1Ts = { name: "file1.ts", text: SourceText.New("", `import * as a from "a";`, "const myX: number = a.x;") };
|
||||
const file2Ts = { name: "file2.ts", text: SourceText.New("", "", "") };
|
||||
const indexDTS = { name: "node_modules/a/index.d.ts", text: SourceText.New("", "export declare let x: number;", "") };
|
||||
const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.NodeJs };
|
||||
const rootFiles = [file1Ts, file2Ts];
|
||||
const filesAfterNpmInstall = [file1Ts, file2Ts, indexDTS];
|
||||
|
||||
const initialProgram = newProgram(rootFiles, rootFiles.map(f => f.name), options);
|
||||
{
|
||||
assert.deepEqual(initialProgram.host.getTrace(),
|
||||
[
|
||||
"======== Resolving module 'a' from 'file1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
|
||||
"File 'node_modules/a.ts' does not exist.",
|
||||
"File 'node_modules/a.tsx' does not exist.",
|
||||
"File 'node_modules/a.d.ts' does not exist.",
|
||||
"File 'node_modules/a/package.json' does not exist.",
|
||||
"File 'node_modules/a/index.ts' does not exist.",
|
||||
"File 'node_modules/a/index.tsx' does not exist.",
|
||||
"File 'node_modules/a/index.d.ts' does not exist.",
|
||||
"File 'node_modules/@types/a.d.ts' does not exist.",
|
||||
"File 'node_modules/@types/a/package.json' does not exist.",
|
||||
"File 'node_modules/@types/a/index.d.ts' does not exist.",
|
||||
"Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.",
|
||||
"File 'node_modules/a.js' does not exist.",
|
||||
"File 'node_modules/a.jsx' does not exist.",
|
||||
"File 'node_modules/a/package.json' does not exist.",
|
||||
"File 'node_modules/a/index.js' does not exist.",
|
||||
"File 'node_modules/a/index.jsx' does not exist.",
|
||||
"======== Module name 'a' was not resolved. ========"
|
||||
],
|
||||
"initialProgram: execute module resolution normally.");
|
||||
|
||||
const initialProgramDiagnostics = initialProgram.getSemanticDiagnostics(initialProgram.getSourceFile("file1.ts"));
|
||||
assert(initialProgramDiagnostics.length === 1, `initialProgram: import should fail.`);
|
||||
}
|
||||
|
||||
const afterNpmInstallProgram = updateProgram(initialProgram, rootFiles.map(f => f.name), options, f => {
|
||||
f[1].text = f[1].text.updateReferences(`/// <reference no-default-lib="true"/>`);
|
||||
}, filesAfterNpmInstall);
|
||||
{
|
||||
assert.deepEqual(afterNpmInstallProgram.host.getTrace(),
|
||||
[
|
||||
"======== Resolving module 'a' from 'file1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
|
||||
"File 'node_modules/a.ts' does not exist.",
|
||||
"File 'node_modules/a.tsx' does not exist.",
|
||||
"File 'node_modules/a.d.ts' does not exist.",
|
||||
"File 'node_modules/a/package.json' does not exist.",
|
||||
"File 'node_modules/a/index.ts' does not exist.",
|
||||
"File 'node_modules/a/index.tsx' does not exist.",
|
||||
"File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========"
|
||||
],
|
||||
"afterNpmInstallProgram: execute module resolution normally.");
|
||||
|
||||
const afterNpmInstallProgramDiagnostics = afterNpmInstallProgram.getSemanticDiagnostics(afterNpmInstallProgram.getSourceFile("file1.ts"));
|
||||
assert(afterNpmInstallProgramDiagnostics.length === 0, `afterNpmInstallProgram: program is well-formed with import.`);
|
||||
}
|
||||
});
|
||||
|
||||
it("can reuse ambient module declarations from non-modified files", () => {
|
||||
const files = [
|
||||
{ name: "/a/b/app.ts", text: SourceText.New("", "import * as fs from 'fs'", "") },
|
||||
@@ -468,7 +536,206 @@ namespace ts {
|
||||
"File '/fs.jsx' does not exist.",
|
||||
"======== Module name 'fs' was not resolved. ========",
|
||||
], "should look for 'fs' again since node.d.ts was changed");
|
||||
});
|
||||
|
||||
it("can reuse module resolutions from non-modified files", () => {
|
||||
const files = [
|
||||
{ name: "a1.ts", text: SourceText.New("", "", "let x = 1;") },
|
||||
{ name: "a2.ts", text: SourceText.New("", "", "let x = 1;") },
|
||||
{ name: "b1.ts", text: SourceText.New("", "export class B { x: number; }", "") },
|
||||
{ name: "b2.ts", text: SourceText.New("", "export class B { x: number; }", "") },
|
||||
{ name: "node_modules/@types/typerefs1/index.d.ts", text: SourceText.New("", "", "declare let z: string;") },
|
||||
{ name: "node_modules/@types/typerefs2/index.d.ts", text: SourceText.New("", "", "declare let z: string;") },
|
||||
{
|
||||
name: "f1.ts",
|
||||
text:
|
||||
SourceText.New(
|
||||
`/// <reference path="a1.ts"/>${newLine}/// <reference types="typerefs1"/>${newLine}/// <reference no-default-lib="true"/>`,
|
||||
`import { B } from './b1';${newLine}export let BB = B;`,
|
||||
"declare module './b1' { interface B { y: string; } }")
|
||||
},
|
||||
{
|
||||
name: "f2.ts",
|
||||
text: SourceText.New(
|
||||
`/// <reference path="a2.ts"/>${newLine}/// <reference types="typerefs2"/>`,
|
||||
`import { B } from './b2';${newLine}import { BB } from './f1';`,
|
||||
"(new BB).x; (new BB).y;")
|
||||
},
|
||||
];
|
||||
|
||||
const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.Classic };
|
||||
const program_1 = newProgram(files, files.map(f => f.name), options);
|
||||
let expectedErrors = 0;
|
||||
{
|
||||
assert.deepEqual(program_1.host.getTrace(),
|
||||
[
|
||||
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"======== Resolving module './b2' from 'f2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b2' was successfully resolved to 'b2.ts'. ========",
|
||||
"======== Resolving module './f1' from 'f2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'f1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './f1' was successfully resolved to 'f1.ts'. ========"
|
||||
],
|
||||
"program_1: execute module reoslution normally.");
|
||||
|
||||
const program_1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("f2.ts"));
|
||||
assert(program_1Diagnostics.length === expectedErrors, `initial program should be well-formed`);
|
||||
}
|
||||
const indexOfF1 = 6;
|
||||
const program_2 = updateProgram(program_1, program_1.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateReferences(`/// <reference path="a1.ts"/>${newLine}/// <reference types="typerefs1"/>`);
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_2Diagnostics = program_2.getSemanticDiagnostics(program_2.getSourceFile("f2.ts"));
|
||||
assert(program_2Diagnostics.length === expectedErrors, `removing no-default-lib shouldn't affect any types used.`);
|
||||
|
||||
assert.deepEqual(program_2.host.getTrace(), [
|
||||
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
|
||||
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
|
||||
], "program_2: reuse module resolutions in f2 since it is unchanged");
|
||||
}
|
||||
|
||||
const program_3 = updateProgram(program_2, program_2.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateReferences(`/// <reference path="a1.ts"/>`);
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_3Diagnostics = program_3.getSemanticDiagnostics(program_3.getSourceFile("f2.ts"));
|
||||
assert(program_3Diagnostics.length === expectedErrors, `typerefs2 was unused, so diagnostics should be unaffected.`);
|
||||
|
||||
assert.deepEqual(program_3.host.getTrace(), [
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
|
||||
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
|
||||
], "program_3: reuse module resolutions in f2 since it is unchanged");
|
||||
}
|
||||
|
||||
|
||||
const program_4 = updateProgram(program_3, program_3.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateReferences("");
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_4Diagnostics = program_4.getSemanticDiagnostics(program_4.getSourceFile("f2.ts"));
|
||||
assert(program_4Diagnostics.length === expectedErrors, `a1.ts was unused, so diagnostics should be unaffected.`);
|
||||
|
||||
assert.deepEqual(program_4.host.getTrace(), [
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
|
||||
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
|
||||
], "program_4: reuse module resolutions in f2 since it is unchanged");
|
||||
}
|
||||
|
||||
const program_5 = updateProgram(program_4, program_4.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateImportsAndExports(`import { B } from './b1';`);
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_5Diagnostics = program_5.getSemanticDiagnostics(program_5.getSourceFile("f2.ts"));
|
||||
assert(program_5Diagnostics.length === ++expectedErrors, `import of BB in f1 fails. BB is of type any. Add one error`);
|
||||
|
||||
assert.deepEqual(program_5.host.getTrace(), [
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========"
|
||||
], "program_5: exports do not affect program structure, so f2's resolutions are silently reused.");
|
||||
}
|
||||
|
||||
const program_6 = updateProgram(program_5, program_5.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateProgram("");
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_6Diagnostics = program_6.getSemanticDiagnostics(program_6.getSourceFile("f2.ts"));
|
||||
assert(program_6Diagnostics.length === expectedErrors, `import of BB in f1 fails.`);
|
||||
|
||||
assert.deepEqual(program_6.host.getTrace(), [
|
||||
"======== Resolving module './b1' from 'f1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'b1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
|
||||
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
|
||||
], "program_6: reuse module resolutions in f2 since it is unchanged");
|
||||
}
|
||||
|
||||
const program_7 = updateProgram(program_6, program_6.getRootFileNames(), options, f => {
|
||||
const newSourceText = f[indexOfF1].text.updateImportsAndExports("");
|
||||
f[indexOfF1] = { name: "f1.ts", text: newSourceText };
|
||||
});
|
||||
|
||||
{
|
||||
const program_7Diagnostics = program_7.getSemanticDiagnostics(program_7.getSourceFile("f2.ts"));
|
||||
assert(program_7Diagnostics.length === expectedErrors, `removing import is noop with respect to program, so no change in diagnostics.`);
|
||||
|
||||
assert.deepEqual(program_7.host.getTrace(), [
|
||||
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
|
||||
"Resolving with primary search path 'node_modules/@types'.",
|
||||
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
|
||||
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
|
||||
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
|
||||
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
|
||||
], "program_7 should reuse module resolutions in f2 since it is unchanged");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -3,41 +3,77 @@
|
||||
|
||||
namespace ts {
|
||||
describe("TransformAPI", () => {
|
||||
function transformsCorrectly(name: string, source: string, transformers: TransformerFactory<SourceFile>[]) {
|
||||
it(name, () => {
|
||||
Harness.Baseline.runBaseline(`transformApi/transformsCorrectly.${name}.js`, () => {
|
||||
const transformed = transform(createSourceFile("source.ts", source, ScriptTarget.ES2015), transformers);
|
||||
const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, {
|
||||
onEmitNode: transformed.emitNodeWithNotification,
|
||||
substituteNode: transformed.substituteNode
|
||||
});
|
||||
const result = printer.printBundle(createBundle(transformed.transformed));
|
||||
transformed.dispose();
|
||||
return result;
|
||||
});
|
||||
function replaceUndefinedWithVoid0(context: ts.TransformationContext) {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
context.onSubstituteNode = (hint, node) => {
|
||||
node = previousOnSubstituteNode(hint, node);
|
||||
if (hint === EmitHint.Expression && node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "undefined") {
|
||||
node = createPartiallyEmittedExpression(
|
||||
addSyntheticTrailingComment(
|
||||
setTextRange(
|
||||
createVoidZero(),
|
||||
node),
|
||||
SyntaxKind.MultiLineCommentTrivia, "undefined"));
|
||||
}
|
||||
return node;
|
||||
};
|
||||
return (file: ts.SourceFile) => file;
|
||||
}
|
||||
|
||||
function replaceIdentifiersNamedOldNameWithNewName(context: ts.TransformationContext) {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
context.onSubstituteNode = (hint, node) => {
|
||||
node = previousOnSubstituteNode(hint, node);
|
||||
if (node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "oldName") {
|
||||
node = setTextRange(createIdentifier("newName"), node);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
return (file: ts.SourceFile) => file;
|
||||
}
|
||||
|
||||
function transformSourceFile(sourceText: string, transformers: TransformerFactory<SourceFile>[]) {
|
||||
const transformed = transform(createSourceFile("source.ts", sourceText, ScriptTarget.ES2015), transformers);
|
||||
const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, {
|
||||
onEmitNode: transformed.emitNodeWithNotification,
|
||||
substituteNode: transformed.substituteNode
|
||||
});
|
||||
const result = printer.printBundle(createBundle(transformed.transformed));
|
||||
transformed.dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
function testBaseline(testName: string, test: () => string) {
|
||||
it(testName, () => {
|
||||
Harness.Baseline.runBaseline(`transformApi/transformsCorrectly.${testName}.js`, test);
|
||||
});
|
||||
}
|
||||
|
||||
transformsCorrectly("substitution", `
|
||||
var a = undefined;
|
||||
`, [
|
||||
context => {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
context.onSubstituteNode = (hint, node) => {
|
||||
node = previousOnSubstituteNode(hint, node);
|
||||
if (hint === EmitHint.Expression && node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "undefined") {
|
||||
node = createPartiallyEmittedExpression(
|
||||
addSyntheticTrailingComment(
|
||||
setTextRange(
|
||||
createVoidZero(),
|
||||
node),
|
||||
SyntaxKind.MultiLineCommentTrivia, "undefined"));
|
||||
}
|
||||
return node;
|
||||
};
|
||||
return file => file;
|
||||
}
|
||||
]);
|
||||
testBaseline("substitution", () => {
|
||||
return transformSourceFile(`var a = undefined;`, [replaceUndefinedWithVoid0]);
|
||||
});
|
||||
|
||||
testBaseline("types", () => {
|
||||
return transformSourceFile(`let a: () => void`, [
|
||||
context => file => visitNode(file, function visitor(node: Node): VisitResult<Node> {
|
||||
return visitEachChild(node, visitor, context);
|
||||
})
|
||||
]);
|
||||
});
|
||||
|
||||
testBaseline("fromTranspileModule", () => {
|
||||
return ts.transpileModule(`var oldName = undefined;`, {
|
||||
transformers: {
|
||||
before: [replaceUndefinedWithVoid0],
|
||||
after: [replaceIdentifiersNamedOldNameWithNewName]
|
||||
},
|
||||
compilerOptions: {
|
||||
newLine: NewLineKind.CarriageReturnLineFeed
|
||||
}
|
||||
}).outputText;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3204,6 +3204,122 @@ namespace ts.projectSystem {
|
||||
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 0);
|
||||
});
|
||||
|
||||
it("should not report bind errors for declaration files with skipLibCheck=true", () => {
|
||||
const jsconfigFile = {
|
||||
path: "/a/jsconfig.json",
|
||||
content: "{}"
|
||||
};
|
||||
const jsFile = {
|
||||
path: "/a/jsFile.js",
|
||||
content: "let x = 1;"
|
||||
};
|
||||
const dTsFile1 = {
|
||||
path: "/a/dTsFile1.d.ts",
|
||||
content: `
|
||||
declare var x: number;`
|
||||
};
|
||||
const dTsFile2 = {
|
||||
path: "/a/dTsFile2.d.ts",
|
||||
content: `
|
||||
declare var x: string;`
|
||||
};
|
||||
const host = createServerHost([jsconfigFile, jsFile, dTsFile1, dTsFile2]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([jsFile], session);
|
||||
|
||||
const dTsFile1GetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: dTsFile1.path }
|
||||
);
|
||||
const error1Result = <protocol.Diagnostic[]>session.executeCommand(dTsFile1GetErrRequest).response;
|
||||
assert.isTrue(error1Result.length === 0);
|
||||
|
||||
const dTsFile2GetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: dTsFile2.path }
|
||||
);
|
||||
const error2Result = <protocol.Diagnostic[]>session.executeCommand(dTsFile2GetErrRequest).response;
|
||||
assert.isTrue(error2Result.length === 0);
|
||||
});
|
||||
|
||||
it("should report semanitc errors for loose JS files with '// @ts-check' and skipLibCheck=true", () => {
|
||||
const jsFile = {
|
||||
path: "/a/jsFile.js",
|
||||
content: `
|
||||
// @ts-check
|
||||
let x = 1;
|
||||
x === "string";`
|
||||
};
|
||||
|
||||
const host = createServerHost([jsFile]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([jsFile], session);
|
||||
|
||||
const getErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: jsFile.path }
|
||||
);
|
||||
const errorResult = <protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code);
|
||||
});
|
||||
|
||||
it("should report semanitc errors for configured js project with '// @ts-check' and skipLibCheck=true", () => {
|
||||
const jsconfigFile = {
|
||||
path: "/a/jsconfig.json",
|
||||
content: "{}"
|
||||
};
|
||||
|
||||
const jsFile = {
|
||||
path: "/a/jsFile.js",
|
||||
content: `
|
||||
// @ts-check
|
||||
let x = 1;
|
||||
x === "string";`
|
||||
};
|
||||
|
||||
const host = createServerHost([jsconfigFile, jsFile]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([jsFile], session);
|
||||
|
||||
const getErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: jsFile.path }
|
||||
);
|
||||
const errorResult = <protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code);
|
||||
});
|
||||
|
||||
it("should report semanitc errors for configured js project with checkJs=true and skipLibCheck=true", () => {
|
||||
const jsconfigFile = {
|
||||
path: "/a/jsconfig.json",
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
checkJs: true,
|
||||
skipLibCheck: true
|
||||
},
|
||||
})
|
||||
};
|
||||
const jsFile = {
|
||||
path: "/a/jsFile.js",
|
||||
content: `let x = 1;
|
||||
x === "string";`
|
||||
};
|
||||
|
||||
const host = createServerHost([jsconfigFile, jsFile]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([jsFile], session);
|
||||
|
||||
const getErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: jsFile.path }
|
||||
);
|
||||
const errorResult = <protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 1);
|
||||
assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code);
|
||||
});
|
||||
});
|
||||
|
||||
describe("non-existing directories listed in config file input array", () => {
|
||||
@@ -3228,7 +3344,7 @@ namespace ts.projectSystem {
|
||||
checkNumberOfInferredProjects(projectService, 1);
|
||||
|
||||
const configuredProject = projectService.configuredProjects[0];
|
||||
assert.isTrue(configuredProject.getFileNames().length == 0);
|
||||
assert.isTrue(configuredProject.getFileNames().length === 0);
|
||||
|
||||
const inferredProject = projectService.inferredProjects[0];
|
||||
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
|
||||
@@ -3493,6 +3609,30 @@ namespace ts.projectSystem {
|
||||
});
|
||||
});
|
||||
|
||||
describe("searching for config file", () => {
|
||||
it("should stop at projectRootPath if given", () => {
|
||||
const f1 = {
|
||||
path: "/a/file1.ts",
|
||||
content: ""
|
||||
};
|
||||
const configFile = {
|
||||
path: "/tsconfig.json",
|
||||
content: "{}"
|
||||
};
|
||||
const host = createServerHost([f1, configFile]);
|
||||
const service = createProjectService(host);
|
||||
service.openClientFile(f1.path, /*fileContent*/ undefined, /*scriptKind*/ undefined, "/a");
|
||||
|
||||
checkNumberOfConfiguredProjects(service, 0);
|
||||
checkNumberOfInferredProjects(service, 1);
|
||||
|
||||
service.closeClientFile(f1.path);
|
||||
service.openClientFile(f1.path);
|
||||
checkNumberOfConfiguredProjects(service, 1);
|
||||
checkNumberOfInferredProjects(service, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("cancellationToken", () => {
|
||||
it("is attached to request", () => {
|
||||
const f1 = {
|
||||
|
||||
@@ -278,7 +278,7 @@ and grew 1cm per day`;
|
||||
const insertString = testContent.substring(rsa[i], rsa[i] + las[i]);
|
||||
svc.edit(ersa[i], elas[i], insertString);
|
||||
checkText = editFlat(ersa[i], elas[i], insertString, checkText);
|
||||
if (0 == (i % 4)) {
|
||||
if (0 === (i % 4)) {
|
||||
const snap = svc.getSnapshot();
|
||||
const snapText = snap.getText(0, checkText.length);
|
||||
assert.equal(checkText, snapText);
|
||||
|
||||
Vendored
+35
@@ -21,6 +21,22 @@ interface FormData {
|
||||
[Symbol.iterator](): IterableIterator<string | File>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all key/value pairs contained in this object.
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all keys f the key/value pairs contained in this object.
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
@@ -70,3 +86,22 @@ interface NodeListOf<TNode extends Node> {
|
||||
|
||||
[Symbol.iterator](): IterableIterator<TNode>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the search params
|
||||
*/
|
||||
entries(): IterableIterator<[string, string]>;
|
||||
/**
|
||||
* Returns a list of keys in the search params
|
||||
*/
|
||||
keys(): IterableIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the search params
|
||||
*/
|
||||
values(): IterableIterator<string>;
|
||||
/**
|
||||
* iterate over key/value pairs
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<[string, string]>;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -58,7 +58,7 @@ interface ReadonlySet<T> {
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakSet<T extends object> {
|
||||
interface WeakSet<T> {
|
||||
add(value: T): this;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
|
||||
Vendored
+72
-8
@@ -32,17 +32,17 @@ interface Array<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -66,21 +66,21 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
@@ -91,9 +91,42 @@ interface IArguments {
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
@@ -108,9 +141,40 @@ interface WeakMapConstructor {
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set,
|
||||
*/
|
||||
keys(): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
@@ -118,7 +182,7 @@ interface SetConstructor {
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T extends object> { }
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T extends object>(iterable: Iterable<T>): WeakSet<T>;
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ interface ProxyHandler<T extends object> {
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
|
||||
Vendored
+1
-1
@@ -118,7 +118,7 @@ interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface WeakSet<T extends object> {
|
||||
interface WeakSet<T> {
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-64
@@ -1742,13 +1742,6 @@ interface Int8Array {
|
||||
*/
|
||||
reverse(): Int8Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -2033,13 +2026,6 @@ interface Uint8Array {
|
||||
*/
|
||||
reverse(): Uint8Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -2325,19 +2311,12 @@ interface Uint8ClampedArray {
|
||||
*/
|
||||
reverse(): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
* @param offset The index in the current array at which the values are to be written.
|
||||
*/
|
||||
set(array: Uint8ClampedArray, offset?: number): void;
|
||||
set(array: ArrayLike<number>, offset?: number): void;
|
||||
|
||||
/**
|
||||
* Returns a section of an array.
|
||||
@@ -2616,13 +2595,6 @@ interface Int16Array {
|
||||
*/
|
||||
reverse(): Int16Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -2908,13 +2880,6 @@ interface Uint16Array {
|
||||
*/
|
||||
reverse(): Uint16Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -3199,13 +3164,6 @@ interface Int32Array {
|
||||
*/
|
||||
reverse(): Int32Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -3490,13 +3448,6 @@ interface Uint32Array {
|
||||
*/
|
||||
reverse(): Uint32Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -3781,13 +3732,6 @@ interface Float32Array {
|
||||
*/
|
||||
reverse(): Float32Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
@@ -4073,13 +4017,6 @@ interface Float64Array {
|
||||
*/
|
||||
reverse(): Float64Array;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param index The index of the location to set.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
set(index: number, value: number): void;
|
||||
|
||||
/**
|
||||
* Sets a value or an array of values.
|
||||
* @param array A typed or untyped array of values to set.
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace ts.server {
|
||||
startWatchingContainingDirectoriesForFile(fileName: string, project: InferredProject, callback: (fileName: string) => void) {
|
||||
let currentPath = getDirectoryPath(fileName);
|
||||
let parentPath = getDirectoryPath(currentPath);
|
||||
while (currentPath != parentPath) {
|
||||
while (currentPath !== parentPath) {
|
||||
if (!this.directoryWatchersForTsconfig.has(currentPath)) {
|
||||
this.projectService.logger.info(`Add watcher for: ${currentPath}`);
|
||||
this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback));
|
||||
@@ -618,7 +618,7 @@ namespace ts.server {
|
||||
*/
|
||||
private onConfigFileAddedForInferredProject(fileName: string) {
|
||||
// TODO: check directory separators
|
||||
if (getBaseFileName(fileName) != "tsconfig.json") {
|
||||
if (getBaseFileName(fileName) !== "tsconfig.json") {
|
||||
this.logger.info(`${fileName} is not tsconfig.json`);
|
||||
return;
|
||||
}
|
||||
@@ -787,12 +787,12 @@ namespace ts.server {
|
||||
* we first detect if there is already a configured project created for it: if so, we re-read
|
||||
* the tsconfig file content and update the project; otherwise we create a new one.
|
||||
*/
|
||||
private openOrUpdateConfiguredProjectForFile(fileName: NormalizedPath): OpenConfiguredProjectResult {
|
||||
private openOrUpdateConfiguredProjectForFile(fileName: NormalizedPath, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
|
||||
const searchPath = getDirectoryPath(fileName);
|
||||
this.logger.info(`Search path: ${searchPath}`);
|
||||
|
||||
// check if this file is already included in one of external projects
|
||||
const configFileName = this.findConfigFile(asNormalizedPath(searchPath));
|
||||
const configFileName = this.findConfigFile(asNormalizedPath(searchPath), projectRootPath);
|
||||
if (!configFileName) {
|
||||
this.logger.info("No config files found.");
|
||||
return {};
|
||||
@@ -826,8 +826,8 @@ namespace ts.server {
|
||||
// current directory (the directory in which tsc was invoked).
|
||||
// The server must start searching from the directory containing
|
||||
// the newly opened file.
|
||||
private findConfigFile(searchPath: NormalizedPath): NormalizedPath {
|
||||
while (true) {
|
||||
private findConfigFile(searchPath: NormalizedPath, projectRootPath?: NormalizedPath): NormalizedPath {
|
||||
while (!projectRootPath || searchPath.indexOf(projectRootPath) >= 0) {
|
||||
const tsconfigFileName = asNormalizedPath(combinePaths(searchPath, "tsconfig.json"));
|
||||
if (this.host.fileExists(tsconfigFileName)) {
|
||||
return tsconfigFileName;
|
||||
@@ -1027,7 +1027,7 @@ namespace ts.server {
|
||||
const scriptKind = propertyReader.getScriptKind(f);
|
||||
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName == rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
|
||||
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName === rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
|
||||
project.addRoot(info);
|
||||
}
|
||||
else {
|
||||
@@ -1320,17 +1320,17 @@ namespace ts.server {
|
||||
* @param filename is absolute pathname
|
||||
* @param fileContent is a known version of the file content that is more up to date than the one on disk
|
||||
*/
|
||||
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult {
|
||||
return this.openClientFileWithNormalizedPath(toNormalizedPath(fileName), fileContent, scriptKind);
|
||||
openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult {
|
||||
return this.openClientFileWithNormalizedPath(toNormalizedPath(fileName), fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath ? toNormalizedPath(projectRootPath) : undefined);
|
||||
}
|
||||
|
||||
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult {
|
||||
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
|
||||
let configFileName: NormalizedPath;
|
||||
let configFileErrors: Diagnostic[];
|
||||
|
||||
let project: ConfiguredProject | ExternalProject = this.findContainingExternalProject(fileName);
|
||||
if (!project) {
|
||||
({ configFileName, configFileErrors } = this.openOrUpdateConfiguredProjectForFile(fileName));
|
||||
({ configFileName, configFileErrors } = this.openOrUpdateConfiguredProjectForFile(fileName, projectRootPath));
|
||||
if (configFileName) {
|
||||
project = this.findConfiguredProjectByProjectName(configFileName);
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ namespace ts.server {
|
||||
// bump up the version if
|
||||
// - oldProgram is not set - this is a first time updateGraph is called
|
||||
// - newProgram is different from the old program and structure of the old program was not reused.
|
||||
if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) {
|
||||
if (!oldProgram || (this.program !== oldProgram && !(oldProgram.structureIsReused & StructureIsReused.Completely))) {
|
||||
hasChanges = true;
|
||||
if (oldProgram) {
|
||||
for (const f of oldProgram.getSourceFiles()) {
|
||||
@@ -643,7 +643,7 @@ namespace ts.server {
|
||||
// check if requested version is the same that we have reported last time
|
||||
if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) {
|
||||
// if current structure version is the same - return info without any changes
|
||||
if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) {
|
||||
if (this.projectStructureVersion === this.lastReportedVersion && !updatedFileNames) {
|
||||
return { info, projectErrors: this.projectErrors };
|
||||
}
|
||||
// compute and return the difference
|
||||
|
||||
@@ -1045,6 +1045,11 @@ namespace ts.server.protocol {
|
||||
* "TS", "JS", "TSX", "JSX"
|
||||
*/
|
||||
scriptKindName?: ScriptKindName;
|
||||
/**
|
||||
* Used to limit the searching for project config file. If given the searching will stop at this
|
||||
* root path; otherwise it will go all the way up to the dist root path.
|
||||
*/
|
||||
projectRootPath?: string;
|
||||
}
|
||||
|
||||
export type ScriptKindName = "TS" | "JS" | "TSX" | "JSX";
|
||||
@@ -1823,10 +1828,20 @@ namespace ts.server.protocol {
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The category of the diagnostic message, e.g. "error" vs. "warning"
|
||||
*/
|
||||
category: string;
|
||||
|
||||
/**
|
||||
* The error code of the diagnostic message.
|
||||
*/
|
||||
code?: number;
|
||||
|
||||
/**
|
||||
* The name of the plugin reporting the message.
|
||||
*/
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export interface DiagnosticWithFileName extends Diagnostic {
|
||||
@@ -2273,15 +2288,19 @@ namespace ts.server.protocol {
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
allowUnusedLabels?: boolean;
|
||||
alwaysStrict?: boolean;
|
||||
baseUrl?: string;
|
||||
charset?: string;
|
||||
checkJs?: boolean;
|
||||
declaration?: boolean;
|
||||
declarationDir?: string;
|
||||
disableSizeLimit?: boolean;
|
||||
downlevelIteration?: boolean;
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
importHelpers?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
@@ -2321,6 +2340,7 @@ namespace ts.server.protocol {
|
||||
skipDefaultLibCheck?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
strict?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace ts.server {
|
||||
const lm = LineIndex.linesFromText(insertedText);
|
||||
const lines = lm.lines;
|
||||
if (lines.length > 1) {
|
||||
if (lines[lines.length - 1] == "") {
|
||||
if (lines[lines.length - 1] === "") {
|
||||
lines.length--;
|
||||
}
|
||||
}
|
||||
@@ -570,7 +570,7 @@ namespace ts.server {
|
||||
}
|
||||
if (this.checkEdits) {
|
||||
const updatedText = this.getText(0, this.root.charCount());
|
||||
Debug.assert(checkText == updatedText, "buffer edit mismatch");
|
||||
Debug.assert(checkText === updatedText, "buffer edit mismatch");
|
||||
}
|
||||
return walker.lineIndex;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
this.projectService.updateTypingsForProject(response);
|
||||
if (response.kind == ActionSet && this.socket) {
|
||||
if (response.kind === ActionSet && this.socket) {
|
||||
this.sendEvent(0, "setTypings", response);
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,9 @@ namespace ts.server {
|
||||
byteLength: Buffer.byteLength,
|
||||
hrtime: process.hrtime,
|
||||
logger,
|
||||
canUseEvents});
|
||||
canUseEvents,
|
||||
globalPlugins: options.globalPlugins,
|
||||
pluginProbeLocations: options.pluginProbeLocations});
|
||||
|
||||
if (telemetryEnabled && typingsInstaller) {
|
||||
typingsInstaller.setTelemetrySender(this);
|
||||
@@ -706,12 +708,11 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
sys.require = (initialDir: string, moduleName: string): RequireResult => {
|
||||
const result = nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, /*cache*/ undefined, /*jsOnly*/ true);
|
||||
try {
|
||||
return { module: require(result.resolvedModule.resolvedFileName), error: undefined };
|
||||
return { module: require(resolveJavaScriptModule(moduleName, initialDir, sys)), error: undefined };
|
||||
}
|
||||
catch (e) {
|
||||
return { module: undefined, error: e };
|
||||
catch (error) {
|
||||
return { module: undefined, error };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+41
-21
@@ -25,15 +25,26 @@ namespace ts.server {
|
||||
return ((1e9 * seconds) + nanoseconds) / 1000000.0;
|
||||
}
|
||||
|
||||
function shouldSkipSemanticCheck(project: Project) {
|
||||
if (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) {
|
||||
return project.isJsOnlyProject();
|
||||
}
|
||||
else {
|
||||
// For configured projects, require that skipLibCheck be set also
|
||||
const options = project.getCompilerOptions();
|
||||
return options.skipLibCheck && !options.checkJs && project.isJsOnlyProject();
|
||||
function isDeclarationFileInJSOnlyNonConfiguredProject(project: Project, file: NormalizedPath) {
|
||||
// Checking for semantic diagnostics is an expensive process. We want to avoid it if we
|
||||
// know for sure it is not needed.
|
||||
// For instance, .d.ts files injected by ATA automatically do not produce any relevant
|
||||
// errors to a JS- only project.
|
||||
//
|
||||
// Note that configured projects can set skipLibCheck (on by default in jsconfig.json) to
|
||||
// disable checking for declaration files. We only need to verify for inferred projects (e.g.
|
||||
// miscellaneous context in VS) and external projects(e.g.VS.csproj project) with only JS
|
||||
// files.
|
||||
//
|
||||
// We still want to check .js files in a JS-only inferred or external project (e.g. if the
|
||||
// file has '// @ts-check').
|
||||
|
||||
if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) &&
|
||||
project.isJsOnlyProject()) {
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
return scriptInfo && !scriptInfo.isJavaScript();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
interface FileStart {
|
||||
@@ -49,7 +60,7 @@ namespace ts.server {
|
||||
if (a.file < b.file) {
|
||||
return -1;
|
||||
}
|
||||
else if (a.file == b.file) {
|
||||
else if (a.file === b.file) {
|
||||
const n = compareNumber(a.start.line, b.start.line);
|
||||
if (n === 0) {
|
||||
return compareNumber(a.start.offset, b.start.offset);
|
||||
@@ -67,7 +78,9 @@ namespace ts.server {
|
||||
start: scriptInfo.positionToLineOffset(diag.start),
|
||||
end: scriptInfo.positionToLineOffset(diag.start + diag.length),
|
||||
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
|
||||
code: diag.code
|
||||
code: diag.code,
|
||||
category: DiagnosticCategory[diag.category].toLowerCase(),
|
||||
source: diag.source
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +94,9 @@ namespace ts.server {
|
||||
end: diag.file && convertToILineInfo(getLineAndCharacterOfPosition(diag.file, diag.start + diag.length)),
|
||||
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"),
|
||||
code: diag.code,
|
||||
fileName: diag.file && diag.file.fileName
|
||||
category: DiagnosticCategory[diag.category].toLowerCase(),
|
||||
fileName: diag.file && diag.file.fileName,
|
||||
source: diag.source
|
||||
};
|
||||
}
|
||||
|
||||
@@ -520,7 +535,7 @@ namespace ts.server {
|
||||
private semanticCheck(file: NormalizedPath, project: Project) {
|
||||
try {
|
||||
let diags: Diagnostic[] = [];
|
||||
if (!shouldSkipSemanticCheck(project)) {
|
||||
if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) {
|
||||
diags = project.getLanguageService().getSemanticDiagnostics(file);
|
||||
}
|
||||
|
||||
@@ -634,6 +649,7 @@ namespace ts.server {
|
||||
length: d.length,
|
||||
category: DiagnosticCategory[d.category].toLowerCase(),
|
||||
code: d.code,
|
||||
source: d.source,
|
||||
startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start),
|
||||
endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length)
|
||||
});
|
||||
@@ -641,7 +657,7 @@ namespace ts.server {
|
||||
|
||||
private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) {
|
||||
const { project, file } = this.getFileAndProject(args);
|
||||
if (isSemantic && shouldSkipSemanticCheck(project)) {
|
||||
if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) {
|
||||
return [];
|
||||
}
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
@@ -1023,8 +1039,8 @@ namespace ts.server {
|
||||
* @param fileName is the name of the file to be opened
|
||||
* @param fileContent is a version of the file content that is known to be more up to date than the one on disk
|
||||
*/
|
||||
private openClientFile(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind) {
|
||||
const { configFileName, configFileErrors } = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind);
|
||||
private openClientFile(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: NormalizedPath) {
|
||||
const { configFileName, configFileErrors } = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath);
|
||||
if (this.eventHandler) {
|
||||
this.eventHandler({
|
||||
eventName: "configFileDiag",
|
||||
@@ -1172,7 +1188,7 @@ namespace ts.server {
|
||||
// getFormattingEditsAfterKeystroke either empty or pertaining
|
||||
// only to the previous line. If all this is true, then
|
||||
// add edits necessary to properly indent the current line.
|
||||
if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
|
||||
if ((args.key === "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
|
||||
const lineInfo = scriptInfo.getLineInfo(args.line);
|
||||
if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) {
|
||||
const lineText = lineInfo.leaf.text;
|
||||
@@ -1181,10 +1197,10 @@ namespace ts.server {
|
||||
let hasIndent = 0;
|
||||
let i: number, len: number;
|
||||
for (i = 0, len = lineText.length; i < len; i++) {
|
||||
if (lineText.charAt(i) == " ") {
|
||||
if (lineText.charAt(i) === " ") {
|
||||
hasIndent++;
|
||||
}
|
||||
else if (lineText.charAt(i) == "\t") {
|
||||
else if (lineText.charAt(i) === "\t") {
|
||||
hasIndent += formatOptions.tabSize;
|
||||
}
|
||||
else {
|
||||
@@ -1587,7 +1603,7 @@ namespace ts.server {
|
||||
const normalizedFileName = toNormalizedPath(fileName);
|
||||
const project = this.projectService.getDefaultProjectForFile(normalizedFileName, /*refreshInferredProjects*/ true);
|
||||
for (const fileNameInProject of fileNamesInProject) {
|
||||
if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName))
|
||||
if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName))
|
||||
highPriorityFiles.push(fileNameInProject);
|
||||
else {
|
||||
const info = this.projectService.getScriptInfo(fileNameInProject);
|
||||
@@ -1608,7 +1624,7 @@ namespace ts.server {
|
||||
const checkList = fileNamesInProject.map(fileName => ({ fileName, project }));
|
||||
// Project level error analysis runs on background files too, therefore
|
||||
// doesn't require the file to be opened
|
||||
this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n == this.changeSeq, delay, 200, /*requireOpen*/ false);
|
||||
this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n === this.changeSeq, delay, 200, /*requireOpen*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1717,7 +1733,11 @@ namespace ts.server {
|
||||
return this.requiredResponse(this.getRenameInfo(request.arguments));
|
||||
},
|
||||
[CommandNames.Open]: (request: protocol.OpenRequest) => {
|
||||
this.openClientFile(toNormalizedPath(request.arguments.file), request.arguments.fileContent, convertScriptKindName(request.arguments.scriptKindName));
|
||||
this.openClientFile(
|
||||
toNormalizedPath(request.arguments.file),
|
||||
request.arguments.fileContent,
|
||||
convertScriptKindName(request.arguments.scriptKindName),
|
||||
request.arguments.projectRootPath ? toNormalizedPath(request.arguments.projectRootPath) : undefined);
|
||||
return this.notRequired();
|
||||
},
|
||||
[CommandNames.Quickinfo]: (request: protocol.QuickInfoRequest) => {
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace ts.server {
|
||||
|
||||
function compilerOptionsChanged(opt1: CompilerOptions, opt2: CompilerOptions): boolean {
|
||||
// TODO: add more relevant properties
|
||||
return opt1.allowJs != opt2.allowJs;
|
||||
return opt1.allowJs !== opt2.allowJs;
|
||||
}
|
||||
|
||||
function unresolvedImportsChanged(imports1: SortedReadonlyArray<string>, imports2: SortedReadonlyArray<string>): boolean {
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ts.server.typingsInstaller {
|
||||
}
|
||||
|
||||
function getNPMLocation(processName: string) {
|
||||
if (path.basename(processName).indexOf("node") == 0) {
|
||||
if (path.basename(processName).indexOf("node") === 0) {
|
||||
return `"${path.join(path.dirname(process.argv[0]), "npm")}"`;
|
||||
}
|
||||
else {
|
||||
@@ -96,6 +96,9 @@ namespace ts.server.typingsInstaller {
|
||||
this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`);
|
||||
}
|
||||
this.execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" });
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Updated ${TypesRegistryPackageName} npm package`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (this.log.isEnabled()) {
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
public scheduleCollect() {
|
||||
if (!this.host.gc || this.timerId != undefined) {
|
||||
if (!this.host.gc || this.timerId !== undefined) {
|
||||
// no global.gc or collection was already scheduled - skip this request
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace ts.BreakpointResolver {
|
||||
if (isFunctionBlock(node)) {
|
||||
return spanInFunctionBlock(<Block>node);
|
||||
}
|
||||
// Fall through
|
||||
// falls through
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return spanInBlock(<Block>node);
|
||||
|
||||
@@ -186,6 +186,7 @@ namespace ts.BreakpointResolver {
|
||||
if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
@@ -264,7 +265,7 @@ namespace ts.BreakpointResolver {
|
||||
// a or ...c or d: x from
|
||||
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
|
||||
if ((node.kind === SyntaxKind.Identifier ||
|
||||
node.kind == SyntaxKind.SpreadElement ||
|
||||
node.kind === SyntaxKind.SpreadElement ||
|
||||
node.kind === SyntaxKind.PropertyAssignment ||
|
||||
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
|
||||
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
|
||||
@@ -473,6 +474,7 @@ namespace ts.BreakpointResolver {
|
||||
if (getModuleInstanceState(block.parent) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
// falls through
|
||||
|
||||
// Set on parent if on same line otherwise on first statement
|
||||
case SyntaxKind.WhileStatement:
|
||||
@@ -582,6 +584,7 @@ namespace ts.BreakpointResolver {
|
||||
if (getModuleInstanceState(node.parent.parent) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@@ -593,7 +596,7 @@ namespace ts.BreakpointResolver {
|
||||
// Span on close brace token
|
||||
return textSpan(node);
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return spanInNode(lastOrUndefined((<Block>node.parent).statements));
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace ts {
|
||||
case EndOfLineState.InTemplateMiddleOrTail:
|
||||
text = "}\n" + text;
|
||||
offset = 2;
|
||||
// fallthrough
|
||||
// falls through
|
||||
case EndOfLineState.InTemplateSubstitutionPosition:
|
||||
templateStack.push(SyntaxKind.TemplateHead);
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code],
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
||||
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code],
|
||||
getCodeActions: getActionsForAddMissingMember
|
||||
});
|
||||
|
||||
@@ -14,7 +15,7 @@ namespace ts.codefix {
|
||||
// ^^^^^^^
|
||||
const token = getTokenAtPosition(sourceFile, start);
|
||||
|
||||
if (token.kind != SyntaxKind.Identifier) {
|
||||
if (token.kind !== SyntaxKind.Identifier) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -110,16 +111,16 @@ namespace ts.codefix {
|
||||
if (!isStatic) {
|
||||
const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword);
|
||||
const indexingParameter = createParameter(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined,
|
||||
"x",
|
||||
/*questionToken*/ undefined,
|
||||
/*questionToken*/ undefined,
|
||||
stringTypeNode,
|
||||
/*initializer*/ undefined);
|
||||
const indexSignature = createIndexSignatureDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*initializer*/ undefined);
|
||||
const indexSignature = createIndexSignature(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
[indexingParameter],
|
||||
typeNode);
|
||||
|
||||
@@ -135,4 +136,4 @@ namespace ts.codefix {
|
||||
return actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace ts.codefix {
|
||||
|
||||
// figure out if the `this` access is actually inside the supercall
|
||||
// i.e. super(this.a), since in that case we won't suggest a fix
|
||||
if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) {
|
||||
if (superCall.expression && superCall.expression.kind === SyntaxKind.CallExpression) {
|
||||
const arguments = (<CallExpression>superCall.expression).arguments;
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
if ((<PropertyAccessExpression>arguments[i]).expression === token) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code],
|
||||
getCodeActions: getActionsForCorrectSpelling
|
||||
});
|
||||
|
||||
function getActionsForCorrectSpelling(context: CodeFixContext): CodeAction[] | undefined {
|
||||
const sourceFile = context.sourceFile;
|
||||
|
||||
// This is the identifier of the misspelled word. eg:
|
||||
// this.speling = 1;
|
||||
// ^^^^^^^
|
||||
const node = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const checker = context.program.getTypeChecker();
|
||||
let suggestion: string;
|
||||
if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) {
|
||||
const containingType = checker.getTypeAtLocation(node.parent.expression);
|
||||
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
|
||||
}
|
||||
else {
|
||||
const meaning = getMeaningFromLocation(node);
|
||||
suggestion = checker.getSuggestionForNonexistentSymbol(node, getTextOfNode(node), convertSemanticMeaningToSymbolFlags(meaning));
|
||||
}
|
||||
if (suggestion) {
|
||||
return [{
|
||||
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]),
|
||||
changes: [{
|
||||
fileName: sourceFile.fileName,
|
||||
textChanges: [{
|
||||
span: { start: node.getStart(), length: node.getWidth() },
|
||||
newText: suggestion
|
||||
}],
|
||||
}],
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFlags {
|
||||
let flags = 0;
|
||||
if (meaning & SemanticMeaning.Namespace) {
|
||||
flags |= SymbolFlags.Namespace;
|
||||
}
|
||||
if (meaning & SemanticMeaning.Type) {
|
||||
flags |= SymbolFlags.Type;
|
||||
}
|
||||
if (meaning & SemanticMeaning.Value) {
|
||||
flags |= SymbolFlags.Value;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="fixClassIncorrectlyImplementsInterface.ts" />
|
||||
/// <reference path="fixAddMissingMember.ts" />
|
||||
/// <reference path="fixSpelling.ts" />
|
||||
/// <reference path="fixClassDoesntImplementInheritedAbstractMember.ts" />
|
||||
/// <reference path="fixClassSuperMustPrecedeThisAccess.ts" />
|
||||
/// <reference path="fixConstructorForDerivedNeedSuperCall.ts" />
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) {
|
||||
return createMethodDeclaration(
|
||||
return createMethod(
|
||||
/*decorators*/ undefined,
|
||||
modifiers,
|
||||
/*asteriskToken*/ undefined,
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Cannot_find_name_0.code,
|
||||
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
||||
Diagnostics.Cannot_find_namespace_0.code,
|
||||
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
|
||||
],
|
||||
getCodeActions: getImportCodeActions
|
||||
});
|
||||
|
||||
type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport";
|
||||
interface ImportCodeAction extends CodeAction {
|
||||
@@ -42,12 +51,13 @@ namespace ts.codefix {
|
||||
|
||||
switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) {
|
||||
case ModuleSpecifierComparison.Better:
|
||||
// the new one is not worth considering if it is a new improt.
|
||||
// the new one is not worth considering if it is a new import.
|
||||
// However if it is instead a insertion into existing import, the user might want to use
|
||||
// the module specifier even it is worse by our standards. So keep it.
|
||||
if (newAction.kind === "NewImport") {
|
||||
return;
|
||||
}
|
||||
// falls through
|
||||
case ModuleSpecifierComparison.Equal:
|
||||
// the current one is safe. But it is still possible that the new one is worse
|
||||
// than another existing one. For example, you may have new imports from "./foo/bar"
|
||||
@@ -112,465 +122,458 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes: [
|
||||
Diagnostics.Cannot_find_name_0.code,
|
||||
Diagnostics.Cannot_find_namespace_0.code,
|
||||
Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
|
||||
],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const checker = context.program.getTypeChecker();
|
||||
const allSourceFiles = context.program.getSourceFiles();
|
||||
const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false;
|
||||
function getImportCodeActions(context: CodeFixContext): ImportCodeAction[] {
|
||||
const sourceFile = context.sourceFile;
|
||||
const checker = context.program.getTypeChecker();
|
||||
const allSourceFiles = context.program.getSourceFiles();
|
||||
const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false;
|
||||
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const name = token.getText();
|
||||
const symbolIdActionMap = new ImportCodeActionMap();
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
const name = token.getText();
|
||||
const symbolIdActionMap = new ImportCodeActionMap();
|
||||
|
||||
// this is a module id -> module import declaration map
|
||||
const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = [];
|
||||
let lastImportDeclaration: Node;
|
||||
// this is a module id -> module import declaration map
|
||||
const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = [];
|
||||
let lastImportDeclaration: Node;
|
||||
|
||||
const currentTokenMeaning = getMeaningFromLocation(token);
|
||||
if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
||||
const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token));
|
||||
return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true);
|
||||
const currentTokenMeaning = getMeaningFromLocation(token);
|
||||
if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
||||
const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token));
|
||||
return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true);
|
||||
}
|
||||
|
||||
const candidateModules = checker.getAmbientModules();
|
||||
for (const otherSourceFile of allSourceFiles) {
|
||||
if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) {
|
||||
candidateModules.push(otherSourceFile.symbol);
|
||||
}
|
||||
}
|
||||
|
||||
const candidateModules = checker.getAmbientModules();
|
||||
for (const otherSourceFile of allSourceFiles) {
|
||||
if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) {
|
||||
candidateModules.push(otherSourceFile.symbol);
|
||||
for (const moduleSymbol of candidateModules) {
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
// check the default export
|
||||
const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol);
|
||||
if (defaultExport) {
|
||||
const localSymbol = getLocalSymbolForExportDefault(defaultExport);
|
||||
if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
|
||||
// check if this symbol is already used
|
||||
const symbolId = getUniqueSymbolId(localSymbol);
|
||||
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
for (const moduleSymbol of candidateModules) {
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
// check exports with the same name
|
||||
const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol);
|
||||
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
|
||||
const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName);
|
||||
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol));
|
||||
}
|
||||
}
|
||||
|
||||
// check the default export
|
||||
const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol);
|
||||
if (defaultExport) {
|
||||
const localSymbol = getLocalSymbolForExportDefault(defaultExport);
|
||||
if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
|
||||
// check if this symbol is already used
|
||||
const symbolId = getUniqueSymbolId(localSymbol);
|
||||
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true));
|
||||
return symbolIdActionMap.getAllActions();
|
||||
|
||||
function getImportDeclarations(moduleSymbol: Symbol) {
|
||||
const moduleSymbolId = getUniqueSymbolId(moduleSymbol);
|
||||
|
||||
const cached = cachedImportDeclarations[moduleSymbolId];
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = [];
|
||||
for (const importModuleSpecifier of sourceFile.imports) {
|
||||
const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier);
|
||||
if (importSymbol === moduleSymbol) {
|
||||
existingDeclarations.push(getImportDeclaration(importModuleSpecifier));
|
||||
}
|
||||
}
|
||||
cachedImportDeclarations[moduleSymbolId] = existingDeclarations;
|
||||
return existingDeclarations;
|
||||
|
||||
function getImportDeclaration(moduleSpecifier: LiteralExpression) {
|
||||
let node: Node = moduleSpecifier;
|
||||
while (node) {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return <ImportDeclaration>node;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
return <ImportEqualsDeclaration>node;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// check exports with the same name
|
||||
const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol);
|
||||
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
|
||||
const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName);
|
||||
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol));
|
||||
}
|
||||
function getUniqueSymbolId(symbol: Symbol) {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
return getSymbolId(checker.getAliasedSymbol(symbol));
|
||||
}
|
||||
return getSymbolId(symbol);
|
||||
}
|
||||
|
||||
function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) {
|
||||
const declarations = symbol.getDeclarations();
|
||||
return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false;
|
||||
}
|
||||
|
||||
function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] {
|
||||
const existingDeclarations = getImportDeclarations(moduleSymbol);
|
||||
if (existingDeclarations.length > 0) {
|
||||
// With an existing import statement, there are more than one actions the user can do.
|
||||
return getCodeActionsForExistingImport(existingDeclarations);
|
||||
}
|
||||
else {
|
||||
return [getCodeActionForNewImport()];
|
||||
}
|
||||
|
||||
return symbolIdActionMap.getAllActions();
|
||||
function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] {
|
||||
const actions: ImportCodeAction[] = [];
|
||||
|
||||
function getImportDeclarations(moduleSymbol: Symbol) {
|
||||
const moduleSymbolId = getUniqueSymbolId(moduleSymbol);
|
||||
|
||||
const cached = cachedImportDeclarations[moduleSymbolId];
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = [];
|
||||
for (const importModuleSpecifier of sourceFile.imports) {
|
||||
const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier);
|
||||
if (importSymbol === moduleSymbol) {
|
||||
existingDeclarations.push(getImportDeclaration(importModuleSpecifier));
|
||||
}
|
||||
}
|
||||
cachedImportDeclarations[moduleSymbolId] = existingDeclarations;
|
||||
return existingDeclarations;
|
||||
|
||||
function getImportDeclaration(moduleSpecifier: LiteralExpression) {
|
||||
let node: Node = moduleSpecifier;
|
||||
while (node) {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return <ImportDeclaration>node;
|
||||
// It is possible that multiple import statements with the same specifier exist in the file.
|
||||
// e.g.
|
||||
//
|
||||
// import * as ns from "foo";
|
||||
// import { member1, member2 } from "foo";
|
||||
//
|
||||
// member3/**/ <-- cusor here
|
||||
//
|
||||
// in this case we should provie 2 actions:
|
||||
// 1. change "member3" to "ns.member3"
|
||||
// 2. add "member3" to the second import statement's import list
|
||||
// and it is up to the user to decide which one fits best.
|
||||
let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration;
|
||||
let namedImportDeclaration: ImportDeclaration;
|
||||
let existingModuleSpecifier: string;
|
||||
for (const declaration of declarations) {
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
const namedBindings = declaration.importClause && declaration.importClause.namedBindings;
|
||||
if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
// case:
|
||||
// import * as ns from "foo"
|
||||
namespaceImportDeclaration = declaration;
|
||||
}
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
return <ImportEqualsDeclaration>node;
|
||||
else {
|
||||
// cases:
|
||||
// import default from "foo"
|
||||
// import { bar } from "foo" or combination with the first one
|
||||
// import "foo"
|
||||
namedImportDeclaration = declaration;
|
||||
}
|
||||
node = node.parent;
|
||||
existingModuleSpecifier = declaration.moduleSpecifier.getText();
|
||||
}
|
||||
else {
|
||||
// case:
|
||||
// import foo = require("foo")
|
||||
namespaceImportDeclaration = declaration;
|
||||
existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function getUniqueSymbolId(symbol: Symbol) {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
return getSymbolId(checker.getAliasedSymbol(symbol));
|
||||
if (namespaceImportDeclaration) {
|
||||
actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration));
|
||||
}
|
||||
return getSymbolId(symbol);
|
||||
}
|
||||
|
||||
function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) {
|
||||
const declarations = symbol.getDeclarations();
|
||||
return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false;
|
||||
}
|
||||
|
||||
function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] {
|
||||
const existingDeclarations = getImportDeclarations(moduleSymbol);
|
||||
if (existingDeclarations.length > 0) {
|
||||
// With an existing import statement, there are more than one actions the user can do.
|
||||
return getCodeActionsForExistingImport(existingDeclarations);
|
||||
if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause &&
|
||||
(namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) {
|
||||
/**
|
||||
* If the existing import declaration already has a named import list, just
|
||||
* insert the identifier into that list.
|
||||
*/
|
||||
const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause);
|
||||
const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText());
|
||||
actions.push(createCodeAction(
|
||||
Diagnostics.Add_0_to_existing_import_declaration_from_1,
|
||||
[name, moduleSpecifierWithoutQuotes],
|
||||
fileTextChanges,
|
||||
"InsertingIntoExistingImport",
|
||||
moduleSpecifierWithoutQuotes
|
||||
));
|
||||
}
|
||||
else {
|
||||
return [getCodeActionForNewImport()];
|
||||
// we need to create a new import statement, but the existing module specifier can be reused.
|
||||
actions.push(getCodeActionForNewImport(existingModuleSpecifier));
|
||||
}
|
||||
return actions;
|
||||
|
||||
function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) {
|
||||
if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
return declaration.moduleReference.expression.getText();
|
||||
}
|
||||
return declaration.moduleReference.getText();
|
||||
}
|
||||
|
||||
function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] {
|
||||
const actions: ImportCodeAction[] = [];
|
||||
|
||||
// It is possible that multiple import statements with the same specifier exist in the file.
|
||||
// e.g.
|
||||
//
|
||||
// import * as ns from "foo";
|
||||
// import { member1, member2 } from "foo";
|
||||
//
|
||||
// member3/**/ <-- cusor here
|
||||
//
|
||||
// in this case we should provie 2 actions:
|
||||
// 1. change "member3" to "ns.member3"
|
||||
// 2. add "member3" to the second import statement's import list
|
||||
// and it is up to the user to decide which one fits best.
|
||||
let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration;
|
||||
let namedImportDeclaration: ImportDeclaration;
|
||||
let existingModuleSpecifier: string;
|
||||
for (const declaration of declarations) {
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
const namedBindings = declaration.importClause && declaration.importClause.namedBindings;
|
||||
if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
// case:
|
||||
// import * as ns from "foo"
|
||||
namespaceImportDeclaration = declaration;
|
||||
}
|
||||
else {
|
||||
// cases:
|
||||
// import default from "foo"
|
||||
// import { bar } from "foo" or combination with the first one
|
||||
// import "foo"
|
||||
namedImportDeclaration = declaration;
|
||||
}
|
||||
existingModuleSpecifier = declaration.moduleSpecifier.getText();
|
||||
}
|
||||
else {
|
||||
// case:
|
||||
// import foo = require("foo")
|
||||
namespaceImportDeclaration = declaration;
|
||||
existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration);
|
||||
}
|
||||
function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] {
|
||||
const importList = <NamedImports>importClause.namedBindings;
|
||||
const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name));
|
||||
// case 1:
|
||||
// original text: import default from "module"
|
||||
// change to: import default, { name } from "module"
|
||||
// case 2:
|
||||
// original text: import {} from "module"
|
||||
// change to: import { name } from "module"
|
||||
if (!importList || importList.elements.length === 0) {
|
||||
const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier]));
|
||||
return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges();
|
||||
}
|
||||
|
||||
if (namespaceImportDeclaration) {
|
||||
actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration));
|
||||
}
|
||||
|
||||
if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause &&
|
||||
(namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) {
|
||||
/**
|
||||
* If the existing import declaration already has a named import list, just
|
||||
* insert the identifier into that list.
|
||||
*/
|
||||
const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause);
|
||||
const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText());
|
||||
actions.push(createCodeAction(
|
||||
Diagnostics.Add_0_to_existing_import_declaration_from_1,
|
||||
[name, moduleSpecifierWithoutQuotes],
|
||||
fileTextChanges,
|
||||
"InsertingIntoExistingImport",
|
||||
moduleSpecifierWithoutQuotes
|
||||
));
|
||||
}
|
||||
else {
|
||||
// we need to create a new import statement, but the existing module specifier can be reused.
|
||||
actions.push(getCodeActionForNewImport(existingModuleSpecifier));
|
||||
}
|
||||
return actions;
|
||||
|
||||
function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) {
|
||||
if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
return declaration.moduleReference.expression.getText();
|
||||
}
|
||||
return declaration.moduleReference.getText();
|
||||
}
|
||||
|
||||
function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] {
|
||||
const importList = <NamedImports>importClause.namedBindings;
|
||||
const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name));
|
||||
// case 1:
|
||||
// original text: import default from "module"
|
||||
// change to: import default, { name } from "module"
|
||||
// case 2:
|
||||
// original text: import {} from "module"
|
||||
// change to: import { name } from "module"
|
||||
if (!importList || importList.elements.length === 0) {
|
||||
const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier]));
|
||||
return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the import list has one import per line, preserve that. Otherwise, insert on same line as last element
|
||||
* import {
|
||||
* foo
|
||||
* } from "./module";
|
||||
*/
|
||||
return createChangeTracker().insertNodeInListAfter(
|
||||
sourceFile,
|
||||
importList.elements[importList.elements.length - 1],
|
||||
newImportSpecifier).getChanges();
|
||||
}
|
||||
|
||||
function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction {
|
||||
let namespacePrefix: string;
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
namespacePrefix = (<NamespaceImport>declaration.importClause.namedBindings).name.getText();
|
||||
}
|
||||
else {
|
||||
namespacePrefix = declaration.name.getText();
|
||||
}
|
||||
namespacePrefix = stripQuotes(namespacePrefix);
|
||||
|
||||
/**
|
||||
* Cases:
|
||||
* import * as ns from "mod"
|
||||
* import default, * as ns from "mod"
|
||||
* import ns = require("mod")
|
||||
*
|
||||
* Because there is no import list, we alter the reference to include the
|
||||
* namespace instead of altering the import declaration. For example, "foo" would
|
||||
* become "ns.foo"
|
||||
*/
|
||||
return createCodeAction(
|
||||
Diagnostics.Change_0_to_1,
|
||||
[name, `${namespacePrefix}.${name}`],
|
||||
createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(),
|
||||
"CodeChange"
|
||||
);
|
||||
}
|
||||
/**
|
||||
* If the import list has one import per line, preserve that. Otherwise, insert on same line as last element
|
||||
* import {
|
||||
* foo
|
||||
* } from "./module";
|
||||
*/
|
||||
return createChangeTracker().insertNodeInListAfter(
|
||||
sourceFile,
|
||||
importList.elements[importList.elements.length - 1],
|
||||
newImportSpecifier).getChanges();
|
||||
}
|
||||
|
||||
function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction {
|
||||
if (!lastImportDeclaration) {
|
||||
// insert after any existing imports
|
||||
for (let i = sourceFile.statements.length - 1; i >= 0; i--) {
|
||||
const statement = sourceFile.statements[i];
|
||||
if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) {
|
||||
lastImportDeclaration = statement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport());
|
||||
const changeTracker = createChangeTracker();
|
||||
const importClause = isDefault
|
||||
? createImportClause(createIdentifier(name), /*namedBindings*/ undefined)
|
||||
: isNamespaceImport
|
||||
? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name)))
|
||||
: createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))]));
|
||||
const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes));
|
||||
if (!lastImportDeclaration) {
|
||||
changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` });
|
||||
function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction {
|
||||
let namespacePrefix: string;
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
namespacePrefix = (<NamespaceImport>declaration.importClause.namedBindings).name.getText();
|
||||
}
|
||||
else {
|
||||
changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter });
|
||||
namespacePrefix = declaration.name.getText();
|
||||
}
|
||||
namespacePrefix = stripQuotes(namespacePrefix);
|
||||
|
||||
// if this file doesn't have any import statements, insert an import statement and then insert a new line
|
||||
// between the only import statement and user code. Otherwise just insert the statement because chances
|
||||
// are there are already a new line seperating code and import statements.
|
||||
/**
|
||||
* Cases:
|
||||
* import * as ns from "mod"
|
||||
* import default, * as ns from "mod"
|
||||
* import ns = require("mod")
|
||||
*
|
||||
* Because there is no import list, we alter the reference to include the
|
||||
* namespace instead of altering the import declaration. For example, "foo" would
|
||||
* become "ns.foo"
|
||||
*/
|
||||
return createCodeAction(
|
||||
Diagnostics.Import_0_from_1,
|
||||
[name, `"${moduleSpecifierWithoutQuotes}"`],
|
||||
changeTracker.getChanges(),
|
||||
"NewImport",
|
||||
moduleSpecifierWithoutQuotes
|
||||
Diagnostics.Change_0_to_1,
|
||||
[name, `${namespacePrefix}.${name}`],
|
||||
createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(),
|
||||
"CodeChange"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getModuleSpecifierForNewImport() {
|
||||
const fileName = sourceFile.fileName;
|
||||
const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName;
|
||||
const sourceDirectory = getDirectoryPath(fileName);
|
||||
const options = context.program.getCompilerOptions();
|
||||
|
||||
return tryGetModuleNameFromAmbientModule() ||
|
||||
tryGetModuleNameFromTypeRoots() ||
|
||||
tryGetModuleNameAsNodeModule() ||
|
||||
tryGetModuleNameFromBaseUrl() ||
|
||||
tryGetModuleNameFromRootDirs() ||
|
||||
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory));
|
||||
|
||||
function tryGetModuleNameFromAmbientModule(): string {
|
||||
if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) {
|
||||
return moduleSymbol.name;
|
||||
}
|
||||
function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction {
|
||||
if (!lastImportDeclaration) {
|
||||
// insert after any existing imports
|
||||
for (let i = sourceFile.statements.length - 1; i >= 0; i--) {
|
||||
const statement = sourceFile.statements[i];
|
||||
if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) {
|
||||
lastImportDeclaration = statement;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromBaseUrl() {
|
||||
if (!options.baseUrl) {
|
||||
return undefined;
|
||||
}
|
||||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport());
|
||||
const changeTracker = createChangeTracker();
|
||||
const importClause = isDefault
|
||||
? createImportClause(createIdentifier(name), /*namedBindings*/ undefined)
|
||||
: isNamespaceImport
|
||||
? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name)))
|
||||
: createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))]));
|
||||
const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes));
|
||||
if (!lastImportDeclaration) {
|
||||
changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` });
|
||||
}
|
||||
else {
|
||||
changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter });
|
||||
}
|
||||
|
||||
let relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl);
|
||||
if (!relativeName) {
|
||||
return undefined;
|
||||
}
|
||||
// if this file doesn't have any import statements, insert an import statement and then insert a new line
|
||||
// between the only import statement and user code. Otherwise just insert the statement because chances
|
||||
// are there are already a new line seperating code and import statements.
|
||||
return createCodeAction(
|
||||
Diagnostics.Import_0_from_1,
|
||||
[name, `"${moduleSpecifierWithoutQuotes}"`],
|
||||
changeTracker.getChanges(),
|
||||
"NewImport",
|
||||
moduleSpecifierWithoutQuotes
|
||||
);
|
||||
|
||||
const relativeNameWithIndex = removeFileExtension(relativeName);
|
||||
relativeName = removeExtensionAndIndexPostFix(relativeName);
|
||||
function getModuleSpecifierForNewImport() {
|
||||
const fileName = sourceFile.fileName;
|
||||
const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName;
|
||||
const sourceDirectory = getDirectoryPath(fileName);
|
||||
const options = context.program.getCompilerOptions();
|
||||
|
||||
if (options.paths) {
|
||||
for (const key in options.paths) {
|
||||
for (const pattern of options.paths[key]) {
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
if (indexOfStar === 0 && pattern.length === 1) {
|
||||
continue;
|
||||
}
|
||||
else if (indexOfStar !== -1) {
|
||||
const prefix = pattern.substr(0, indexOfStar);
|
||||
const suffix = pattern.substr(indexOfStar + 1);
|
||||
if (relativeName.length >= prefix.length + suffix.length &&
|
||||
startsWith(relativeName, prefix) &&
|
||||
endsWith(relativeName, suffix)) {
|
||||
const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length);
|
||||
return key.replace("\*", matchedStar);
|
||||
}
|
||||
}
|
||||
else if (pattern === relativeName || pattern === relativeNameWithIndex) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tryGetModuleNameFromAmbientModule() ||
|
||||
tryGetModuleNameFromTypeRoots() ||
|
||||
tryGetModuleNameAsNodeModule() ||
|
||||
tryGetModuleNameFromBaseUrl() ||
|
||||
tryGetModuleNameFromRootDirs() ||
|
||||
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory));
|
||||
|
||||
return relativeName;
|
||||
function tryGetModuleNameFromAmbientModule(): string {
|
||||
if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) {
|
||||
return moduleSymbol.name;
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromRootDirs() {
|
||||
if (options.rootDirs) {
|
||||
const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs);
|
||||
const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs);
|
||||
if (normalizedTargetPath !== undefined) {
|
||||
const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath;
|
||||
return removeFileExtension(relativePath);
|
||||
}
|
||||
}
|
||||
function tryGetModuleNameFromBaseUrl() {
|
||||
if (!options.baseUrl) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromTypeRoots() {
|
||||
const typeRoots = getEffectiveTypeRoots(options, context.host);
|
||||
if (typeRoots) {
|
||||
const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName));
|
||||
for (const typeRoot of normalizedTypeRoots) {
|
||||
if (startsWith(moduleFileName, typeRoot)) {
|
||||
const relativeFileName = moduleFileName.substring(typeRoot.length + 1);
|
||||
return removeExtensionAndIndexPostFix(relativeFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
let relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl);
|
||||
if (!relativeName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetModuleNameAsNodeModule() {
|
||||
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
|
||||
// nothing to do here
|
||||
return undefined;
|
||||
}
|
||||
const relativeNameWithIndex = removeFileExtension(relativeName);
|
||||
relativeName = removeExtensionAndIndexPostFix(relativeName);
|
||||
|
||||
const indexOfNodeModules = moduleFileName.indexOf("node_modules");
|
||||
if (indexOfNodeModules < 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let relativeFileName: string;
|
||||
if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) {
|
||||
// if node_modules folder is in this folder or any of its parent folder, no need to keep it.
|
||||
relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */);
|
||||
}
|
||||
else {
|
||||
relativeFileName = getRelativePath(moduleFileName, sourceDirectory);
|
||||
}
|
||||
|
||||
relativeFileName = removeFileExtension(relativeFileName);
|
||||
if (endsWith(relativeFileName, "/index")) {
|
||||
relativeFileName = getDirectoryPath(relativeFileName);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
const moduleDirectory = getDirectoryPath(moduleFileName);
|
||||
const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json")));
|
||||
if (packageJsonContent) {
|
||||
const mainFile = packageJsonContent.main || packageJsonContent.typings;
|
||||
if (mainFile) {
|
||||
const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName);
|
||||
if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) {
|
||||
relativeFileName = getDirectoryPath(relativeFileName);
|
||||
}
|
||||
if (options.paths) {
|
||||
for (const key in options.paths) {
|
||||
for (const pattern of options.paths[key]) {
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
if (indexOfStar === 0 && pattern.length === 1) {
|
||||
continue;
|
||||
}
|
||||
else if (indexOfStar !== -1) {
|
||||
const prefix = pattern.substr(0, indexOfStar);
|
||||
const suffix = pattern.substr(indexOfStar + 1);
|
||||
if (relativeName.length >= prefix.length + suffix.length &&
|
||||
startsWith(relativeName, prefix) &&
|
||||
endsWith(relativeName, suffix)) {
|
||||
const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length);
|
||||
return key.replace("\*", matchedStar);
|
||||
}
|
||||
}
|
||||
else if (pattern === relativeName || pattern === relativeNameWithIndex) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
|
||||
return relativeFileName;
|
||||
}
|
||||
|
||||
return relativeName;
|
||||
}
|
||||
|
||||
function getPathRelativeToRootDirs(path: string, rootDirs: string[]) {
|
||||
for (const rootDir of rootDirs) {
|
||||
const relativeName = getRelativePathIfInDirectory(path, rootDir);
|
||||
if (relativeName !== undefined) {
|
||||
return relativeName;
|
||||
function tryGetModuleNameFromRootDirs() {
|
||||
if (options.rootDirs) {
|
||||
const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs);
|
||||
const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs);
|
||||
if (normalizedTargetPath !== undefined) {
|
||||
const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath;
|
||||
return removeFileExtension(relativePath);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function removeExtensionAndIndexPostFix(fileName: string) {
|
||||
fileName = removeFileExtension(fileName);
|
||||
if (endsWith(fileName, "/index")) {
|
||||
fileName = fileName.substr(0, fileName.length - 6/* "/index".length */);
|
||||
function tryGetModuleNameFromTypeRoots() {
|
||||
const typeRoots = getEffectiveTypeRoots(options, context.host);
|
||||
if (typeRoots) {
|
||||
const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName));
|
||||
for (const typeRoot of normalizedTypeRoots) {
|
||||
if (startsWith(moduleFileName, typeRoot)) {
|
||||
const relativeFileName = moduleFileName.substring(typeRoot.length + 1);
|
||||
return removeExtensionAndIndexPostFix(relativeFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
function getRelativePathIfInDirectory(path: string, directoryPath: string) {
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath;
|
||||
}
|
||||
function tryGetModuleNameAsNodeModule() {
|
||||
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
|
||||
// nothing to do here
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getRelativePath(path: string, directoryPath: string) {
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath;
|
||||
const indexOfNodeModules = moduleFileName.indexOf("node_modules");
|
||||
if (indexOfNodeModules < 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let relativeFileName: string;
|
||||
if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) {
|
||||
// if node_modules folder is in this folder or any of its parent folder, no need to keep it.
|
||||
relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */);
|
||||
}
|
||||
else {
|
||||
relativeFileName = getRelativePath(moduleFileName, sourceDirectory);
|
||||
}
|
||||
|
||||
relativeFileName = removeFileExtension(relativeFileName);
|
||||
if (endsWith(relativeFileName, "/index")) {
|
||||
relativeFileName = getDirectoryPath(relativeFileName);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
const moduleDirectory = getDirectoryPath(moduleFileName);
|
||||
const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json")));
|
||||
if (packageJsonContent) {
|
||||
const mainFile = packageJsonContent.main || packageJsonContent.typings;
|
||||
if (mainFile) {
|
||||
const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName);
|
||||
if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) {
|
||||
relativeFileName = getDirectoryPath(relativeFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
|
||||
return relativeFileName;
|
||||
}
|
||||
}
|
||||
|
||||
function getPathRelativeToRootDirs(path: string, rootDirs: string[]) {
|
||||
for (const rootDir of rootDirs) {
|
||||
const relativeName = getRelativePathIfInDirectory(path, rootDir);
|
||||
if (relativeName !== undefined) {
|
||||
return relativeName;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function removeExtensionAndIndexPostFix(fileName: string) {
|
||||
fileName = removeFileExtension(fileName);
|
||||
if (endsWith(fileName, "/index")) {
|
||||
fileName = fileName.substr(0, fileName.length - 6/* "/index".length */);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
function getRelativePathIfInDirectory(path: string, directoryPath: string) {
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath;
|
||||
}
|
||||
|
||||
function getRelativePath(path: string, directoryPath: string) {
|
||||
const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
function createChangeTracker() {
|
||||
return textChanges.ChangeTracker.fromCodeFixContext(context);
|
||||
}
|
||||
|
||||
function createCodeAction(
|
||||
description: DiagnosticMessage,
|
||||
diagnosticArgs: string[],
|
||||
changes: FileTextChanges[],
|
||||
kind: ImportCodeActionKind,
|
||||
moduleSpecifier?: string): ImportCodeAction {
|
||||
return {
|
||||
description: formatMessage.apply(undefined, [undefined, description].concat(<any[]>diagnosticArgs)),
|
||||
changes,
|
||||
kind,
|
||||
moduleSpecifier
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function createChangeTracker() {
|
||||
return textChanges.ChangeTracker.fromCodeFixContext(context);
|
||||
}
|
||||
|
||||
function createCodeAction(
|
||||
description: DiagnosticMessage,
|
||||
diagnosticArgs: string[],
|
||||
changes: FileTextChanges[],
|
||||
kind: ImportCodeActionKind,
|
||||
moduleSpecifier?: string): ImportCodeAction {
|
||||
return {
|
||||
description: formatMessage.apply(undefined, [undefined, description].concat(<any[]>diagnosticArgs)),
|
||||
changes,
|
||||
kind,
|
||||
moduleSpecifier
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,140 +18,150 @@ namespace ts.codefix {
|
||||
|
||||
switch (token.kind) {
|
||||
case ts.SyntaxKind.Identifier:
|
||||
switch (token.parent.kind) {
|
||||
case ts.SyntaxKind.VariableDeclaration:
|
||||
switch (token.parent.parent.parent.kind) {
|
||||
case SyntaxKind.ForStatement:
|
||||
const forStatement = <ForStatement>token.parent.parent.parent;
|
||||
const forInitializer = <VariableDeclarationList>forStatement.initializer;
|
||||
if (forInitializer.declarations.length === 1) {
|
||||
return deleteNode(forInitializer);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
case SyntaxKind.ForOfStatement:
|
||||
const forOfStatement = <ForOfStatement>token.parent.parent.parent;
|
||||
if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
const forOfInitializer = <VariableDeclarationList>forOfStatement.initializer;
|
||||
return replaceNode(forOfInitializer.declarations[0], createObjectLiteral());
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.ForInStatement:
|
||||
// There is no valid fix in the case of:
|
||||
// for .. in
|
||||
return undefined;
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
const catchClause = <CatchClause>token.parent.parent;
|
||||
const parameter = catchClause.variableDeclaration.getChildren()[0];
|
||||
return deleteNode(parameter);
|
||||
|
||||
default:
|
||||
const variableStatement = <VariableStatement>token.parent.parent.parent;
|
||||
if (variableStatement.declarationList.declarations.length === 1) {
|
||||
return deleteNode(variableStatement);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
}
|
||||
|
||||
case SyntaxKind.TypeParameter:
|
||||
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
|
||||
if (typeParameters.length === 1) {
|
||||
const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1);
|
||||
if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
const nextToken = getTokenAtPosition(sourceFile, typeParameters.end);
|
||||
if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
return deleteNodeRange(previousToken, nextToken);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
case ts.SyntaxKind.Parameter:
|
||||
const functionDeclaration = <FunctionDeclaration>token.parent.parent;
|
||||
if (functionDeclaration.parameters.length === 1) {
|
||||
return deleteNode(token.parent);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
// handle case where 'import a = A;'
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration);
|
||||
return deleteNode(importEquals);
|
||||
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
const namedImports = <NamedImports>token.parent.parent;
|
||||
if (namedImports.elements.length === 1) {
|
||||
// Only 1 import and it is unused. So the entire declaration should be removed.
|
||||
const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importSpec);
|
||||
}
|
||||
else {
|
||||
// delete import specifier
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
// handle case where "import d, * as ns from './file'"
|
||||
// or "'import {a, b as ns} from './file'"
|
||||
case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *'
|
||||
const importClause = <ImportClause>token.parent;
|
||||
if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'|
|
||||
const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importDecl);
|
||||
}
|
||||
else {
|
||||
// import |d,| * as ns from './file'
|
||||
const start = importClause.name.getStart(sourceFile);
|
||||
const nextToken = getTokenAtPosition(sourceFile, importClause.name.end);
|
||||
if (nextToken && nextToken.kind === SyntaxKind.CommaToken) {
|
||||
// shift first non-whitespace position after comma to the start position of the node
|
||||
return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) });
|
||||
}
|
||||
else {
|
||||
return deleteNode(importClause.name);
|
||||
}
|
||||
}
|
||||
|
||||
case SyntaxKind.NamespaceImport:
|
||||
const namespaceImport = <NamespaceImport>token.parent;
|
||||
if (namespaceImport.name == token && !(<ImportClause>namespaceImport.parent).name) {
|
||||
const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importDecl);
|
||||
}
|
||||
else {
|
||||
const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1);
|
||||
if (previousToken && previousToken.kind === SyntaxKind.CommaToken) {
|
||||
const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart);
|
||||
return deleteRange({ pos: startPosition, end: namespaceImport.end });
|
||||
}
|
||||
return deleteRange(namespaceImport);
|
||||
}
|
||||
}
|
||||
break;
|
||||
return deleteIdentifier();
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return deleteNode(token.parent);
|
||||
|
||||
default:
|
||||
return deleteDefault();
|
||||
}
|
||||
if (isDeclarationName(token)) {
|
||||
return deleteNode(token.parent);
|
||||
|
||||
function deleteDefault() {
|
||||
if (isDeclarationName(token)) {
|
||||
return deleteNode(token.parent);
|
||||
}
|
||||
else if (isLiteralComputedPropertyDeclarationName(token)) {
|
||||
return deleteNode(token.parent.parent);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else if (isLiteralComputedPropertyDeclarationName(token)) {
|
||||
return deleteNode(token.parent.parent);
|
||||
|
||||
function deleteIdentifier(): CodeAction[] | undefined {
|
||||
switch (token.parent.kind) {
|
||||
case ts.SyntaxKind.VariableDeclaration:
|
||||
return deleteVariableDeclaration(<ts.VariableDeclaration>token.parent);
|
||||
|
||||
case SyntaxKind.TypeParameter:
|
||||
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
|
||||
if (typeParameters.length === 1) {
|
||||
const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1);
|
||||
if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
const nextToken = getTokenAtPosition(sourceFile, typeParameters.end);
|
||||
if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) {
|
||||
return deleteRange(typeParameters);
|
||||
}
|
||||
return deleteNodeRange(previousToken, nextToken);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
case ts.SyntaxKind.Parameter:
|
||||
const functionDeclaration = <FunctionDeclaration>token.parent.parent;
|
||||
if (functionDeclaration.parameters.length === 1) {
|
||||
return deleteNode(token.parent);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
// handle case where 'import a = A;'
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration);
|
||||
return deleteNode(importEquals);
|
||||
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
const namedImports = <NamedImports>token.parent.parent;
|
||||
if (namedImports.elements.length === 1) {
|
||||
// Only 1 import and it is unused. So the entire declaration should be removed.
|
||||
const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importSpec);
|
||||
}
|
||||
else {
|
||||
// delete import specifier
|
||||
return deleteNodeInList(token.parent);
|
||||
}
|
||||
|
||||
// handle case where "import d, * as ns from './file'"
|
||||
// or "'import {a, b as ns} from './file'"
|
||||
case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *'
|
||||
const importClause = <ImportClause>token.parent;
|
||||
if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'|
|
||||
const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importDecl);
|
||||
}
|
||||
else {
|
||||
// import |d,| * as ns from './file'
|
||||
const start = importClause.name.getStart(sourceFile);
|
||||
const nextToken = getTokenAtPosition(sourceFile, importClause.name.end);
|
||||
if (nextToken && nextToken.kind === SyntaxKind.CommaToken) {
|
||||
// shift first non-whitespace position after comma to the start position of the node
|
||||
return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) });
|
||||
}
|
||||
else {
|
||||
return deleteNode(importClause.name);
|
||||
}
|
||||
}
|
||||
|
||||
case SyntaxKind.NamespaceImport:
|
||||
const namespaceImport = <NamespaceImport>token.parent;
|
||||
if (namespaceImport.name === token && !(<ImportClause>namespaceImport.parent).name) {
|
||||
const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration);
|
||||
return deleteNode(importDecl);
|
||||
}
|
||||
else {
|
||||
const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1);
|
||||
if (previousToken && previousToken.kind === SyntaxKind.CommaToken) {
|
||||
const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart);
|
||||
return deleteRange({ pos: startPosition, end: namespaceImport.end });
|
||||
}
|
||||
return deleteRange(namespaceImport);
|
||||
}
|
||||
|
||||
default:
|
||||
return deleteDefault();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
|
||||
// token.parent is a variableDeclaration
|
||||
function deleteVariableDeclaration(varDecl: ts.VariableDeclaration): CodeAction[] | undefined {
|
||||
switch (varDecl.parent.parent.kind) {
|
||||
case SyntaxKind.ForStatement:
|
||||
const forStatement = <ForStatement>varDecl.parent.parent;
|
||||
const forInitializer = <VariableDeclarationList>forStatement.initializer;
|
||||
if (forInitializer.declarations.length === 1) {
|
||||
return deleteNode(forInitializer);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(varDecl);
|
||||
}
|
||||
|
||||
case SyntaxKind.ForOfStatement:
|
||||
const forOfStatement = <ForOfStatement>varDecl.parent.parent;
|
||||
Debug.assert(forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList);
|
||||
const forOfInitializer = <VariableDeclarationList>forOfStatement.initializer;
|
||||
return replaceNode(forOfInitializer.declarations[0], createObjectLiteral());
|
||||
|
||||
case SyntaxKind.ForInStatement:
|
||||
// There is no valid fix in the case of:
|
||||
// for .. in
|
||||
return undefined;
|
||||
|
||||
default:
|
||||
const variableStatement = <VariableStatement>varDecl.parent.parent;
|
||||
if (variableStatement.declarationList.declarations.length === 1) {
|
||||
return deleteNode(variableStatement);
|
||||
}
|
||||
else {
|
||||
return deleteNodeInList(varDecl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteNode(n: Node) {
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace ts.Completions {
|
||||
|
||||
function addStringLiteralCompletionsFromType(type: Type, result: Push<CompletionEntry>, typeChecker: TypeChecker): void {
|
||||
if (type && type.flags & TypeFlags.TypeParameter) {
|
||||
type = typeChecker.getApparentType(type);
|
||||
type = typeChecker.getBaseConstraintOfType(type);
|
||||
}
|
||||
if (!type) {
|
||||
return;
|
||||
@@ -487,7 +487,7 @@ namespace ts.Completions {
|
||||
// It has a left-hand side, so we're not in an opening JSX tag.
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxElement:
|
||||
@@ -1311,7 +1311,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
function isEqualityOperatorKind(kind: SyntaxKind) {
|
||||
return kind == SyntaxKind.EqualsEqualsToken ||
|
||||
return kind === SyntaxKind.EqualsEqualsToken ||
|
||||
kind === SyntaxKind.ExclamationEqualsToken ||
|
||||
kind === SyntaxKind.EqualsEqualsEqualsToken ||
|
||||
kind === SyntaxKind.ExclamationEqualsEqualsToken;
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace ts.DocumentHighlights {
|
||||
if (statement.kind === SyntaxKind.ContinueStatement) {
|
||||
continue;
|
||||
}
|
||||
// Fall through.
|
||||
// falls through
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ts.FindAllReferences {
|
||||
references: Entry[];
|
||||
}
|
||||
|
||||
type Definition =
|
||||
export type Definition =
|
||||
| { type: "symbol"; symbol: Symbol; node: Node }
|
||||
| { type: "label"; node: Identifier }
|
||||
| { type: "keyword"; node: ts.Node }
|
||||
@@ -20,7 +20,7 @@ namespace ts.FindAllReferences {
|
||||
node: Node;
|
||||
isInString?: true;
|
||||
}
|
||||
interface SpanEntry {
|
||||
export interface SpanEntry {
|
||||
type: "span";
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
@@ -108,10 +108,6 @@ namespace ts.FindAllReferences {
|
||||
switch (def.type) {
|
||||
case "symbol": {
|
||||
const { symbol, node } = def;
|
||||
const declarations = symbol.declarations;
|
||||
if (!declarations || declarations.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const { displayParts, kind } = getDefinitionKindAndDisplayParts(symbol, node, checker);
|
||||
const name = displayParts.map(p => p.text).join("");
|
||||
return { node, name, kind, displayParts };
|
||||
@@ -285,11 +281,6 @@ namespace ts.FindAllReferences.Core {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// The symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
||||
if (!symbol.declarations || !symbol.declarations.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options);
|
||||
}
|
||||
|
||||
@@ -1234,7 +1225,7 @@ namespace ts.FindAllReferences.Core {
|
||||
if (isObjectLiteralMethod(searchSpaceNode)) {
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
// falls through
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -1247,7 +1238,7 @@ namespace ts.FindAllReferences.Core {
|
||||
if (isExternalModule(<SourceFile>searchSpaceNode)) {
|
||||
return undefined;
|
||||
}
|
||||
// Fall through
|
||||
// falls through
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
break;
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace ts.formatting {
|
||||
sourceFile: SourceFileLike): TextChange[] {
|
||||
|
||||
// formatting context is used by rules provider
|
||||
const formattingContext = new FormattingContext(sourceFile, requestKind);
|
||||
const formattingContext = new FormattingContext(sourceFile, requestKind, options);
|
||||
let previousRangeHasError: boolean;
|
||||
let previousRange: TextRangeWithKind;
|
||||
let previousParent: Node;
|
||||
@@ -483,9 +483,8 @@ namespace ts.formatting {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if ((<MethodDeclaration>node).asteriskToken) {
|
||||
return SyntaxKind.AsteriskToken;
|
||||
}/*
|
||||
fall-through
|
||||
*/
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
return (<Declaration>node).name.kind;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user