diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index 8a2561af13a..fd048630ca1 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -561,7 +561,7 @@ interface Math { */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point (y,x). + * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 0b963774071..3344cf3197d 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -561,7 +561,7 @@ interface Math { */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point (y,x). + * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ @@ -1628,7 +1628,7 @@ interface IteratorResult { } interface Iterator { - next(): IteratorResult; + next(value?: any): IteratorResult; return?(value?: any): IteratorResult; throw?(e?: any): IteratorResult; } diff --git a/bin/lib.d.ts b/bin/lib.d.ts index 82a6fa8345c..17e87597583 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -561,7 +561,7 @@ interface Math { */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point (y,x). + * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ @@ -13878,7 +13878,7 @@ interface SourceBuffer extends EventTarget { videoTracks: VideoTrackList; abort(): void; appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: any): void; + appendBuffer(data: ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -13986,31 +13986,31 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: any): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: any): any; - digest(algorithm: Algorithm, data: any): any; - encrypt(algorithm: string, key: CryptoKey, data: any): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + digest(algorithm: string, data: ArrayBufferView): any; + digest(algorithm: Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: any): any; - sign(algorithm: Algorithm, key: CryptoKey, data: any): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: any, data: any): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: any, data: any): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; } @@ -14522,9 +14522,9 @@ interface WebGLRenderingContext { blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; bufferData(target: number, size: number, usage: number): void; + bufferData(target: number, size: ArrayBufferView, usage: number): void; bufferData(target: number, size: any, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; bufferSubData(target: number, offset: number, data: any): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; @@ -14533,8 +14533,8 @@ interface WebGLRenderingContext { clearStencil(s: number): void; colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; compileShader(shader: WebGLShader): void; - compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: any): void; - compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: any): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; createBuffer(): WebGLBuffer; @@ -14602,7 +14602,7 @@ interface WebGLRenderingContext { linkProgram(program: WebGLProgram): void; pixelStorei(pname: number, param: number): void; polygonOffset(factor: number, units: number): void; - readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: any): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; sampleCoverage(value: number, invert: boolean): void; scissor(x: number, y: number, width: number, height: number): void; @@ -16026,7 +16026,7 @@ interface NodeSelector { } interface RandomSource { - getRandomValues(array: any): any; + getRandomValues(array: ArrayBufferView): ArrayBufferView; } interface SVGAnimatedPathData { diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index d66afb9b27f..2c970a1cf52 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -12708,7 +12708,7 @@ interface SourceBuffer extends EventTarget { videoTracks: VideoTrackList; abort(): void; appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: any): void; + appendBuffer(data: ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -12816,31 +12816,31 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: any): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: any): any; - digest(algorithm: Algorithm, data: any): any; - encrypt(algorithm: string, key: CryptoKey, data: any): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + digest(algorithm: string, data: ArrayBufferView): any; + digest(algorithm: Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: any): any; - sign(algorithm: Algorithm, key: CryptoKey, data: any): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: any, data: any): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: any, data: any): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; } @@ -13352,9 +13352,9 @@ interface WebGLRenderingContext { blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; bufferData(target: number, size: number, usage: number): void; + bufferData(target: number, size: ArrayBufferView, usage: number): void; bufferData(target: number, size: any, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; bufferSubData(target: number, offset: number, data: any): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; @@ -13363,8 +13363,8 @@ interface WebGLRenderingContext { clearStencil(s: number): void; colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; compileShader(shader: WebGLShader): void; - compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: any): void; - compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: any): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; createBuffer(): WebGLBuffer; @@ -13432,7 +13432,7 @@ interface WebGLRenderingContext { linkProgram(program: WebGLProgram): void; pixelStorei(pname: number, param: number): void; polygonOffset(factor: number, units: number): void; - readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: any): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; sampleCoverage(value: number, invert: boolean): void; scissor(x: number, y: number, width: number, height: number): void; @@ -14856,7 +14856,7 @@ interface NodeSelector { } interface RandomSource { - getRandomValues(array: any): any; + getRandomValues(array: ArrayBufferView): ArrayBufferView; } interface SVGAnimatedPathData { diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index e2a76a04ae2..c2361d833d1 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -561,7 +561,7 @@ interface Math { */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point (y,x). + * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ @@ -1628,7 +1628,7 @@ interface IteratorResult { } interface Iterator { - next(): IteratorResult; + next(value?: any): IteratorResult; return?(value?: any): IteratorResult; throw?(e?: any): IteratorResult; } @@ -15356,7 +15356,7 @@ interface SourceBuffer extends EventTarget { videoTracks: VideoTrackList; abort(): void; appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: any): void; + appendBuffer(data: ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -15464,31 +15464,31 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: any): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: any): any; - digest(algorithm: Algorithm, data: any): any; - encrypt(algorithm: string, key: CryptoKey, data: any): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: any): any; + digest(algorithm: string, data: ArrayBufferView): any; + digest(algorithm: Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: any, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: any): any; - sign(algorithm: Algorithm, key: CryptoKey, data: any): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: any, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: any, data: any): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: any, data: any): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; + sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; } @@ -16000,9 +16000,9 @@ interface WebGLRenderingContext { blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; bufferData(target: number, size: number, usage: number): void; + bufferData(target: number, size: ArrayBufferView, usage: number): void; bufferData(target: number, size: any, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; bufferSubData(target: number, offset: number, data: any): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; @@ -16011,8 +16011,8 @@ interface WebGLRenderingContext { clearStencil(s: number): void; colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; compileShader(shader: WebGLShader): void; - compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: any): void; - compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: any): void; + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; createBuffer(): WebGLBuffer; @@ -16080,7 +16080,7 @@ interface WebGLRenderingContext { linkProgram(program: WebGLProgram): void; pixelStorei(pname: number, param: number): void; polygonOffset(factor: number, units: number): void; - readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: any): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; sampleCoverage(value: number, invert: boolean): void; scissor(x: number, y: number, width: number, height: number): void; @@ -17504,7 +17504,7 @@ interface NodeSelector { } interface RandomSource { - getRandomValues(array: any): any; + getRandomValues(array: ArrayBufferView): ArrayBufferView; } interface SVGAnimatedPathData { diff --git a/bin/tsc.js b/bin/tsc.js index 3323c446649..49db1f2cb85 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -275,6 +275,17 @@ var ts; return result; } ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1064,7 +1075,7 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, @@ -1366,7 +1377,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1387,8 +1398,8 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, @@ -1399,6 +1410,8 @@ var ts; Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1686,7 +1699,7 @@ var ts; function isLineBreak(ch) { // ES5 7.3: // The ECMAScript line terminator characters are listed in Table 3. - // Table 3 � Line Terminator Characters + // Table 3: Line Terminator Characters // Code Unit Value Name Formal Name // \u000A Line Feed // \u000D Carriage Return @@ -2873,10 +2886,7 @@ var ts; parent = node; if (symbolKind & 262128) { container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; + addToContainerChain(container); } if (isBlockScopeContainer) { setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 227); @@ -2886,6 +2896,12 @@ var ts; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function addToContainerChain(node) { + if (lastContainer) { + lastContainer.nextContainer = node; + } + lastContainer = node; + } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { case 205: @@ -3014,6 +3030,7 @@ var ts; default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); } @@ -3806,7 +3823,7 @@ var ts; var forStatement = parent_1; return (forStatement.initializer === node && forStatement.initializer.kind !== 199) || forStatement.condition === node || - forStatement.iterator === node; + forStatement.incrementor === node; case 187: case 188: var forInStatement = parent_1; @@ -4903,7 +4920,7 @@ var ts; case 186: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || - visitNode(cbNode, node.iterator) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 187: return visitNode(cbNode, node.initializer) || @@ -7112,7 +7129,7 @@ var ts; } parseExpected(22); if (token !== 17) { - forStatement.iterator = allowInAnd(parseExpression); + forStatement.incrementor = allowInAnd(parseExpression); } parseExpected(17); forOrForInOrForOfStatement = forStatement; @@ -8514,11 +8531,10 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; - var globalTypedPropertyDescriptorType; - var globalClassDecoratorType; - var globalParameterDecoratorType; - var globalPropertyDecoratorType; - var globalMethodDecoratorType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -10440,10 +10456,11 @@ var ts; } } } - function getDeclaredTypeOfClass(symbol) { + function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = links.declaredType = createObjectType(1024, symbol); + var kind = symbol.flags & 32 ? 1024 : 2048; + var type = links.declaredType = createObjectType(kind, symbol); var typeParameters = getTypeParametersOfClassOrInterface(symbol); if (typeParameters) { type.flags |= 4096; @@ -10453,32 +10470,6 @@ var ts; type.target = type; type.typeArguments = type.typeParameters; } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - return links.declaredType; - } - function getDeclaredTypeOfInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(2048, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); } return links.declaredType; } @@ -10529,11 +10520,8 @@ var ts; } function getDeclaredTypeOfSymbol(symbol) { ts.Debug.assert((symbol.flags & 16777216) === 0); - if (symbol.flags & 32) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & 64) { - return getDeclaredTypeOfInterface(symbol); + if (symbol.flags & (32 | 64)) { + return getDeclaredTypeOfClassOrInterface(symbol); } if (symbol.flags & 524288) { return getDeclaredTypeOfTypeAlias(symbol); @@ -10581,15 +10569,27 @@ var ts; } } } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + return type; + } function resolveClassOrInterfaceMembers(type) { - var members = type.symbol.members; - var callSignatures = type.declaredCallSignatures; - var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - var baseTypes = getBaseTypes(type); + var target = resolveDeclaredMembers(type); + var members = target.symbol.members; + var callSignatures = target.declaredCallSignatures; + var constructSignatures = target.declaredConstructSignatures; + var stringIndexType = target.declaredStringIndexType; + var numberIndexType = target.declaredNumberIndexType; + var baseTypes = getBaseTypes(target); if (baseTypes.length) { - members = createSymbolTable(type.declaredProperties); + members = createSymbolTable(target.declaredProperties); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; addInheritedMembers(members, getPropertiesOfObjectType(baseType)); @@ -10602,7 +10602,7 @@ var ts; setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function resolveTypeReferenceMembers(type) { - var target = type.target; + var target = resolveDeclaredMembers(type.target); var mapper = createTypeMapper(target.typeParameters, type.typeArguments); var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); @@ -10740,7 +10740,7 @@ var ts; callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClass(symbol); + var classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); @@ -10841,7 +10841,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop) { + if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 | 64)) { return undefined; } if (!props) { @@ -10951,7 +10951,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -11553,7 +11553,7 @@ var ts; return type; } function combineTypeMappers(mapper1, mapper2) { - return function (t) { return mapper2(mapper1(t)); }; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function instantiateTypeParameter(typeParameter, mapper) { var result = createType(512); @@ -15407,21 +15407,21 @@ var ts; case 201: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; case 132: - checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; case 134: case 136: case 137: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; case 129: - checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } @@ -15804,8 +15804,8 @@ var ts; } if (node.condition) checkExpression(node.condition); - if (node.iterator) - checkExpression(node.iterator); + if (node.incrementor) + checkExpression(node.incrementor); checkSourceElement(node.statement); } function checkForOfStatement(node) { @@ -16385,7 +16385,7 @@ var ts; return true; } var seen = {}; - ts.forEach(type.declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; @@ -17880,11 +17880,10 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); - globalClassDecoratorType = getGlobalType("ClassDecorator"); - globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); - globalMethodDecoratorType = getGlobalType("MethodDecorator"); - globalParameterDecoratorType = getGlobalType("ParameterDecorator"); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -20156,9 +20155,9 @@ var ts; ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; - var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; - var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; + var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; @@ -21773,7 +21772,7 @@ var ts; write(";"); emitOptional(" ", node.condition); write(";"); - emitOptional(" ", node.iterator); + emitOptional(" ", node.incrementor); write(")"); emitEmbeddedStatement(node.statement); } @@ -23811,8 +23810,18 @@ var ts; write("}"); } } - function emitAMDModule(node, startIndex) { - collectExternalModuleInfo(node); + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -23841,7 +23850,7 @@ var ts; else { importAliasName = getGeneratedNameForNode(importNode); } - if (importAliasName) { + if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } @@ -23849,11 +23858,6 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -23868,6 +23872,15 @@ var ts; write(", "); write(importAliasNames.join(", ")); } + } + function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + emitAMDDependencies(node, true); write(") {"); increaseIndent(); emitExportStarHelper(); @@ -23887,6 +23900,21 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } + function emitUMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); + emitAMDDependencies(node, false); + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } function emitES6Module(node, startIndex) { externalImports = undefined; exportSpecifiers = undefined; @@ -23956,6 +23984,9 @@ var ts; else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 3) { + emitUMDModule(node, startIndex); + } else { emitCommonJSModule(node, startIndex); } @@ -24441,7 +24472,7 @@ var ts; getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, - getCurrentDirectory: host.getCurrentDirectory, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, @@ -24450,14 +24481,14 @@ var ts; return program; function getEmitHost(writeFileCallback) { return { - getCanonicalFileName: host.getCanonicalFileName, + getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: host.getCurrentDirectory, - getNewLine: host.getNewLine, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || host.writeFile + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) }; } function getDiagnosticsProducingTypeChecker() { @@ -24663,6 +24694,53 @@ var ts; return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); } } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + var currentDirectory = host.getCurrentDirectory(); + ts.forEach(files, function (sourceFile) { + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); + if (!commonPathComponents) { + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + commonPathComponents.length = i; + break; + } + } + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var currentDirectory = host.getCurrentDirectory(); + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } function verifyCompilerOptions() { if (options.separateCompilation) { if (options.sourceMap) { @@ -24704,40 +24782,19 @@ var ts; diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || (options.mapRoot && (!options.out || firstExternalModuleSourceFile !== undefined))) { - var commonPathComponents; - ts.forEach(files, function (sourceFile) { - if (!(sourceFile.flags & 2048) - && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory()); - sourcePathComponents.pop(); - if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - commonPathComponents.length = i; - break; - } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - commonPathComponents = sourcePathComponents; - } - } - }); - commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { commonSourceDirectory += ts.directorySeparator; } } @@ -24804,11 +24861,12 @@ var ts; shortName: "m", type: { "commonjs": 1, - "amd": 2 + "amd": 2, + "umd": 3 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd }, { name: "noEmit", @@ -24864,6 +24922,13 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_emit_comments_to_output }, + { + name: "rootDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, { name: "separateCompilation", type: "boolean" @@ -24897,7 +24962,7 @@ var ts; type: { "es3": 0, "es5": 1, "es6": 2 }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 }, { name: "version", diff --git a/bin/tsserver.js b/bin/tsserver.js index b54ac96e5d0..d5b7fdd0094 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -275,6 +275,17 @@ var ts; return result; } ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1064,7 +1075,7 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, @@ -1366,7 +1377,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -1387,8 +1398,8 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, @@ -1399,6 +1410,8 @@ var ts; Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1686,7 +1699,7 @@ var ts; function isLineBreak(ch) { // ES5 7.3: // The ECMAScript line terminator characters are listed in Table 3. - // Table 3 � Line Terminator Characters + // Table 3: Line Terminator Characters // Code Unit Value Name Formal Name // \u000A Line Feed // \u000D Carriage Return @@ -2736,11 +2749,12 @@ var ts; shortName: "m", type: { "commonjs": 1, - "amd": 2 + "amd": 2, + "umd": 3 }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd }, { name: "noEmit", @@ -2796,6 +2810,13 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_emit_comments_to_output }, + { + name: "rootDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, { name: "separateCompilation", type: "boolean" @@ -2829,7 +2850,7 @@ var ts; type: { "es3": 0, "es5": 1, "es6": 2 }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 }, { name: "version", @@ -3640,7 +3661,7 @@ var ts; var forStatement = parent_1; return (forStatement.initializer === node && forStatement.initializer.kind !== 199) || forStatement.condition === node || - forStatement.iterator === node; + forStatement.incrementor === node; case 187: case 188: var forInStatement = parent_1; @@ -4737,7 +4758,7 @@ var ts; case 186: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || - visitNode(cbNode, node.iterator) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 187: return visitNode(cbNode, node.initializer) || @@ -6946,7 +6967,7 @@ var ts; } parseExpected(22); if (token !== 17) { - forStatement.iterator = allowInAnd(parseExpression); + forStatement.incrementor = allowInAnd(parseExpression); } parseExpected(17); forOrForInOrForOfStatement = forStatement; @@ -8437,10 +8458,7 @@ var ts; parent = node; if (symbolKind & 262128) { container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; + addToContainerChain(container); } if (isBlockScopeContainer) { setBlockScopeContainer(node, (symbolKind & 255504) === 0 && node.kind !== 227); @@ -8450,6 +8468,12 @@ var ts; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function addToContainerChain(node) { + if (lastContainer) { + lastContainer.nextContainer = node; + } + lastContainer = node; + } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { case 205: @@ -8578,6 +8602,7 @@ var ts; default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); } @@ -8857,11 +8882,10 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; - var globalTypedPropertyDescriptorType; - var globalClassDecoratorType; - var globalParameterDecoratorType; - var globalPropertyDecoratorType; - var globalMethodDecoratorType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -10783,10 +10807,11 @@ var ts; } } } - function getDeclaredTypeOfClass(symbol) { + function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = links.declaredType = createObjectType(1024, symbol); + var kind = symbol.flags & 32 ? 1024 : 2048; + var type = links.declaredType = createObjectType(kind, symbol); var typeParameters = getTypeParametersOfClassOrInterface(symbol); if (typeParameters) { type.flags |= 4096; @@ -10796,32 +10821,6 @@ var ts; type.target = type; type.typeArguments = type.typeParameters; } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); - } - return links.declaredType; - } - function getDeclaredTypeOfInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(2048, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); } return links.declaredType; } @@ -10872,11 +10871,8 @@ var ts; } function getDeclaredTypeOfSymbol(symbol) { ts.Debug.assert((symbol.flags & 16777216) === 0); - if (symbol.flags & 32) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & 64) { - return getDeclaredTypeOfInterface(symbol); + if (symbol.flags & (32 | 64)) { + return getDeclaredTypeOfClassOrInterface(symbol); } if (symbol.flags & 524288) { return getDeclaredTypeOfTypeAlias(symbol); @@ -10924,15 +10920,27 @@ var ts; } } } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1); + } + return type; + } function resolveClassOrInterfaceMembers(type) { - var members = type.symbol.members; - var callSignatures = type.declaredCallSignatures; - var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - var baseTypes = getBaseTypes(type); + var target = resolveDeclaredMembers(type); + var members = target.symbol.members; + var callSignatures = target.declaredCallSignatures; + var constructSignatures = target.declaredConstructSignatures; + var stringIndexType = target.declaredStringIndexType; + var numberIndexType = target.declaredNumberIndexType; + var baseTypes = getBaseTypes(target); if (baseTypes.length) { - members = createSymbolTable(type.declaredProperties); + members = createSymbolTable(target.declaredProperties); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; addInheritedMembers(members, getPropertiesOfObjectType(baseType)); @@ -10945,7 +10953,7 @@ var ts; setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function resolveTypeReferenceMembers(type) { - var target = type.target; + var target = resolveDeclaredMembers(type.target); var mapper = createTypeMapper(target.typeParameters, type.typeArguments); var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); @@ -11083,7 +11091,7 @@ var ts; callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClass(symbol); + var classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); @@ -11184,7 +11192,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop) { + if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 | 64)) { return undefined; } if (!props) { @@ -11294,7 +11302,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -11896,7 +11904,7 @@ var ts; return type; } function combineTypeMappers(mapper1, mapper2) { - return function (t) { return mapper2(mapper1(t)); }; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function instantiateTypeParameter(typeParameter, mapper) { var result = createType(512); @@ -15750,21 +15758,21 @@ var ts; case 201: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; case 132: - checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; case 134: case 136: case 137: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; case 129: - checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } @@ -16147,8 +16155,8 @@ var ts; } if (node.condition) checkExpression(node.condition); - if (node.iterator) - checkExpression(node.iterator); + if (node.incrementor) + checkExpression(node.incrementor); checkSourceElement(node.statement); } function checkForOfStatement(node) { @@ -16728,7 +16736,7 @@ var ts; return true; } var seen = {}; - ts.forEach(type.declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; @@ -18223,11 +18231,10 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); - globalClassDecoratorType = getGlobalType("ClassDecorator"); - globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); - globalMethodDecoratorType = getGlobalType("MethodDecorator"); - globalParameterDecoratorType = getGlobalType("ParameterDecorator"); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -20499,9 +20506,9 @@ var ts; ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; function emitFiles(resolver, host, targetSourceFile) { var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; - var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; - var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; - var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; + var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; + var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; @@ -22116,7 +22123,7 @@ var ts; write(";"); emitOptional(" ", node.condition); write(";"); - emitOptional(" ", node.iterator); + emitOptional(" ", node.incrementor); write(")"); emitEmbeddedStatement(node.statement); } @@ -24154,8 +24161,18 @@ var ts; write("}"); } } - function emitAMDModule(node, startIndex) { - collectExternalModuleInfo(node); + function emitAMDDependencies(node, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -24184,7 +24201,7 @@ var ts; else { importAliasName = getGeneratedNameForNode(importNode); } - if (importAliasName) { + if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } @@ -24192,11 +24209,6 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -24211,6 +24223,15 @@ var ts; write(", "); write(importAliasNames.join(", ")); } + } + function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + emitAMDDependencies(node, true); write(") {"); increaseIndent(); emitExportStarHelper(); @@ -24230,6 +24251,21 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } + function emitUMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); + emitAMDDependencies(node, false); + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } function emitES6Module(node, startIndex) { externalImports = undefined; exportSpecifiers = undefined; @@ -24299,6 +24335,9 @@ var ts; else if (compilerOptions.module === 2) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 3) { + emitUMDModule(node, startIndex); + } else { emitCommonJSModule(node, startIndex); } @@ -24784,7 +24823,7 @@ var ts; getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, - getCurrentDirectory: host.getCurrentDirectory, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, @@ -24793,14 +24832,14 @@ var ts; return program; function getEmitHost(writeFileCallback) { return { - getCanonicalFileName: host.getCanonicalFileName, + getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: host.getCurrentDirectory, - getNewLine: host.getNewLine, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || host.writeFile + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) }; } function getDiagnosticsProducingTypeChecker() { @@ -25006,6 +25045,53 @@ var ts; return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); } } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + var currentDirectory = host.getCurrentDirectory(); + ts.forEach(files, function (sourceFile) { + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); + if (!commonPathComponents) { + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + commonPathComponents.length = i; + break; + } + } + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var currentDirectory = host.getCurrentDirectory(); + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } function verifyCompilerOptions() { if (options.separateCompilation) { if (options.sourceMap) { @@ -25047,40 +25133,19 @@ var ts; diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || (options.mapRoot && (!options.out || firstExternalModuleSourceFile !== undefined))) { - var commonPathComponents; - ts.forEach(files, function (sourceFile) { - if (!(sourceFile.flags & 2048) - && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory()); - sourcePathComponents.pop(); - if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - commonPathComponents.length = i; - break; - } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - commonPathComponents = sourcePathComponents; - } - } - }); - commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { commonSourceDirectory += ts.directorySeparator; } } @@ -25368,8 +25433,8 @@ var ts; if (forStatement.condition) { return textSpan(forStatement.condition); } - if (forStatement.iterator) { - return textSpan(forStatement.iterator); + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); } } function spanInOpenBraceToken(node) { @@ -28003,6 +28068,8 @@ var ts; case 169: case 170: return true; + case 152: + case 203: case 208: case 198: case 129: @@ -28014,8 +28081,6 @@ var ts; return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; case 188: return context.currentTokenSpan.kind === 125 || context.nextTokenSpan.kind === 125; - case 152: - return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; } return false; }; @@ -34835,6 +34900,9 @@ var ts; if (lineText.charAt(i) == " ") { indentPosition--; } + else if (lineText.charAt(i) == "\t") { + indentPosition -= editorOptions.IndentSize; + } else { break; } diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index 2ce77b9fb70..00ddd433179 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -597,7 +597,7 @@ declare module "typescript" { interface ForStatement extends IterationStatement { initializer?: VariableDeclarationList | Expression; condition?: Expression; - iterator?: Expression; + incrementor?: Expression; } interface ForInStatement extends IterationStatement { initializer: VariableDeclarationList | Expression; @@ -1005,15 +1005,17 @@ declare module "typescript" { } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; + } + interface InterfaceTypeWithBaseTypes extends InterfaceType { + baseTypes: ObjectType[]; + } + interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; declaredStringIndexType: Type; declaredNumberIndexType: Type; } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; - } interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -1095,6 +1097,7 @@ declare module "typescript" { preserveConstEnums?: boolean; project?: string; removeComments?: boolean; + rootDir?: string; sourceMap?: boolean; sourceRoot?: string; suppressImplicitAnyIndexErrors?: boolean; @@ -1109,6 +1112,7 @@ declare module "typescript" { None = 0, CommonJS = 1, AMD = 2, + UMD = 3, } interface LineAndCharacter { line: number; diff --git a/bin/typescript.js b/bin/typescript.js index 8b29d8d0252..fefe3658fb4 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -541,6 +541,7 @@ var ts; ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; + ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (ScriptTarget) { @@ -960,6 +961,17 @@ var ts; return result; } ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1798,7 +1810,7 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, @@ -2100,7 +2112,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2121,8 +2133,8 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, @@ -2133,6 +2145,8 @@ var ts; Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2476,7 +2490,7 @@ var ts; function isLineBreak(ch) { // ES5 7.3: // The ECMAScript line terminator characters are listed in Table 3. - // Table 3 � Line Terminator Characters + // Table 3: Line Terminator Characters // Code Unit Value Name Formal Name // \u000A Line Feed // \u000D Carriage Return @@ -3764,10 +3778,7 @@ var ts; parent = node; if (symbolKind & 262128 /* IsContainer */) { container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; + addToContainerChain(container); } if (isBlockScopeContainer) { // in incremental scenarios we might reuse nodes that already have locals being allocated @@ -3783,6 +3794,12 @@ var ts; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function addToContainerChain(node) { + if (lastContainer) { + lastContainer.nextContainer = node; + } + lastContainer = node; + } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { case 205 /* ModuleDeclaration */: @@ -3916,6 +3933,7 @@ var ts; default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); } @@ -4818,7 +4836,7 @@ var ts; var forStatement = parent_1; return (forStatement.initializer === node && forStatement.initializer.kind !== 199 /* VariableDeclarationList */) || forStatement.condition === node || - forStatement.iterator === node; + forStatement.incrementor === node; case 187 /* ForInStatement */: case 188 /* ForOfStatement */: var forInStatement = parent_1; @@ -6077,7 +6095,7 @@ var ts; case 186 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || - visitNode(cbNode, node.iterator) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 187 /* ForInStatement */: return visitNode(cbNode, node.initializer) || @@ -8951,7 +8969,7 @@ var ts; } parseExpected(22 /* SemicolonToken */); if (token !== 17 /* CloseParenToken */) { - forStatement.iterator = allowInAnd(parseExpression); + forStatement.incrementor = allowInAnd(parseExpression); } parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; @@ -10712,11 +10730,10 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; - var globalTypedPropertyDescriptorType; - var globalClassDecoratorType; - var globalParameterDecoratorType; - var globalPropertyDecoratorType; - var globalMethodDecoratorType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -12927,10 +12944,11 @@ var ts; } } } - function getDeclaredTypeOfClass(symbol) { + function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = links.declaredType = createObjectType(1024 /* Class */, symbol); + var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; + var type = links.declaredType = createObjectType(kind, symbol); var typeParameters = getTypeParametersOfClassOrInterface(symbol); if (typeParameters) { type.flags |= 4096 /* Reference */; @@ -12940,32 +12958,6 @@ var ts; type.target = type; type.typeArguments = type.typeParameters; } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return links.declaredType; - } - function getDeclaredTypeOfInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(2048 /* Interface */, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096 /* Reference */; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); } return links.declaredType; } @@ -13016,11 +13008,8 @@ var ts; } function getDeclaredTypeOfSymbol(symbol) { ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); - if (symbol.flags & 32 /* Class */) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & 64 /* Interface */) { - return getDeclaredTypeOfInterface(symbol); + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getDeclaredTypeOfClassOrInterface(symbol); } if (symbol.flags & 524288 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); @@ -13068,15 +13057,27 @@ var ts; } } } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + return type; + } function resolveClassOrInterfaceMembers(type) { - var members = type.symbol.members; - var callSignatures = type.declaredCallSignatures; - var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - var baseTypes = getBaseTypes(type); + var target = resolveDeclaredMembers(type); + var members = target.symbol.members; + var callSignatures = target.declaredCallSignatures; + var constructSignatures = target.declaredConstructSignatures; + var stringIndexType = target.declaredStringIndexType; + var numberIndexType = target.declaredNumberIndexType; + var baseTypes = getBaseTypes(target); if (baseTypes.length) { - members = createSymbolTable(type.declaredProperties); + members = createSymbolTable(target.declaredProperties); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; addInheritedMembers(members, getPropertiesOfObjectType(baseType)); @@ -13089,7 +13090,7 @@ var ts; setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function resolveTypeReferenceMembers(type) { - var target = type.target; + var target = resolveDeclaredMembers(type.target); var mapper = createTypeMapper(target.typeParameters, type.typeArguments); var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); @@ -13234,7 +13235,7 @@ var ts; callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClass(symbol); + var classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); @@ -13341,7 +13342,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop) { + if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */)) { return undefined; } if (!props) { @@ -13460,7 +13461,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14105,7 +14106,7 @@ var ts; return type; } function combineTypeMappers(mapper1, mapper2) { - return function (t) { return mapper2(mapper1(t)); }; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function instantiateTypeParameter(typeParameter, mapper) { var result = createType(512 /* TypeParameter */); @@ -18689,21 +18690,21 @@ var ts; case 201 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; case 132 /* PropertyDeclaration */: - checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; case 134 /* MethodDeclaration */: case 136 /* GetAccessor */: case 137 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; case 129 /* Parameter */: - checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } @@ -19176,8 +19177,8 @@ var ts; } if (node.condition) checkExpression(node.condition); - if (node.iterator) - checkExpression(node.iterator); + if (node.incrementor) + checkExpression(node.incrementor); checkSourceElement(node.statement); } function checkForOfStatement(node) { @@ -19858,7 +19859,7 @@ var ts; return true; } var seen = {}; - ts.forEach(type.declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; @@ -21518,11 +21519,10 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); - globalClassDecoratorType = getGlobalType("ClassDecorator"); - globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); - globalMethodDecoratorType = getGlobalType("MethodDecorator"); - globalParameterDecoratorType = getGlobalType("ParameterDecorator"); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -24025,11 +24025,11 @@ var ts; // emit output for the __extends helper function var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; + var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function - var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; + var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; @@ -25861,7 +25861,7 @@ var ts; write(";"); emitOptional(" ", node.condition); write(";"); - emitOptional(" ", node.iterator); + emitOptional(" ", node.incrementor); write(")"); emitEmbeddedStatement(node.statement); } @@ -28162,25 +28162,24 @@ var ts; write("}"); } } - function emitAMDModule(node, startIndex) { - collectExternalModuleInfo(node); + function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // // This has the shape of // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to + // The location of the alias in the parameter list in the factory function needs to // match the position of the module name in the dependency list. // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - var aliasedModuleNames = []; // names of modules with corresponding parameter in the + var aliasedModuleNames = []; // names of modules with corresponding parameter in the // factory function. var unaliasedModuleNames = []; // names of modules with no corresponding parameters in // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // paramters need to match the indexes of the corresponding + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -28201,7 +28200,7 @@ var ts; if (moduleName.kind === 8 /* StringLiteral */) { externalModuleName = getLiteralText(moduleName); } - // Find the name of the module alais, if there is one + // Find the name of the module alias, if there is one var importAliasName = void 0; var namespaceDeclaration = getNamespaceDeclarationNode(importNode); if (namespaceDeclaration && !isDefaultImport(importNode)) { @@ -28210,7 +28209,7 @@ var ts; else { importAliasName = getGeneratedNameForNode(importNode); } - if (importAliasName) { + if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } @@ -28218,11 +28217,6 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -28237,6 +28231,15 @@ var ts; write(", "); write(importAliasNames.join(", ")); } + } + function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + emitAMDDependencies(node, true); write(") {"); increaseIndent(); emitExportStarHelper(); @@ -28256,6 +28259,22 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } + function emitUMDModule(node, startIndex) { + collectExternalModuleInfo(node); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); + emitAMDDependencies(node, false); + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } function emitES6Module(node, startIndex) { externalImports = undefined; exportSpecifiers = undefined; @@ -28332,6 +28351,9 @@ var ts; else if (compilerOptions.module === 2 /* AMD */) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 3 /* UMD */) { + emitUMDModule(node, startIndex); + } else { emitCommonJSModule(node, startIndex); } @@ -28855,7 +28877,7 @@ var ts; getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, - getCurrentDirectory: host.getCurrentDirectory, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, @@ -28864,14 +28886,14 @@ var ts; return program; function getEmitHost(writeFileCallback) { return { - getCanonicalFileName: host.getCanonicalFileName, + getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: host.getCurrentDirectory, - getNewLine: host.getNewLine, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || host.writeFile + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) }; } function getDiagnosticsProducingTypeChecker() { @@ -29095,6 +29117,57 @@ var ts; return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); } } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + var currentDirectory = host.getCurrentDirectory(); + ts.forEach(files, function (sourceFile) { + // Each file contributes into common source file path + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); // The base file name is not part of the common directory path + if (!commonPathComponents) { + // first file + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + // New common path found that is 0 -> i-1 + commonPathComponents.length = i; + break; + } + } + // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var currentDirectory = host.getCurrentDirectory(); + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } function verifyCompilerOptions() { if (options.separateCompilation) { if (options.sourceMap) { @@ -29139,7 +29212,7 @@ var ts; } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -29147,38 +29220,15 @@ var ts; options.sourceRoot || (options.mapRoot && (!options.out || firstExternalModuleSourceFile !== undefined))) { - var commonPathComponents; - ts.forEach(files, function (sourceFile) { - // Each file contributes into common source file path - if (!(sourceFile.flags & 2048 /* DeclarationFile */) - && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory()); - sourcePathComponents.pop(); // FileName is not part of directory - if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - // New common path found that is 0 -> i-1 - commonPathComponents.length = i; - break; - } - } - // If the fileComponent path completely matched and less than already found update the length - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - // first file - commonPathComponents = sourcePathComponents; - } - } - }); - commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path @@ -29249,11 +29299,12 @@ var ts; shortName: "m", type: { "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */ + "amd": 2 /* AMD */, + "umd": 3 /* UMD */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd }, { name: "noEmit", @@ -29309,6 +29360,13 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_emit_comments_to_output }, + { + name: "rootDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, { name: "separateCompilation", type: "boolean" @@ -29342,7 +29400,7 @@ var ts; type: { "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES6 */ }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 }, { name: "version", @@ -32767,6 +32825,10 @@ var ts; case 169 /* BinaryExpression */: case 170 /* ConditionalExpression */: return true; + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case 152 /* BindingElement */: + // equals in type X = ... + case 203 /* TypeAliasDeclaration */: // equal in import a = module('a'); case 208 /* ImportEqualsDeclaration */: // equal in let a = 0; @@ -32783,8 +32845,6 @@ var ts; // Technically, "of" is not a binary operator, but format it the same way as "in" case 188 /* ForOfStatement */: return context.currentTokenSpan.kind === 125 /* OfKeyword */ || context.nextTokenSpan.kind === 125 /* OfKeyword */; - case 152 /* BindingElement */: - return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; } return false; }; @@ -40444,8 +40504,8 @@ var ts; if (forStatement.condition) { return textSpan(forStatement.condition); } - if (forStatement.iterator) { - return textSpan(forStatement.iterator); + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); } } // Tokens: diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index e6d06765c27..d946fdcfe30 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -597,7 +597,7 @@ declare module ts { interface ForStatement extends IterationStatement { initializer?: VariableDeclarationList | Expression; condition?: Expression; - iterator?: Expression; + incrementor?: Expression; } interface ForInStatement extends IterationStatement { initializer: VariableDeclarationList | Expression; @@ -1005,15 +1005,17 @@ declare module ts { } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; + } + interface InterfaceTypeWithBaseTypes extends InterfaceType { + baseTypes: ObjectType[]; + } + interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; declaredStringIndexType: Type; declaredNumberIndexType: Type; } - interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; - } interface TypeReference extends ObjectType { target: GenericType; typeArguments: Type[]; @@ -1095,6 +1097,7 @@ declare module ts { preserveConstEnums?: boolean; project?: string; removeComments?: boolean; + rootDir?: string; sourceMap?: boolean; sourceRoot?: string; suppressImplicitAnyIndexErrors?: boolean; @@ -1109,6 +1112,7 @@ declare module ts { None = 0, CommonJS = 1, AMD = 2, + UMD = 3, } interface LineAndCharacter { line: number; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 8b29d8d0252..fefe3658fb4 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -541,6 +541,7 @@ var ts; ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; + ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; (function (ScriptTarget) { @@ -960,6 +961,17 @@ var ts; return result; } ts.arrayToMap = arrayToMap; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1798,7 +1810,7 @@ var ts; Line_terminator_not_permitted_before_arrow: { code: 1200, category: ts.DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: ts.DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: ts.DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: ts.DiagnosticCategory.Error, key: "Cannot compile external modules into 'amd', 'commonjs' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: ts.DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: ts.DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: ts.DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, @@ -2100,7 +2112,7 @@ var ts; Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Specify_module_code_generation_Colon_commonjs_amd_or_umd: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', or 'umd'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -2121,8 +2133,8 @@ var ts; Generates_corresponding_map_file: { code: 6043, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: ts.DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Argument_for_module_option_must_be_commonjs_amd_or_umd: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', or 'umd'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: ts.DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: ts.DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: ts.DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, @@ -2133,6 +2145,8 @@ var ts; Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2476,7 +2490,7 @@ var ts; function isLineBreak(ch) { // ES5 7.3: // The ECMAScript line terminator characters are listed in Table 3. - // Table 3 � Line Terminator Characters + // Table 3: Line Terminator Characters // Code Unit Value Name Formal Name // \u000A Line Feed // \u000D Carriage Return @@ -3764,10 +3778,7 @@ var ts; parent = node; if (symbolKind & 262128 /* IsContainer */) { container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; + addToContainerChain(container); } if (isBlockScopeContainer) { // in incremental scenarios we might reuse nodes that already have locals being allocated @@ -3783,6 +3794,12 @@ var ts; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function addToContainerChain(node) { + if (lastContainer) { + lastContainer.nextContainer = node; + } + lastContainer = node; + } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { case 205 /* ModuleDeclaration */: @@ -3916,6 +3933,7 @@ var ts; default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); } @@ -4818,7 +4836,7 @@ var ts; var forStatement = parent_1; return (forStatement.initializer === node && forStatement.initializer.kind !== 199 /* VariableDeclarationList */) || forStatement.condition === node || - forStatement.iterator === node; + forStatement.incrementor === node; case 187 /* ForInStatement */: case 188 /* ForOfStatement */: var forInStatement = parent_1; @@ -6077,7 +6095,7 @@ var ts; case 186 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || - visitNode(cbNode, node.iterator) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 187 /* ForInStatement */: return visitNode(cbNode, node.initializer) || @@ -8951,7 +8969,7 @@ var ts; } parseExpected(22 /* SemicolonToken */); if (token !== 17 /* CloseParenToken */) { - forStatement.iterator = allowInAnd(parseExpression); + forStatement.incrementor = allowInAnd(parseExpression); } parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; @@ -10712,11 +10730,10 @@ var ts; var globalESSymbolType; var globalIterableType; var anyArrayType; - var globalTypedPropertyDescriptorType; - var globalClassDecoratorType; - var globalParameterDecoratorType; - var globalPropertyDecoratorType; - var globalMethodDecoratorType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var tupleTypes = {}; var unionTypes = {}; var stringLiteralTypes = {}; @@ -12927,10 +12944,11 @@ var ts; } } } - function getDeclaredTypeOfClass(symbol) { + function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = links.declaredType = createObjectType(1024 /* Class */, symbol); + var kind = symbol.flags & 32 /* Class */ ? 1024 /* Class */ : 2048 /* Interface */; + var type = links.declaredType = createObjectType(kind, symbol); var typeParameters = getTypeParametersOfClassOrInterface(symbol); if (typeParameters) { type.flags |= 4096 /* Reference */; @@ -12940,32 +12958,6 @@ var ts; type.target = type; type.typeArguments = type.typeParameters; } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return links.declaredType; - } - function getDeclaredTypeOfInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(2048 /* Interface */, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096 /* Reference */; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); } return links.declaredType; } @@ -13016,11 +13008,8 @@ var ts; } function getDeclaredTypeOfSymbol(symbol) { ts.Debug.assert((symbol.flags & 16777216 /* Instantiated */) === 0); - if (symbol.flags & 32 /* Class */) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & 64 /* Interface */) { - return getDeclaredTypeOfInterface(symbol); + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getDeclaredTypeOfClassOrInterface(symbol); } if (symbol.flags & 524288 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); @@ -13068,15 +13057,27 @@ var ts; } } } + function resolveDeclaredMembers(type) { + if (!type.declaredProperties) { + var symbol = type.symbol; + type.declaredProperties = getNamedMembers(symbol.members); + type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); + type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); + } + return type; + } function resolveClassOrInterfaceMembers(type) { - var members = type.symbol.members; - var callSignatures = type.declaredCallSignatures; - var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - var baseTypes = getBaseTypes(type); + var target = resolveDeclaredMembers(type); + var members = target.symbol.members; + var callSignatures = target.declaredCallSignatures; + var constructSignatures = target.declaredConstructSignatures; + var stringIndexType = target.declaredStringIndexType; + var numberIndexType = target.declaredNumberIndexType; + var baseTypes = getBaseTypes(target); if (baseTypes.length) { - members = createSymbolTable(type.declaredProperties); + members = createSymbolTable(target.declaredProperties); for (var _i = 0; _i < baseTypes.length; _i++) { var baseType = baseTypes[_i]; addInheritedMembers(members, getPropertiesOfObjectType(baseType)); @@ -13089,7 +13090,7 @@ var ts; setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function resolveTypeReferenceMembers(type) { - var target = type.target; + var target = resolveDeclaredMembers(type.target); var mapper = createTypeMapper(target.typeParameters, type.typeArguments); var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); @@ -13234,7 +13235,7 @@ var ts; callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClass(symbol); + var classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); @@ -13341,7 +13342,7 @@ var ts; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop) { + if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */)) { return undefined; } if (!props) { @@ -13460,7 +13461,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 135 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -14105,7 +14106,7 @@ var ts; return type; } function combineTypeMappers(mapper1, mapper2) { - return function (t) { return mapper2(mapper1(t)); }; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function instantiateTypeParameter(typeParameter, mapper) { var result = createType(512 /* TypeParameter */); @@ -18689,21 +18690,21 @@ var ts; case 201 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); - var classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + var classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; case 132 /* PropertyDeclaration */: - checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; case 134 /* MethodDeclaration */: case 136 /* GetAccessor */: case 137 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); - var methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + var methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; case 129 /* Parameter */: - checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } @@ -19176,8 +19177,8 @@ var ts; } if (node.condition) checkExpression(node.condition); - if (node.iterator) - checkExpression(node.iterator); + if (node.incrementor) + checkExpression(node.incrementor); checkSourceElement(node.statement); } function checkForOfStatement(node) { @@ -19858,7 +19859,7 @@ var ts; return true; } var seen = {}; - ts.forEach(type.declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; for (var _i = 0; _i < baseTypes.length; _i++) { var base = baseTypes[_i]; @@ -21518,11 +21519,10 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); - globalClassDecoratorType = getGlobalType("ClassDecorator"); - globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); - globalMethodDecoratorType = getGlobalType("MethodDecorator"); - globalParameterDecoratorType = getGlobalType("ParameterDecorator"); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -24025,11 +24025,11 @@ var ts; // emit output for the __extends helper function var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; // emit output for the __decorate helper function - var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + var decorateHelper = "\nif (typeof __decorate !== \"function\") __decorate = function (decorators, target, key, desc) {\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") return Reflect.decorate(decorators, target, key, desc);\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; // emit output for the __metadata helper function - var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; + var metadataHelper = "\nif (typeof __metadata !== \"function\") __metadata = function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; // emit output for the __param helper function - var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; + var paramHelper = "\nif (typeof __param !== \"function\") __param = function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; var compilerOptions = host.getCompilerOptions(); var languageVersion = compilerOptions.target || 0 /* ES3 */; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; @@ -25861,7 +25861,7 @@ var ts; write(";"); emitOptional(" ", node.condition); write(";"); - emitOptional(" ", node.iterator); + emitOptional(" ", node.incrementor); write(")"); emitEmbeddedStatement(node.statement); } @@ -28162,25 +28162,24 @@ var ts; write("}"); } } - function emitAMDModule(node, startIndex) { - collectExternalModuleInfo(node); + function emitAMDDependencies(node, includeNonAmdDependencies) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // // This has the shape of // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to + // The location of the alias in the parameter list in the factory function needs to // match the position of the module name in the dependency list. // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - var aliasedModuleNames = []; // names of modules with corresponding parameter in the + var aliasedModuleNames = []; // names of modules with corresponding parameter in the // factory function. var unaliasedModuleNames = []; // names of modules with no corresponding parameters in // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // paramters need to match the indexes of the corresponding + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -28201,7 +28200,7 @@ var ts; if (moduleName.kind === 8 /* StringLiteral */) { externalModuleName = getLiteralText(moduleName); } - // Find the name of the module alais, if there is one + // Find the name of the module alias, if there is one var importAliasName = void 0; var namespaceDeclaration = getNamespaceDeclarationNode(importNode); if (namespaceDeclaration && !isDefaultImport(importNode)) { @@ -28210,7 +28209,7 @@ var ts; else { importAliasName = getGeneratedNameForNode(importNode); } - if (importAliasName) { + if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } @@ -28218,11 +28217,6 @@ var ts; unaliasedModuleNames.push(externalModuleName); } } - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -28237,6 +28231,15 @@ var ts; write(", "); write(importAliasNames.join(", ")); } + } + function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + emitAMDDependencies(node, true); write(") {"); increaseIndent(); emitExportStarHelper(); @@ -28256,6 +28259,22 @@ var ts; emitTempDeclarations(true); emitExportEquals(false); } + function emitUMDModule(node, startIndex) { + collectExternalModuleInfo(node); + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); + emitAMDDependencies(node, false); + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } function emitES6Module(node, startIndex) { externalImports = undefined; exportSpecifiers = undefined; @@ -28332,6 +28351,9 @@ var ts; else if (compilerOptions.module === 2 /* AMD */) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === 3 /* UMD */) { + emitUMDModule(node, startIndex); + } else { emitCommonJSModule(node, startIndex); } @@ -28855,7 +28877,7 @@ var ts; getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, getCommonSourceDirectory: function () { return commonSourceDirectory; }, emit: emit, - getCurrentDirectory: host.getCurrentDirectory, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, @@ -28864,14 +28886,14 @@ var ts; return program; function getEmitHost(writeFileCallback) { return { - getCanonicalFileName: host.getCanonicalFileName, + getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: host.getCurrentDirectory, - getNewLine: host.getNewLine, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFiles: program.getSourceFiles, - writeFile: writeFileCallback || host.writeFile + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError) { return host.writeFile(fileName, data, writeByteOrderMark, onError); }) }; } function getDiagnosticsProducingTypeChecker() { @@ -29095,6 +29117,57 @@ var ts; return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); } } + function computeCommonSourceDirectory(sourceFiles) { + var commonPathComponents; + var currentDirectory = host.getCurrentDirectory(); + ts.forEach(files, function (sourceFile) { + // Each file contributes into common source file path + if (ts.isDeclarationFile(sourceFile)) { + return; + } + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); // The base file name is not part of the common directory path + if (!commonPathComponents) { + // first file + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + // New common path found that is 0 -> i-1 + commonPathComponents.length = i; + break; + } + } + // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var currentDirectory = host.getCurrentDirectory(); + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0; _i < sourceFiles.length; _i++) { + var sourceFile = sourceFiles[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + return allFilesBelongToPath; + } function verifyCompilerOptions() { if (options.separateCompilation) { if (options.sourceMap) { @@ -29139,7 +29212,7 @@ var ts; } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_external_modules_into_amd_commonjs_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted @@ -29147,38 +29220,15 @@ var ts; options.sourceRoot || (options.mapRoot && (!options.out || firstExternalModuleSourceFile !== undefined))) { - var commonPathComponents; - ts.forEach(files, function (sourceFile) { - // Each file contributes into common source file path - if (!(sourceFile.flags & 2048 /* DeclarationFile */) - && !ts.fileExtensionIs(sourceFile.fileName, ".js")) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory()); - sourcePathComponents.pop(); // FileName is not part of directory - if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - // New common path found that is 0 -> i-1 - commonPathComponents.length = i; - break; - } - } - // If the fileComponent path completely matched and less than already found update the length - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - // first file - commonPathComponents = sourcePathComponents; - } - } - }); - commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path @@ -29249,11 +29299,12 @@ var ts; shortName: "m", type: { "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */ + "amd": 2 /* AMD */, + "umd": 3 /* UMD */ }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_or_umd, paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_amd_or_umd }, { name: "noEmit", @@ -29309,6 +29360,13 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_emit_comments_to_output }, + { + name: "rootDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: ts.Diagnostics.LOCATION + }, { name: "separateCompilation", type: "boolean" @@ -29342,7 +29400,7 @@ var ts; type: { "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES6 */ }, description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + error: ts.Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 }, { name: "version", @@ -32767,6 +32825,10 @@ var ts; case 169 /* BinaryExpression */: case 170 /* ConditionalExpression */: return true; + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case 152 /* BindingElement */: + // equals in type X = ... + case 203 /* TypeAliasDeclaration */: // equal in import a = module('a'); case 208 /* ImportEqualsDeclaration */: // equal in let a = 0; @@ -32783,8 +32845,6 @@ var ts; // Technically, "of" is not a binary operator, but format it the same way as "in" case 188 /* ForOfStatement */: return context.currentTokenSpan.kind === 125 /* OfKeyword */ || context.nextTokenSpan.kind === 125 /* OfKeyword */; - case 152 /* BindingElement */: - return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; } return false; }; @@ -40444,8 +40504,8 @@ var ts; if (forStatement.condition) { return textSpan(forStatement.condition); } - if (forStatement.iterator) { - return textSpan(forStatement.iterator); + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); } } // Tokens: diff --git a/doc/logo.svg b/doc/logo.svg new file mode 100644 index 00000000000..fc7e0fadd66 --- /dev/null +++ b/doc/logo.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/scripts/createBenchmark.ts b/scripts/createBenchmark.ts new file mode 100644 index 00000000000..659df53c915 --- /dev/null +++ b/scripts/createBenchmark.ts @@ -0,0 +1,124 @@ +/// +/// + +import * as fs from "fs"; +import * as path from "path"; +import * as typescript from "typescript"; +declare var ts: typeof typescript; + +var tsSourceDir = "../src"; +var tsBuildDir = "../built/local"; +var testOutputDir = "../built/benchmark"; +var sourceFiles = [ + "compiler/types.ts", + "compiler/core.ts", + "compiler/sys.ts", + "compiler/diagnosticInformationMap.generated.ts", + "compiler/scanner.ts", + "compiler/binder.ts", + "compiler/utilities.ts", + "compiler/parser.ts", + "compiler/checker.ts", + "compiler/declarationEmitter.ts", + "compiler/emitter.ts", + "compiler/program.ts", + "compiler/commandLineParser.ts", + "compiler/tsc.ts"]; + +// .ts sources for the compiler, used as a test input +var rawCompilerSources = ""; +sourceFiles.forEach(f=> { + rawCompilerSources += "\r\n" + fs.readFileSync(path.join(tsSourceDir, f)).toString(); +}); +var compilerSoruces = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`; + +// .js code for the compiler, what we are actuallty testing +var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString(); +rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.sys.args);", ""); + +// lib.d.ts sources +var rawLibSources = fs.readFileSync(path.join(tsBuildDir, "lib.d.ts")).toString(); +var libSoruces = `var libSources = ${JSON.stringify(rawLibSources) };`; + +// write test output +if (!fs.existsSync(testOutputDir)) { + fs.mkdirSync(testOutputDir); +} + +// 1. compiler ts sources, used to test +fs.writeFileSync( + path.join(testOutputDir, "compilerSources.js"), + `${ compilerSoruces } \r\n ${ libSoruces }`); + +// 2. the compiler js sources + a call the compiler +fs.writeFileSync( + path.join(testOutputDir, "benchmarktsc.js"), + `${ rawCompilerJavaScript }\r\n${ compile.toString() }\r\ncompile(compilerSources, libSources);`); + +// 3. test html file to drive the test +fs.writeFileSync( + path.join(testOutputDir, "benchmarktsc.html"), + ` + + + + Typescript 1.1 Compiler + + + +
Status: Running
+
End-to-End Time: N/A
+ + + + + +`); + +function compile(compilerSources, librarySources) { + var program = ts.createProgram( + ["lib.d.ts", "compiler.ts"], + { + noResolve: true, + out: "compiler.js", + removeComments: true, + target: ts.ScriptTarget.ES3 + }, { + getDefaultLibFileName: () => "lib.d.ts", + getSourceFile: (filename, languageVersion) => { + var source: string; + if (filename === "lib.d.ts") source = librarySources; + else if (filename === "compiler.ts") source = compilerSources; + else console.error("Unexpected read file request: " + filename); + + return ts.createSourceFile(filename, source, languageVersion); + }, + writeFile: (filename, data, writeByteOrderMark) => { + if (filename !== "compiler.js") + console.error("Unexpected write file request: " + filename); + // console.log(data); + }, + getCurrentDirectory: () => "", + getCanonicalFileName: (filename) => filename, + useCaseSensitiveFileNames: () => false, + getNewLine: () => "\r\n" + }); + + var emitOutput = program.emit(); + + var errors = program.getSyntacticDiagnostics() + .concat(program.getSemanticDiagnostics()) + .concat(program.getGlobalDiagnostics()) + .concat(emitOutput.diagnostics); + + if (errors.length) { + console.error("Unexpected errors."); + errors.forEach(e=> console.log(`${e.code}: ${e.messageText}`)) + } +} diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9d6d9fab35b..170f3d3c830 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -239,11 +239,7 @@ module ts { if (symbolKind & SymbolFlags.IsContainer) { container = node; - if (lastContainer) { - lastContainer.nextContainer = container; - } - - lastContainer = container; + addToContainerChain(container); } if (isBlockScopeContainer) { @@ -262,6 +258,14 @@ module ts { blockScopeContainer = savedBlockScopeContainer; } + function addToContainerChain(node: Node) { + if (lastContainer) { + lastContainer.nextContainer = node; + } + + lastContainer = node; + } + function bindDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) { switch (container.kind) { case SyntaxKind.ModuleDeclaration: @@ -403,6 +407,7 @@ module ts { default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; + addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a6973bb273b..40a6b2e3f72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -114,11 +114,10 @@ module ts { let globalIterableType: ObjectType; let anyArrayType: Type; - let globalTypedPropertyDescriptorType: ObjectType; - let globalClassDecoratorType: ObjectType; - let globalParameterDecoratorType: ObjectType; - let globalPropertyDecoratorType: ObjectType; - let globalMethodDecoratorType: ObjectType; + let getGlobalClassDecoratorType: () => ObjectType; + let getGlobalParameterDecoratorType: () => ObjectType; + let getGlobalPropertyDecoratorType: () => ObjectType; + let getGlobalMethodDecoratorType: () => ObjectType; let tupleTypes: Map = {}; let unionTypes: Map = {}; @@ -2516,10 +2515,11 @@ module ts { } } - function getDeclaredTypeOfClass(symbol: Symbol): InterfaceType { + function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType { let links = getSymbolLinks(symbol); if (!links.declaredType) { - let type = links.declaredType = createObjectType(TypeFlags.Class, symbol); + let kind = symbol.flags & SymbolFlags.Class ? TypeFlags.Class : TypeFlags.Interface; + let type = links.declaredType = createObjectType(kind, symbol); let typeParameters = getTypeParametersOfClassOrInterface(symbol); if (typeParameters) { type.flags |= TypeFlags.Reference; @@ -2529,35 +2529,6 @@ module ts { (type).target = type; (type).typeArguments = type.typeParameters; } - - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); - } - return links.declaredType; - } - - function getDeclaredTypeOfInterface(symbol: Symbol): InterfaceType { - let links = getSymbolLinks(symbol); - if (!links.declaredType) { - let type = links.declaredType = createObjectType(TypeFlags.Interface, symbol); - let typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= TypeFlags.Reference; - type.typeParameters = typeParameters; - (type).instantiations = {}; - (type).instantiations[getTypeListId(type.typeParameters)] = type; - (type).target = type; - (type).typeArguments = type.typeParameters; - } - - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); } return links.declaredType; } @@ -2613,11 +2584,8 @@ module ts { function getDeclaredTypeOfSymbol(symbol: Symbol): Type { Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0); - if (symbol.flags & SymbolFlags.Class) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & SymbolFlags.Interface) { - return getDeclaredTypeOfInterface(symbol); + if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + return getDeclaredTypeOfClassOrInterface(symbol); } if (symbol.flags & SymbolFlags.TypeAlias) { return getDeclaredTypeOfTypeAlias(symbol); @@ -2666,15 +2634,28 @@ module ts { } } + function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers { + if (!(type).declaredProperties) { + var symbol = type.symbol; + (type).declaredProperties = getNamedMembers(symbol.members); + (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); + (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); + (type).declaredStringIndexType = getIndexTypeOfSymbol(symbol, IndexKind.String); + (type).declaredNumberIndexType = getIndexTypeOfSymbol(symbol, IndexKind.Number); + } + return type; + } + function resolveClassOrInterfaceMembers(type: InterfaceType): void { - let members = type.symbol.members; - let callSignatures = type.declaredCallSignatures; - let constructSignatures = type.declaredConstructSignatures; - let stringIndexType = type.declaredStringIndexType; - let numberIndexType = type.declaredNumberIndexType; - let baseTypes = getBaseTypes(type); + let target = resolveDeclaredMembers(type); + let members = target.symbol.members; + let callSignatures = target.declaredCallSignatures; + let constructSignatures = target.declaredConstructSignatures; + let stringIndexType = target.declaredStringIndexType; + let numberIndexType = target.declaredNumberIndexType; + let baseTypes = getBaseTypes(target); if (baseTypes.length) { - members = createSymbolTable(type.declaredProperties); + members = createSymbolTable(target.declaredProperties); for (let baseType of baseTypes) { addInheritedMembers(members, getPropertiesOfObjectType(baseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(baseType, SignatureKind.Call)); @@ -2687,7 +2668,7 @@ module ts { } function resolveTypeReferenceMembers(type: TypeReference): void { - let target = type.target; + let target = resolveDeclaredMembers(type.target); let mapper = createTypeMapper(target.typeParameters, type.typeArguments); let members = createInstantiatedSymbolTable(target.declaredProperties, mapper); let callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); @@ -2843,7 +2824,7 @@ module ts { callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & SymbolFlags.Class) { - let classType = getDeclaredTypeOfClass(symbol); + let classType = getDeclaredTypeOfClassOrInterface(symbol); constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); @@ -2956,7 +2937,7 @@ module ts { let type = getApparentType(current); if (type !== unknownType) { let prop = getPropertyOfType(type, name); - if (!prop) { + if (!prop || getDeclarationFlagsFromSymbol(prop) & (NodeFlags.Private | NodeFlags.Protected)) { return undefined; } if (!props) { @@ -3084,7 +3065,7 @@ module ts { function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { let links = getNodeLinks(declaration); if (!links.resolvedSignature) { - let classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClass((declaration.parent).symbol) : undefined; + let classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface((declaration.parent).symbol) : undefined; let typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; let parameters: Symbol[] = []; @@ -3788,7 +3769,7 @@ module ts { } function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { - return t => mapper2(mapper1(t)); + return t => instantiateType(mapper1(t), mapper2); } function instantiateTypeParameter(typeParameter: TypeParameter, mapper: TypeMapper): TypeParameter { @@ -3859,7 +3840,7 @@ module ts { function instantiateType(type: Type, mapper: TypeMapper): Type { if (mapper !== identityMapper) { if (type.flags & TypeFlags.TypeParameter) { - return mapper(type); + return mapper(type); } if (type.flags & TypeFlags.Anonymous) { return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ? @@ -8808,24 +8789,24 @@ module ts { case SyntaxKind.ClassDeclaration: let classSymbol = getSymbolOfNode(node.parent); let classConstructorType = getTypeOfSymbol(classSymbol); - let classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]); + let classDecoratorType = instantiateSingleCallFunctionType(getGlobalClassDecoratorType(), [classConstructorType]); checkTypeAssignableTo(exprType, classDecoratorType, node); break; case SyntaxKind.PropertyDeclaration: - checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalPropertyDecoratorType(), node); break; case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: let methodType = getTypeOfNode(node.parent); - let methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]); + let methodDecoratorType = instantiateSingleCallFunctionType(getGlobalMethodDecoratorType(), [methodType]); checkTypeAssignableTo(exprType, methodDecoratorType, node); break; case SyntaxKind.Parameter: - checkTypeAssignableTo(exprType, globalParameterDecoratorType, node); + checkTypeAssignableTo(exprType, getGlobalParameterDecoratorType(), node); break; } } @@ -9367,7 +9348,7 @@ module ts { } if (node.condition) checkExpression(node.condition); - if (node.iterator) checkExpression(node.iterator); + if (node.incrementor) checkExpression(node.incrementor); checkSourceElement(node.statement); } @@ -10152,7 +10133,7 @@ module ts { } let seen: Map<{ prop: Symbol; containingType: Type }> = {}; - forEach(type.declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); + forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); let ok = true; for (let base of baseTypes) { @@ -10708,9 +10689,15 @@ module ts { } checkExternalModuleExports(container); - if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (node.isExportEquals) { + if (languageVersion >= ScriptTarget.ES6) { + // export assignment is deprecated in es6 or above + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + } + else if (compilerOptions.module === ModuleKind.System) { + // system modules does not support export assignment + grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); + } } } @@ -11533,9 +11520,11 @@ module ts { function getExportNameSubstitution(symbol: Symbol, location: Node, getGeneratedNameForNode: (Node: Node) => string): string { if (isExternalModuleSymbol(symbol.parent)) { - // If this is es6 or higher, just use the name of the export + // 1. If this is es6 or higher, just use the name of the export // no need to qualify it. - if (languageVersion >= ScriptTarget.ES6) { + // 2. export mechanism for System modules is different from CJS\AMD + // and it does not need qualifications for exports + if (languageVersion >= ScriptTarget.ES6 || compilerOptions.module === ModuleKind.System) { return undefined; } return "exports." + unescapeIdentifier(symbol.name); @@ -11896,6 +11885,15 @@ module ts { return !!resolveName(location, name, SymbolFlags.Value, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } + function getReferencedValueDeclaration(reference: Identifier): Declaration { + Debug.assert(!nodeIsSynthesized(reference)); + let symbol = + getNodeLinks(reference).resolvedSymbol || + resolveName(reference, reference.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + + return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration; + } + function getBlockScopedVariableId(n: Identifier): number { Debug.assert(!nodeIsSynthesized(n)); @@ -11954,6 +11952,7 @@ module ts { resolvesToSomeValue, collectLinkedAliases, getBlockScopedVariableId, + getReferencedValueDeclaration, serializeTypeOfNode, serializeParameterTypesOfNode, serializeReturnTypeOfNode, @@ -11987,11 +11986,10 @@ module ts { globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); - globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1); - globalClassDecoratorType = getGlobalType("ClassDecorator"); - globalPropertyDecoratorType = getGlobalType("PropertyDecorator"); - globalMethodDecoratorType = getGlobalType("MethodDecorator"); - globalParameterDecoratorType = getGlobalType("ParameterDecorator"); + getGlobalClassDecoratorType = memoize(() => getGlobalType("ClassDecorator")); + getGlobalPropertyDecoratorType = memoize(() => getGlobalType("PropertyDecorator")); + getGlobalMethodDecoratorType = memoize(() => getGlobalType("MethodDecorator")); + getGlobalParameterDecoratorType = memoize(() => getGlobalType("ParameterDecorator")); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. @@ -12018,7 +12016,7 @@ module ts { function isReservedWordInStrictMode(node: Identifier): boolean { // Check that originalKeywordKind is less than LastFutureReservedWord to see if an Identifier is a strict-mode reserved word return (node.parserContextFlags & ParserContextFlags.StrictMode) && - (node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord); + (SyntaxKind.FirstFutureReservedWord <= node.originalKeywordKind && node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord); } function reportStrictModeGrammarErrorInClassDeclaration(identifier: Identifier, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean { @@ -12038,7 +12036,7 @@ module ts { let nameBindings = impotClause.namedBindings; if (nameBindings.kind === SyntaxKind.NamespaceImport) { let name = (nameBindings).name; - if (name.originalKeywordKind) { + if (isReservedWordInStrictMode(name)) { let nameText = declarationNameToString(name); return grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } @@ -12047,7 +12045,7 @@ module ts { let reportError = false; for (let element of (nameBindings).elements) { let name = element.name; - if (name.originalKeywordKind) { + if (isReservedWordInStrictMode(name)) { let nameText = declarationNameToString(name); reportError = reportError || grammarErrorOnNode(name, Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode, nameText); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e1a0063e513..15a67db77e0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -58,11 +58,13 @@ module ts { shortName: "m", type: { "commonjs": ModuleKind.CommonJS, - "amd": ModuleKind.AMD + "amd": ModuleKind.AMD, + "system": ModuleKind.System, + "umd": ModuleKind.UMD, }, - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, paramType: Diagnostics.KIND, - error: Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd + error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd }, { name: "noEmit", @@ -118,6 +120,13 @@ module ts { type: "boolean", description: Diagnostics.Do_not_emit_comments_to_output, }, + { + name: "rootDir", + type: "string", + isFilePath: true, + description: Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + paramType: Diagnostics.LOCATION, + }, { name: "separateCompilation", type: "boolean", @@ -151,7 +160,7 @@ module ts { type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 }, description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: Diagnostics.VERSION, - error: Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 + error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6 }, { name: "version", @@ -285,12 +294,27 @@ module ts { * Read tsconfig.json file * @param fileName The path to the config file */ - export function readConfigFile(fileName: string): any { + export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } { try { var text = sys.readFile(fileName); - return /\S/.test(text) ? JSON.parse(text) : {}; } catch (e) { + return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileText(fileName, text); + } + + /** + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ + export function parseConfigFileText(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } { + try { + return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + } + catch (e) { + return { error: createCompilerDiagnostic(Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } @@ -300,7 +324,7 @@ module ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine { + export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine { var errors: Diagnostic[] = []; return { @@ -359,7 +383,7 @@ module ts { } } else { - var sysFiles = sys.readDirectory(basePath, ".ts"); + var sysFiles = host.readDirectory(basePath, ".ts"); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 80840068332..6383108b0d6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -281,6 +281,17 @@ module ts { return result; } + export function memoize(callback: () => T): () => T { + let value: T; + return () => { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string { baseIndex = baseIndex || 0; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index d683333e1d4..b44d9379509 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -161,7 +161,7 @@ module ts { Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." }, + Cannot_compile_external_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." }, Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, @@ -175,6 +175,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" }, Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Type_expected_0_is_a_reserved_word_in_strict_mode_Module_is_automatically_in_strict_mode: { code: 1217, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Module is automatically in strict mode." }, + Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -439,6 +440,7 @@ module ts { Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." }, + Failed_to_parse_file_0_Colon_1: { code: 5014, category: DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, @@ -467,7 +469,7 @@ module ts { Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, + Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." }, Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." }, @@ -488,8 +490,8 @@ module ts { Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, Unterminated_quoted_string_in_response_file_0: { code: 6045, category: DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, + Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, + Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, @@ -500,6 +502,8 @@ module ts { Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, + Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, + File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 915134d8cde..2ab6b8358eb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -631,7 +631,7 @@ "category": "Error", "code": 1203 }, - "Cannot compile external modules into amd or commonjs when targeting es6 or higher.": { + "Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.": { "category": "Error", "code": 1204 }, @@ -687,6 +687,10 @@ "category": "Error", "code": 1217 }, + "Export assignment is not supported when '--module' flag is 'system'.": { + "category": "Error", + "code": 1218 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -1744,6 +1748,10 @@ "category": "Error", "code": 5013 }, + "Failed to parse file '{0}': {1}.": { + "category": "Error", + "code": 5014 + }, "Unknown compiler option '{0}'.": { "category": "Error", "code": 5023 @@ -1857,7 +1865,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'commonjs' or 'amd'": { + "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'": { "category": "Message", "code": 6016 }, @@ -1941,11 +1949,11 @@ "category": "Error", "code": 6045 }, - "Argument for '--module' option must be 'commonjs' or 'amd'.": { + "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'.": { "category": "Error", "code": 6046 }, - "Argument for '--target' option must be 'es3', 'es5', or 'es6'.": { + "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'.": { "category": "Error", "code": 6047 }, @@ -1989,6 +1997,15 @@ "category": "Message", "code": 6057 }, + "Specifies the root directory of input files. Use to control the output directory structure with --outDir.": { + "category": "Message", + "code": 6058 + }, + "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files.": { + "category": "Error", + "code": 6059 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.js b/src/compiler/emitter.js new file mode 100644 index 00000000000..9a6b96640c9 --- /dev/null +++ b/src/compiler/emitter.js @@ -0,0 +1,5229 @@ +/// +/// +/* @internal */ +var ts; +(function (ts) { + function isExternalModuleOrDeclarationFile(sourceFile) { + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); + } + ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature + function emitFiles(resolver, host, targetSourceFile) { + // emit output for the __extends helper function + var extendsHelper = "\nvar __extends = this.__extends || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n __.prototype = b.prototype;\n d.prototype = new __();\n};"; + // emit output for the __decorate helper function + var decorateHelper = "\nvar __decorate = this.__decorate || (typeof Reflect === \"object\" && Reflect.decorate) || function (decorators, target, key, desc) {\n switch (arguments.length) {\n case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);\n case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);\n case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);\n }\n};"; + // emit output for the __metadata helper function + var metadataHelper = "\nvar __metadata = this.__metadata || (typeof Reflect === \"object\" && Reflect.metadata) || function () { };"; + // emit output for the __param helper function + var paramHelper = "\nvar __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };"; + var compilerOptions = host.getCompilerOptions(); + var languageVersion = compilerOptions.target || 0 /* ES3 */; + var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; + var diagnostics = []; + var newLine = host.getNewLine(); + if (targetSourceFile === undefined) { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); + emitFile(jsFilePath, sourceFile); + } + }); + if (compilerOptions.out) { + emitFile(compilerOptions.out); + } + } + else { + // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) + if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + emitFile(compilerOptions.out); + } + } + // Sort and make the unique list of diagnostics + diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); + return { + emitSkipped: false, + diagnostics: diagnostics, + sourceMaps: sourceMapDataList + }; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + function isUniqueLocalName(name, container) { + for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { + return false; + } + } + } + return true; + } + function emitJavaScript(jsFilePath, root) { + var writer = ts.createTextWriter(newLine); + var write = writer.write; + var writeTextOfNode = writer.writeTextOfNode; + var writeLine = writer.writeLine; + var increaseIndent = writer.increaseIndent; + var decreaseIndent = writer.decreaseIndent; + var currentSourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + var exportFunctionForFile; + var generatedNameSet = {}; + var nodeToGeneratedName = []; + var blockScopedVariableToGeneratedName; + var computedPropertyNamesToGeneratedNames; + var extendsEmitted = false; + var decorateEmitted = false; + var paramEmitted = false; + var tempFlags = 0; + var tempVariables; + var tempParameters; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStars; + /** write emitted output to disk*/ + var writeEmittedFiles = writeJavaScriptFile; + var detachedCommentsInfo; + var writeComment = ts.writeCommentRange; + /** Emit a node */ + var emit = emitNodeWithoutSourceMap; + /** Called just before starting emit of a node */ + var emitStart = function (node) { }; + /** Called once the emit of the node is done */ + var emitEnd = function (node) { }; + /** Emit the text for the given token that comes after startPos + * This by default writes the text provided with the given tokenKind + * but if optional emitFn callback is provided the text is emitted using the callback instead of default text + * @param tokenKind the kind of the token to search and emit + * @param startPos the position in the source to start searching for the token + * @param emitFn if given will be invoked to emit the text instead of actual token emit */ + var emitToken = emitTokenText; + /** Called to before starting the lexical scopes as in function/class in the emitted code because of node + * @param scopeDeclaration node that starts the lexical scope + * @param scopeName Optional name of this scope instead of deducing one from the declaration node */ + var scopeEmitStart = function (scopeDeclaration, scopeName) { }; + /** Called after coming out of the scope */ + var scopeEmitEnd = function () { }; + /** Sourcemap data that will get encoded */ + var sourceMapData; + if (compilerOptions.sourceMap) { + initializeEmitterWithSourceMaps(); + } + if (root) { + // Do not call emit directly. It does not set the currentSourceFile. + emitSourceFile(root); + } + else { + ts.forEach(host.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + emitSourceFile(sourceFile); + } + }); + } + writeLine(); + writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + return; + function emitSourceFile(sourceFile) { + currentSourceFile = sourceFile; + exportFunctionForFile = undefined; + emit(sourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentSourceFile.identifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + // Return the next available name in the pattern _a ... _z, _0, _1, ... + // TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name. + // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name)) { + tempFlags |= flags; + return name; + } + } + while (true) { + var count = tempFlags & 268435455 /* CountMask */; + tempFlags++; + // Skip over 'i' and 'n' + if (count !== 8 && count !== 13) { + var name_1 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_1)) { + return name_1; + } + } + } + } + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName) { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function assignGeneratedName(node, name) { + nodeToGeneratedName[ts.getNodeId(node)] = ts.unescapeIdentifier(name); + } + function generateNameForFunctionOrClassDeclaration(node) { + if (!node.name) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForModuleOrEnum(node) { + if (node.name.kind === 65 /* Identifier */) { + var name_2 = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + assignGeneratedName(node, isUniqueLocalName(name_2, node) ? name_2 : makeUniqueName(name_2)); + } + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 8 /* StringLiteral */ ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + assignGeneratedName(node, makeUniqueName(baseName)); + } + function generateNameForImportDeclaration(node) { + if (node.importClause) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportDeclaration(node) { + if (node.moduleSpecifier) { + generateNameForImportOrExportDeclaration(node); + } + } + function generateNameForExportAssignment(node) { + if (node.expression && node.expression.kind !== 65 /* Identifier */) { + assignGeneratedName(node, makeUniqueName("default")); + } + } + function generateNameForNode(node) { + switch (node.kind) { + case 200 /* FunctionDeclaration */: + case 201 /* ClassDeclaration */: + case 174 /* ClassExpression */: + generateNameForFunctionOrClassDeclaration(node); + break; + case 205 /* ModuleDeclaration */: + generateNameForModuleOrEnum(node); + generateNameForNode(node.body); + break; + case 204 /* EnumDeclaration */: + generateNameForModuleOrEnum(node); + break; + case 209 /* ImportDeclaration */: + generateNameForImportDeclaration(node); + break; + case 215 /* ExportDeclaration */: + generateNameForExportDeclaration(node); + break; + case 214 /* ExportAssignment */: + generateNameForExportAssignment(node); + break; + } + } + function getGeneratedNameForNode(node) { + var nodeId = ts.getNodeId(node); + if (!nodeToGeneratedName[nodeId]) { + generateNameForNode(node); + } + return nodeToGeneratedName[nodeId]; + } + function initializeEmitterWithSourceMaps() { + var sourceMapDir; // The directory in which sourcemap will be + // Current source map file and its index in the sources list + var sourceMapSourceIndex = -1; + // Names and its index map + var sourceMapNameIndexMap = {}; + var sourceMapNameIndices = []; + function getSourceMapNameIndex() { + return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; + } + // Last recorded and encoded spans + var lastRecordedSourceMapSpan; + var lastEncodedSourceMapSpan = { + emittedLine: 1, + emittedColumn: 1, + sourceLine: 1, + sourceColumn: 1, + sourceIndex: 0 + }; + var lastEncodedNameIndex = 0; + // Encoding for sourcemap span + function encodeLastRecordedSourceMapSpan() { + if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { + return; + } + var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; + // Line/Comma delimiters + if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { + // Emit comma to separate the entry + if (sourceMapData.sourceMapMappings) { + sourceMapData.sourceMapMappings += ","; + } + } + else { + // Emit line delimiters + for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { + sourceMapData.sourceMapMappings += ";"; + } + prevEncodedEmittedColumn = 1; + } + // 1. Relative Column 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); + // 2. Relative sourceIndex + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); + // 3. Relative sourceLine 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); + // 4. Relative sourceColumn 0 based + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); + // 5. Relative namePosition 0 based + if (lastRecordedSourceMapSpan.nameIndex >= 0) { + sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); + lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; + } + lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; + sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); + function base64VLQFormatEncode(inValue) { + function base64FormatEncode(inValue) { + if (inValue < 64) { + return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + } + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + var encodedStr = ""; + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + base64FormatEncode(currentDigit); + } while (inValue > 0); + return encodedStr; + } + } + function recordSourceMapSpan(pos) { + var sourceLinePos = ts.getLineAndCharacterOfPosition(currentSourceFile, pos); + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + var emittedLine = writer.getLine(); + var emittedColumn = writer.getColumn(); + // If this location wasn't recorded or the location in source is going backwards, record the span + if (!lastRecordedSourceMapSpan || + lastRecordedSourceMapSpan.emittedLine != emittedLine || + lastRecordedSourceMapSpan.emittedColumn != emittedColumn || + (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && + (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || + (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { + // Encode the last recordedSpan before assigning new + encodeLastRecordedSourceMapSpan(); + // New span + lastRecordedSourceMapSpan = { + emittedLine: emittedLine, + emittedColumn: emittedColumn, + sourceLine: sourceLinePos.line, + sourceColumn: sourceLinePos.character, + nameIndex: getSourceMapNameIndex(), + sourceIndex: sourceMapSourceIndex + }; + } + else { + // Take the new pos instead since there is no change in emittedLine and column since last location + lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; + lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; + lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; + } + } + function recordEmitNodeStartSpan(node) { + // Get the token pos after skipping to the token (ignoring the leading trivia) + recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); + } + function recordEmitNodeEndSpan(node) { + recordSourceMapSpan(node.end); + } + function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { + var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); + recordSourceMapSpan(tokenStartPos); + var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); + recordSourceMapSpan(tokenEndPos); + return tokenEndPos; + } + function recordNewSourceFileStart(node) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true)); + sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; + // The one that can be used from program to get the actual source file + sourceMapData.inputSourceFileNames.push(node.fileName); + } + function recordScopeNameOfNode(node, scopeName) { + function recordScopeNameIndex(scopeNameIndex) { + sourceMapNameIndices.push(scopeNameIndex); + } + function recordScopeNameStart(scopeName) { + var scopeNameIndex = -1; + if (scopeName) { + var parentIndex = getSourceMapNameIndex(); + if (parentIndex !== -1) { + // Child scopes are always shown with a dot (even if they have no name), + // unless it is a computed property. Then it is shown with brackets, + // but the brackets are included in the name. + var name_3 = node.name; + if (!name_3 || name_3.kind !== 127 /* ComputedPropertyName */) { + scopeName = "." + scopeName; + } + scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; + } + scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); + if (scopeNameIndex === undefined) { + scopeNameIndex = sourceMapData.sourceMapNames.length; + sourceMapData.sourceMapNames.push(scopeName); + sourceMapNameIndexMap[scopeName] = scopeNameIndex; + } + } + recordScopeNameIndex(scopeNameIndex); + } + if (scopeName) { + // The scope was already given a name use it + recordScopeNameStart(scopeName); + } + else if (node.kind === 200 /* FunctionDeclaration */ || + node.kind === 162 /* FunctionExpression */ || + node.kind === 134 /* MethodDeclaration */ || + node.kind === 133 /* MethodSignature */ || + node.kind === 136 /* GetAccessor */ || + node.kind === 137 /* SetAccessor */ || + node.kind === 205 /* ModuleDeclaration */ || + node.kind === 201 /* ClassDeclaration */ || + node.kind === 204 /* EnumDeclaration */) { + // Declaration and has associated name use it + if (node.name) { + var name_4 = node.name; + // For computed property names, the text will include the brackets + scopeName = name_4.kind === 127 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_4) + : node.name.text; + } + recordScopeNameStart(scopeName); + } + else { + // Block just use the name from upper level scope + recordScopeNameIndex(getSourceMapNameIndex()); + } + } + function recordScopeNameEnd() { + sourceMapNameIndices.pop(); + } + ; + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { + recordSourceMapSpan(comment.pos); + ts.writeCommentRange(currentSourceFile, writer, comment, newLine); + recordSourceMapSpan(comment.end); + } + function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { + if (typeof JSON !== "undefined") { + return JSON.stringify({ + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }); + } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; + function serializeStringArray(list) { + var output = ""; + for (var i = 0, n = list.length; i < n; i++) { + if (i) { + output += ","; + } + output += "\"" + ts.escapeString(list[i]) + "\""; + } + return output; + } + } + function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { + // Write source map file + encodeLastRecordedSourceMapSpan(); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + sourceMapDataList.push(sourceMapData); + // Write sourcemap url to the js file and write the js file + writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + } + // Initialize source map data + var sourceMapJsFile = ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)); + sourceMapData = { + sourceMapFilePath: jsFilePath + ".map", + jsSourceMappingURL: sourceMapJsFile + ".map", + sourceMapFile: sourceMapJsFile, + sourceMapSourceRoot: compilerOptions.sourceRoot || "", + sourceMapSources: [], + inputSourceFileNames: [], + sourceMapNames: [], + sourceMapMappings: "", + sourceMapDecodedMappings: [] + }; + // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the + // relative paths of the sources list in the sourcemap + sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); + if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { + sourceMapData.sourceMapSourceRoot += ts.directorySeparator; + } + if (compilerOptions.mapRoot) { + sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); + if (root) { + // For modules or multiple emit files the mapRoot will have directory structure like the sources + // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map + sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(root, host, sourceMapDir)); + } + if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { + // The relative paths are relative to the common directory + sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } + else { + sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); + } + } + else { + sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); + } + function emitNodeWithSourceMap(node, allowGeneratedIdentifiers) { + if (node) { + if (ts.nodeIsSynthesized(node)) { + return emitNodeWithoutSourceMap(node, false); + } + if (node.kind != 227 /* SourceFile */) { + recordEmitNodeStartSpan(node); + emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers); + recordEmitNodeEndSpan(node); + } + else { + recordNewSourceFileStart(node); + emitNodeWithoutSourceMap(node, false); + } + } + } + writeEmittedFiles = writeJavaScriptAndSourceMapFile; + emit = emitNodeWithSourceMap; + emitStart = recordEmitNodeStartSpan; + emitEnd = recordEmitNodeEndSpan; + emitToken = writeTextWithSpanRecord; + scopeEmitStart = recordScopeNameOfNode; + scopeEmitEnd = recordScopeNameEnd; + writeComment = writeCommentRangeWithMap; + } + function writeJavaScriptFile(emitOutput, writeByteOrderMark) { + ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); + } + // Create a temporary variable with a unique unused name. + function createTempVariable(flags) { + var result = ts.createSynthesizedNode(65 /* Identifier */); + result.text = makeTempVariableName(flags); + return result; + } + function recordTempDeclaration(name) { + if (!tempVariables) { + tempVariables = []; + } + tempVariables.push(name); + } + function createAndRecordTempVariable(flags) { + var temp = createTempVariable(flags); + recordTempDeclaration(temp); + return temp; + } + function emitTempDeclarations(newLine) { + if (tempVariables) { + if (newLine) { + writeLine(); + } + else { + write(" "); + } + write("var "); + emitCommaList(tempVariables); + write(";"); + } + } + function emitTokenText(tokenKind, startPos, emitFn) { + var tokenString = ts.tokenToString(tokenKind); + if (emitFn) { + emitFn(); + } + else { + write(tokenString); + } + return startPos + tokenString.length; + } + function emitOptional(prefix, node) { + if (node) { + write(prefix); + emit(node); + } + } + function emitParenthesizedIf(node, parenthesized) { + if (parenthesized) { + write("("); + } + emit(node); + if (parenthesized) { + write(")"); + } + } + function emitTrailingCommaIfPresent(nodeList) { + if (nodeList.hasTrailingComma) { + write(","); + } + } + function emitLinePreservingList(parent, nodes, allowTrailingComma, spacesBetweenBraces) { + ts.Debug.assert(nodes.length > 0); + increaseIndent(); + if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + for (var i = 0, n = nodes.length; i < n; i++) { + if (i) { + if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) { + write(", "); + } + else { + write(","); + writeLine(); + } + } + emit(nodes[i]); + } + if (nodes.hasTrailingComma && allowTrailingComma) { + write(","); + } + decreaseIndent(); + if (nodeEndPositionsAreOnSameLine(parent, ts.lastOrUndefined(nodes))) { + if (spacesBetweenBraces) { + write(" "); + } + } + else { + writeLine(); + } + } + function emitList(nodes, start, count, multiLine, trailingComma, leadingComma, noTrailingNewLine, emitNode) { + if (!emitNode) { + emitNode = emit; + } + for (var i = 0; i < count; i++) { + if (multiLine) { + if (i || leadingComma) { + write(","); + } + writeLine(); + } + else { + if (i || leadingComma) { + write(", "); + } + } + emitNode(nodes[start + i]); + leadingComma = true; + } + if (trailingComma) { + write(","); + } + if (multiLine && !noTrailingNewLine) { + writeLine(); + } + return count; + } + function emitCommaList(nodes) { + if (nodes) { + emitList(nodes, 0, nodes.length, false, false); + } + } + function emitLines(nodes) { + emitLinesStartingAt(nodes, 0); + } + function emitLinesStartingAt(nodes, startIndex) { + for (var i = startIndex; i < nodes.length; i++) { + writeLine(); + emit(nodes[i]); + } + } + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98 /* b */: + case 66 /* B */: + case 111 /* o */: + case 79 /* O */: + return true; + } + } + return false; + } + function emitLiteral(node) { + var text = getLiteralText(node); + if (compilerOptions.sourceMap && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + writer.writeLiteral(text); + } + else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + write(node.text); + } + else { + write(text); + } + } + function getLiteralText(node) { + // Any template literal or string literal with an extended escape + // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. + if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + // If we don't need to downlevel and we can reach the original source text using + // the node's parent reference, then simply get the text as it was originally written. + if (node.parent) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + } + // If we can't reach the original source text, use the canonical form if it's a number, + // or an escaped quoted form of the original text if it's string-like. + switch (node.kind) { + case 8 /* StringLiteral */: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 10 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText('`', node.text, '`'); + case 11 /* TemplateHead */: + return getQuotedEscapedLiteralText('`', node.text, '${'); + case 12 /* TemplateMiddle */: + return getQuotedEscapedLiteralText('}', node.text, '${'); + case 13 /* TemplateTail */: + return getQuotedEscapedLiteralText('}', node.text, '`'); + case 7 /* NumericLiteral */: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + ts.escapeNonAsciiCharacters(ts.escapeString(text)) + rightQuote; + } + function emitDownlevelRawTemplateLiteral(node) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + text = ts.escapeString(text); + write('"' + text + '"'); + } + function emitDownlevelTaggedTemplateArray(node, literalEmitter) { + write("["); + if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + literalEmitter(node.template); + } + else { + literalEmitter(node.template.head); + ts.forEach(node.template.templateSpans, function (child) { + write(", "); + literalEmitter(child.literal); + }); + } + write("]"); + } + function emitDownlevelTaggedTemplate(node) { + var tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(tempVariable); + write(" = "); + emitDownlevelTaggedTemplateArray(node, emit); + write(", "); + emit(tempVariable); + write(".raw = "); + emitDownlevelTaggedTemplateArray(node, emitDownlevelRawTemplateLiteral); + write(", "); + emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); + write("("); + emit(tempVariable); + // Now we emit the expressions + if (node.template.kind === 171 /* TemplateExpression */) { + ts.forEach(node.template.templateSpans, function (templateSpan) { + write(", "); + var needsParens = templateSpan.expression.kind === 169 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + emitParenthesizedIf(templateSpan.expression, needsParens); + }); + } + write("))"); + } + function emitTemplateExpression(node) { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (languageVersion >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + var emitOuterParens = ts.isExpression(node.parent) + && templateNeedsParens(node, node.parent); + if (emitOuterParens) { + write("("); + } + var headEmitted = false; + if (shouldEmitTemplateHead()) { + emitLiteral(node.head); + headEmitted = true; + } + for (var i = 0, n = node.templateSpans.length; i < n; i++) { + var templateSpan = node.templateSpans[i]; + // Check if the expression has operands and binds its operands less closely than binary '+'. + // If it does, we need to wrap the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var needsParens = templateSpan.expression.kind !== 161 /* ParenthesizedExpression */ + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + if (i > 0 || headEmitted) { + // If this is the first span and the head was not emitted, then this templateSpan's + // expression will be the first to be emitted. Don't emit the preceding ' + ' in that + // case. + write(" + "); + } + emitParenthesizedIf(templateSpan.expression, needsParens); + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + } + if (emitOuterParens) { + write(")"); + } + function shouldEmitTemplateHead() { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function templateNeedsParens(template, parent) { + switch (parent.kind) { + case 157 /* CallExpression */: + case 158 /* NewExpression */: + return parent.expression === template; + case 159 /* TaggedTemplateExpression */: + case 161 /* ParenthesizedExpression */: + return false; + default: + return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; + } + } + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression) { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%' + // which have greater precedence and '-' which has equal precedence. + // All unary operators have a higher precedence apart from yield. + // Arrow functions and conditionals have a lower precedence, + // although we convert the former into regular function expressions in ES5 mode, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + switch (expression.kind) { + case 169 /* BinaryExpression */: + switch (expression.operatorToken.kind) { + case 35 /* AsteriskToken */: + case 36 /* SlashToken */: + case 37 /* PercentToken */: + return 1 /* GreaterThan */; + case 33 /* PlusToken */: + case 34 /* MinusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 172 /* YieldExpression */: + case 170 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); + } + // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. + // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. + // For example, this is utilized when feeding in a result to Object.defineProperty. + function emitExpressionForPropertyName(node) { + ts.Debug.assert(node.kind !== 152 /* BindingElement */); + if (node.kind === 8 /* StringLiteral */) { + emitLiteral(node); + } + else if (node.kind === 127 /* ComputedPropertyName */) { + // if this is a decorated computed property, we will need to capture the result + // of the property expression so that we can apply decorators later. This is to ensure + // we don't introduce unintended side effects: + // + // class C { + // [_a = x]() { } + // } + // + // The emit for the decorated computed property decorator is: + // + // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); + // + if (ts.nodeIsDecorated(node.parent)) { + if (!computedPropertyNamesToGeneratedNames) { + computedPropertyNamesToGeneratedNames = []; + } + var generatedName = computedPropertyNamesToGeneratedNames[ts.getNodeId(node)]; + if (generatedName) { + // we have already generated a variable for this node, write that value instead. + write(generatedName); + return; + } + generatedName = createAndRecordTempVariable(0 /* Auto */).text; + computedPropertyNamesToGeneratedNames[ts.getNodeId(node)] = generatedName; + write(generatedName); + write(" = "); + } + emit(node.expression); + } + else { + write("\""); + if (node.kind === 7 /* NumericLiteral */) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } + write("\""); + } + } + function isNotExpressionIdentifier(node) { + var parent = node.parent; + switch (parent.kind) { + case 129 /* Parameter */: + case 198 /* VariableDeclaration */: + case 152 /* BindingElement */: + case 132 /* PropertyDeclaration */: + case 131 /* PropertySignature */: + case 224 /* PropertyAssignment */: + case 225 /* ShorthandPropertyAssignment */: + case 226 /* EnumMember */: + case 134 /* MethodDeclaration */: + case 133 /* MethodSignature */: + case 200 /* FunctionDeclaration */: + case 136 /* GetAccessor */: + case 137 /* SetAccessor */: + case 162 /* FunctionExpression */: + case 201 /* ClassDeclaration */: + case 202 /* InterfaceDeclaration */: + case 204 /* EnumDeclaration */: + case 205 /* ModuleDeclaration */: + case 208 /* ImportEqualsDeclaration */: + case 210 /* ImportClause */: + case 211 /* NamespaceImport */: + return parent.name === node; + case 213 /* ImportSpecifier */: + case 217 /* ExportSpecifier */: + return parent.name === node || parent.propertyName === node; + case 190 /* BreakStatement */: + case 189 /* ContinueStatement */: + case 214 /* ExportAssignment */: + return false; + case 194 /* LabeledStatement */: + return node.parent.label === node; + } + } + function emitExpressionIdentifier(node) { + var substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode); + if (substitution) { + write(substitution); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function getGeneratedNameForIdentifier(node) { + if (ts.nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) { + return undefined; + } + var variableId = resolver.getBlockScopedVariableId(node); + if (variableId === undefined) { + return undefined; + } + return blockScopedVariableToGeneratedName[variableId]; + } + function emitIdentifier(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers) { + var generatedName = getGeneratedNameForIdentifier(node); + if (generatedName) { + write(generatedName); + return; + } + } + if (!node.parent) { + write(node.text); + } + else if (!isNotExpressionIdentifier(node)) { + emitExpressionIdentifier(node); + } + else { + writeTextOfNode(currentSourceFile, node); + } + } + function emitThis(node) { + if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { + write("_this"); + } + else { + write("this"); + } + } + function emitSuper(node) { + if (languageVersion >= 2 /* ES6 */) { + write("super"); + } + else { + var flags = resolver.getNodeCheckFlags(node); + if (flags & 16 /* SuperInstance */) { + write("_super.prototype"); + } + else { + write("_super"); + } + } + } + function emitObjectBindingPattern(node) { + write("{ "); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write(" }"); + } + function emitArrayBindingPattern(node) { + write("["); + var elements = node.elements; + emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + write("]"); + } + function emitBindingElement(node) { + if (node.propertyName) { + emit(node.propertyName, false); + write(": "); + } + if (node.dotDotDotToken) { + write("..."); + } + if (ts.isBindingPattern(node.name)) { + emit(node.name); + } + else { + emitModuleMemberName(node); + } + emitOptional(" = ", node.initializer); + } + function emitSpreadElementExpression(node) { + write("..."); + emit(node.expression); + } + function emitYieldExpression(node) { + write(ts.tokenToString(110 /* YieldKeyword */)); + if (node.asteriskToken) { + write("*"); + } + if (node.expression) { + write(" "); + emit(node.expression); + } + } + function needsParenthesisForPropertyAccessOrInvocation(node) { + switch (node.kind) { + case 65 /* Identifier */: + case 153 /* ArrayLiteralExpression */: + case 155 /* PropertyAccessExpression */: + case 156 /* ElementAccessExpression */: + case 157 /* CallExpression */: + case 161 /* ParenthesizedExpression */: + // This list is not exhaustive and only includes those cases that are relevant + // to the check in emitArrayLiteral. More cases can be added as needed. + return false; + } + return true; + } + function emitListWithSpread(elements, multiLine, trailingComma) { + var pos = 0; + var group = 0; + var length = elements.length; + while (pos < length) { + // Emit using the pattern .concat(, , ...) + if (group === 1) { + write(".concat("); + } + else if (group > 1) { + write(", "); + } + var e = elements[pos]; + if (e.kind === 173 /* SpreadElementExpression */) { + e = e.expression; + emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + pos++; + } + else { + var i = pos; + while (i < length && elements[i].kind !== 173 /* SpreadElementExpression */) { + i++; + } + write("["); + if (multiLine) { + increaseIndent(); + } + emitList(elements, pos, i - pos, multiLine, trailingComma && i === length); + if (multiLine) { + decreaseIndent(); + } + write("]"); + pos = i; + } + group++; + } + if (group > 1) { + write(")"); + } + } + function isSpreadElementExpression(node) { + return node.kind === 173 /* SpreadElementExpression */; + } + function emitArrayLiteral(node) { + var elements = node.elements; + if (elements.length === 0) { + write("[]"); + } + else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { + write("["); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + write("]"); + } + else { + emitListWithSpread(elements, (node.flags & 512 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma); + } + } + function emitObjectLiteralBody(node, numElements) { + if (numElements === 0) { + write("{}"); + return; + } + write("{"); + if (numElements > 0) { + var properties = node.properties; + // If we are not doing a downlevel transformation for object literals, + // then try to preserve the original shape of the object literal. + // Otherwise just try to preserve the formatting. + if (numElements === properties.length) { + emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); + } + else { + var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + if (!multiLine) { + write(" "); + } + else { + increaseIndent(); + } + emitList(properties, 0, numElements, multiLine, false); + if (!multiLine) { + write(" "); + } + else { + decreaseIndent(); + } + } + } + write("}"); + } + function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { + var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + var properties = node.properties; + write("("); + if (multiLine) { + increaseIndent(); + } + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var tempVar = createAndRecordTempVariable(0 /* Auto */); + // Write out the first non-computed properties + // (or all properties if none of them are computed), + // then emit the rest through indexing on the temp variable. + emit(tempVar); + write(" = "); + emitObjectLiteralBody(node, firstComputedPropertyIndex); + for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { + writeComma(); + var property = properties[i]; + emitStart(property); + if (property.kind === 136 /* GetAccessor */ || property.kind === 137 /* SetAccessor */) { + // TODO (drosen): Reconcile with 'emitMemberFunctions'. + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property !== accessors.firstAccessor) { + continue; + } + write("Object.defineProperty("); + emit(tempVar); + write(", "); + emitStart(node.name); + emitExpressionForPropertyName(property.name); + emitEnd(property.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("})"); + emitEnd(property); + } + else { + emitLeadingComments(property); + emitStart(property.name); + emit(tempVar); + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + if (property.kind === 224 /* PropertyAssignment */) { + emit(property.initializer); + } + else if (property.kind === 225 /* ShorthandPropertyAssignment */) { + emitExpressionIdentifier(property.name); + } + else if (property.kind === 134 /* MethodDeclaration */) { + emitFunctionDeclaration(property); + } + else { + ts.Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); + } + } + emitEnd(property); + } + writeComma(); + emit(tempVar); + if (multiLine) { + decreaseIndent(); + writeLine(); + } + write(")"); + function writeComma() { + if (multiLine) { + write(","); + writeLine(); + } + else { + write(", "); + } + } + } + function emitObjectLiteral(node) { + var properties = node.properties; + if (languageVersion < 2 /* ES6 */) { + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialNonComputedProperties = numProperties; + for (var i = 0, n = properties.length; i < n; i++) { + if (properties[i].name.kind === 127 /* ComputedPropertyName */) { + numInitialNonComputedProperties = i; + break; + } + } + var hasComputedProperty = numInitialNonComputedProperties !== properties.length; + if (hasComputedProperty) { + emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties); + return; + } + } + // Ordinary case: either the object has no computed properties + // or we're compiling with an ES6+ target. + emitObjectLiteralBody(node, properties.length); + } + function createBinaryExpression(left, operator, right, startsOnNewLine) { + var result = ts.createSynthesizedNode(169 /* BinaryExpression */, startsOnNewLine); + result.operatorToken = ts.createSynthesizedNode(operator); + result.left = left; + result.right = right; + return result; + } + function createPropertyAccessExpression(expression, name) { + var result = ts.createSynthesizedNode(155 /* PropertyAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.name = name; + return result; + } + function createElementAccessExpression(expression, argumentExpression) { + var result = ts.createSynthesizedNode(156 /* ElementAccessExpression */); + result.expression = parenthesizeForAccess(expression); + result.argumentExpression = argumentExpression; + return result; + } + function parenthesizeForAccess(expr) { + // isLeftHandSideExpression is almost the correct criterion for when it is not necessary + // to parenthesize the expression before a dot. The known exceptions are: + // + // NewExpression: + // new C.x -> not the same as (new C).x + // NumberLiteral + // 1.x -> not the same as (1).x + // + if (ts.isLeftHandSideExpression(expr) && expr.kind !== 158 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { + return expr; + } + var node = ts.createSynthesizedNode(161 /* ParenthesizedExpression */); + node.expression = expr; + return node; + } + function emitComputedPropertyName(node) { + write("["); + emitExpressionForPropertyName(node); + write("]"); + } + function emitMethod(node) { + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + emit(node.name, false); + if (languageVersion < 2 /* ES6 */) { + write(": function "); + } + emitSignatureAndBody(node); + } + function emitPropertyAssignment(node) { + emit(node.name, false); + write(": "); + emit(node.initializer); + } + function emitShorthandPropertyAssignment(node) { + emit(node.name, false); + // If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example: + // module m { + // export let y; + // } + // module m { + // export let obj = { y }; + // } + // The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version + if (languageVersion < 2 /* ES6 */) { + // Emit identifier as an identifier + write(": "); + var generatedName = getGeneratedNameForIdentifier(node.name); + if (generatedName) { + write(generatedName); + } + else { + // Even though this is stored as identifier treat it as an expression + // Short-hand, { x }, is equivalent of normal form { x: x } + emitExpressionIdentifier(node.name); + } + } + else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) { + // Emit identifier as an identifier + write(": "); + // Even though this is stored as identifier treat it as an expression + // Short-hand, { x }, is equivalent of normal form { x: x } + emitExpressionIdentifier(node.name); + } + } + function tryEmitConstantValue(node) { + if (compilerOptions.separateCompilation) { + // do not inline enum values in separate compilation mode + return false; + } + var constantValue = resolver.getConstantValue(node); + if (constantValue !== undefined) { + write(constantValue.toString()); + if (!compilerOptions.removeComments) { + var propertyName = node.kind === 155 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + write(" /* " + propertyName + " */"); + } + return true; + } + return false; + } + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // emitted instead. + function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { + var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); + // Always use a newline for synthesized code if the synthesizer desires it. + var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); + if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) { + increaseIndent(); + writeLine(); + return true; + } + else { + if (valueToWriteWhenNotIndenting) { + write(valueToWriteWhenNotIndenting); + } + return false; + } + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); + write("."); + var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); + emit(node.name, false); + decreaseIndentIf(indentedBeforeDot, indentedAfterDot); + } + function emitQualifiedName(node) { + emit(node.left); + write("."); + emit(node.right); + } + function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } + emit(node.expression); + write("["); + emit(node.argumentExpression); + write("]"); + } + function hasSpreadElement(elements) { + return ts.forEach(elements, function (e) { return e.kind === 173 /* SpreadElementExpression */; }); + } + function skipParentheses(node) { + while (node.kind === 161 /* ParenthesizedExpression */ || node.kind === 160 /* TypeAssertionExpression */) { + node = node.expression; + } + return node; + } + function emitCallTarget(node) { + if (node.kind === 65 /* Identifier */ || node.kind === 93 /* ThisKeyword */ || node.kind === 91 /* SuperKeyword */) { + emit(node); + return node; + } + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emit(temp); + write(" = "); + emit(node); + write(")"); + return temp; + } + function emitCallWithSpread(node) { + var target; + var expr = skipParentheses(node.expression); + if (expr.kind === 155 /* PropertyAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("."); + emit(expr.name); + } + else if (expr.kind === 156 /* ElementAccessExpression */) { + // Target will be emitted as "this" argument + target = emitCallTarget(expr.expression); + write("["); + emit(expr.argumentExpression); + write("]"); + } + else if (expr.kind === 91 /* SuperKeyword */) { + target = expr; + write("_super"); + } + else { + emit(node.expression); + } + write(".apply("); + if (target) { + if (target.kind === 91 /* SuperKeyword */) { + // Calls of form super(...) and super.foo(...) + emitThis(target); + } + else { + // Calls of form obj.foo(...) + emit(target); + } + } + else { + // Calls of form foo(...) + write("void 0"); + } + write(", "); + emitListWithSpread(node.arguments, false, false); + write(")"); + } + function emitCallExpression(node) { + if (languageVersion < 2 /* ES6 */ && hasSpreadElement(node.arguments)) { + emitCallWithSpread(node); + return; + } + var superCall = false; + if (node.expression.kind === 91 /* SuperKeyword */) { + emitSuper(node.expression); + superCall = true; + } + else { + emit(node.expression); + superCall = node.expression.kind === 155 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + } + if (superCall && languageVersion < 2 /* ES6 */) { + write(".call("); + emitThis(node.expression); + if (node.arguments.length) { + write(", "); + emitCommaList(node.arguments); + } + write(")"); + } + else { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitNewExpression(node) { + write("new "); + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } + } + function emitTaggedTemplateExpression(node) { + if (languageVersion >= 2 /* ES6 */) { + emit(node.tag); + write(" "); + emit(node.template); + } + else { + emitDownlevelTaggedTemplate(node); + } + } + function emitParenExpression(node) { + if (!node.parent || node.parent.kind !== 163 /* ArrowFunction */) { + if (node.expression.kind === 160 /* TypeAssertionExpression */) { + var operand = node.expression.expression; + // Make sure we consider all nested cast expressions, e.g.: + // (-A).x; + while (operand.kind == 160 /* TypeAssertionExpression */) { + operand = operand.expression; + } + // We have an expression of the form: (SubExpr) + // Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is. + // Omitting the parentheses, however, could cause change in the semantics of the generated + // code if the casted expression has a lower precedence than the rest of the expression, e.g.: + // (new A).foo should be emitted as (new A).foo and not new A.foo + // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() + // new (A()) should be emitted as new (A()) and not new A() + // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () + if (operand.kind !== 167 /* PrefixUnaryExpression */ && + operand.kind !== 166 /* VoidExpression */ && + operand.kind !== 165 /* TypeOfExpression */ && + operand.kind !== 164 /* DeleteExpression */ && + operand.kind !== 168 /* PostfixUnaryExpression */ && + operand.kind !== 158 /* NewExpression */ && + !(operand.kind === 157 /* CallExpression */ && node.parent.kind === 158 /* NewExpression */) && + !(operand.kind === 162 /* FunctionExpression */ && node.parent.kind === 157 /* CallExpression */)) { + emit(operand); + return; + } + } + } + write("("); + emit(node.expression); + write(")"); + } + function emitDeleteExpression(node) { + write(ts.tokenToString(74 /* DeleteKeyword */)); + write(" "); + emit(node.expression); + } + function emitVoidExpression(node) { + write(ts.tokenToString(99 /* VoidKeyword */)); + write(" "); + emit(node.expression); + } + function emitTypeOfExpression(node) { + write(ts.tokenToString(97 /* TypeOfKeyword */)); + write(" "); + emit(node.expression); + } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { + return false; + } + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 198 /* VariableDeclaration */ || node.parent.kind === 152 /* BindingElement */); + var targetDeclaration = isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + return isSourceFileLevelDeclarationInSystemExternalModule(targetDeclaration, true); + } + function emitPrefixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + } + write(ts.tokenToString(node.operator)); + // In some cases, we need to emit a space between the operator and the operand. One obvious case + // is when the operator is an identifier, like delete or typeof. We also need to do this for plus + // and minus expressions in certain cases. Specifically, consider the following two cases (parens + // are just for clarity of exposition, and not part of the source code): + // + // (+(+1)) + // (+(++1)) + // + // We need to emit a space in both cases. In the first case, the absence of a space will make + // the resulting expression a prefix increment operation. And in the second, it will make the resulting + // expression a prefix increment whose operand is a plus expression - (++(+x)) + // The same is true of minus of course. + if (node.operand.kind === 167 /* PrefixUnaryExpression */) { + var operand = node.operand; + if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { + write(" "); + } + else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { + write(" "); + } + } + emit(node.operand); + if (exportChanged) { + write(")"); + } + } + function emitPostfixUnaryExpression(node) { + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + write("(" + exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.operand); + write("\", "); + write(ts.tokenToString(node.operator)); + emit(node.operand); + if (node.operator === 38 /* PlusPlusToken */) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(ts.tokenToString(node.operator)); + } + } + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemExternalModule(node, isExported) { + if (!node || languageVersion >= 2 /* ES6 */ || !isCurrentFileSystemExternalModule()) { + return false; + } + var current = node; + while (current) { + if (current.kind === 227 /* SourceFile */) { + return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + } + else if (ts.isFunctionLike(current) || current.kind === 206 /* ModuleBlock */) { + return false; + } + else { + current = current.parent; + } + } + } + function emitBinaryExpression(node) { + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && + (node.left.kind === 154 /* ObjectLiteralExpression */ || node.left.kind === 153 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 182 /* ExpressionStatement */); + } + else { + var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && + node.operatorToken.kind <= 64 /* LastAssignment */ && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.left); + write("\", "); + } + emit(node.left); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + write(ts.tokenToString(node.operatorToken.kind)); + var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); + emit(node.right); + decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } + } + } + function synthesizedNodeStartsOnNewLine(node) { + return ts.nodeIsSynthesized(node) && node.startsOnNewLine; + } + function emitConditionalExpression(node) { + emit(node.condition); + var indentedBeforeQuestion = indentIfOnDifferentLines(node, node.condition, node.questionToken, " "); + write("?"); + var indentedAfterQuestion = indentIfOnDifferentLines(node, node.questionToken, node.whenTrue, " "); + emit(node.whenTrue); + decreaseIndentIf(indentedBeforeQuestion, indentedAfterQuestion); + var indentedBeforeColon = indentIfOnDifferentLines(node, node.whenTrue, node.colonToken, " "); + write(":"); + var indentedAfterColon = indentIfOnDifferentLines(node, node.colonToken, node.whenFalse, " "); + emit(node.whenFalse); + decreaseIndentIf(indentedBeforeColon, indentedAfterColon); + } + // Helper function to decrease the indent if we previously indented. Allows multiple + // previous indent values to be considered at a time. This also allows caller to just + // call this once, passing in all their appropriate indent values, instead of needing + // to call this helper function multiple times. + function decreaseIndentIf(value1, value2) { + if (value1) { + decreaseIndent(); + } + if (value2) { + decreaseIndent(); + } + } + function isSingleLineEmptyBlock(node) { + if (node && node.kind === 179 /* Block */) { + var block = node; + return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); + } + } + function emitBlock(node) { + if (isSingleLineEmptyBlock(node)) { + emitToken(14 /* OpenBraceToken */, node.pos); + write(" "); + emitToken(15 /* CloseBraceToken */, node.statements.end); + return; + } + emitToken(14 /* OpenBraceToken */, node.pos); + increaseIndent(); + scopeEmitStart(node.parent); + if (node.kind === 206 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 205 /* ModuleDeclaration */); + emitCaptureThisForNodeIfNecessary(node.parent); + } + emitLines(node.statements); + if (node.kind === 206 /* ModuleBlock */) { + emitTempDeclarations(true); + } + decreaseIndent(); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.statements.end); + scopeEmitEnd(); + } + function emitEmbeddedStatement(node) { + if (node.kind === 179 /* Block */) { + write(" "); + emit(node); + } + else { + increaseIndent(); + writeLine(); + emit(node); + decreaseIndent(); + } + } + function emitExpressionStatement(node) { + emitParenthesizedIf(node.expression, node.expression.kind === 163 /* ArrowFunction */); + write(";"); + } + function emitIfStatement(node) { + var endPos = emitToken(84 /* IfKeyword */, node.pos); + write(" "); + endPos = emitToken(16 /* OpenParenToken */, endPos); + emit(node.expression); + emitToken(17 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.thenStatement); + if (node.elseStatement) { + writeLine(); + emitToken(76 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 183 /* IfStatement */) { + write(" "); + emit(node.elseStatement); + } + else { + emitEmbeddedStatement(node.elseStatement); + } + } + } + function emitDoStatement(node) { + write("do"); + emitEmbeddedStatement(node.statement); + if (node.statement.kind === 179 /* Block */) { + write(" "); + } + else { + writeLine(); + } + write("while ("); + emit(node.expression); + write(");"); + } + function emitWhileStatement(node) { + write("while ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + /* Returns true if start of variable declaration list was emitted. + * Return false if nothing was written - this can happen for source file level variable declarations + * in system modules - such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl, startPos) { + if (shouldHoistVariable(decl, true)) { + // variables in variable declaration list were already hoisted + return false; + } + var tokenKind = 98 /* VarKeyword */; + if (decl && languageVersion >= 2 /* ES6 */) { + if (ts.isLet(decl)) { + tokenKind = 104 /* LetKeyword */; + } + else if (ts.isConst(decl)) { + tokenKind = 70 /* ConstKeyword */; + } + } + if (startPos !== undefined) { + emitToken(tokenKind, startPos); + write(" "); + } + else { + switch (tokenKind) { + case 98 /* VarKeyword */: + write("var "); + break; + case 104 /* LetKeyword */: + write("let "); + break; + case 70 /* ConstKeyword */: + write("const "); + break; + } + } + return true; + } + function emitVariableDeclarationListSkippingUninitializedEntries(list) { + var started = false; + for (var _i = 0, _a = list.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (!decl.initializer) { + continue; + } + if (!started) { + started = true; + } + else { + write(", "); + } + emit(decl); + } + return started; + } + function emitForStatement(node) { + var endPos = emitToken(82 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(16 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 199 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } + } + else if (node.initializer) { + emit(node.initializer); + } + write(";"); + emitOptional(" ", node.condition); + write(";"); + emitOptional(" ", node.iterator); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitForInOrForOfStatement(node) { + if (languageVersion < 2 /* ES6 */ && node.kind === 188 /* ForOfStatement */) { + return emitDownLevelForOfStatement(node); + } + var endPos = emitToken(82 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(16 /* OpenParenToken */, endPos); + if (node.initializer.kind === 199 /* VariableDeclarationList */) { + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length >= 1) { + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); + } + } + else { + emit(node.initializer); + } + if (node.kind === 187 /* ForInStatement */) { + write(" in "); + } + else { + write(" of "); + } + emit(node.expression); + emitToken(17 /* CloseParenToken */, node.expression.end); + emitEmbeddedStatement(node.statement); + } + function emitDownLevelForOfStatement(node) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (let _i = 0, _a = expr; _i < _a.length; _i++) { + // let v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var endPos = emitToken(82 /* ForKeyword */, node.pos); + write(" "); + endPos = emitToken(16 /* OpenParenToken */, endPos); + // Do not emit the LHS let declaration yet, because it might contain destructuring. + // Do not call recordTempDeclaration because we are declaring the temps + // right here. Recording means they will be declared later. + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var rhsIsIdentifier = node.expression.kind === 65 /* Identifier */; + var counter = createTempVariable(268435456 /* _i */); + var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + // This is the let keyword for the counter and rhsReference. The let keyword for + // the LHS will be emitted inside the body. + emitStart(node.expression); + write("var "); + // _i = 0 + emitNodeWithoutSourceMap(counter); + write(" = 0"); + emitEnd(node.expression); + if (!rhsIsIdentifier) { + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); + } + write("; "); + // _i < _a.length; + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write(" < "); + emitNodeWithoutSourceMap(rhsReference); + write(".length"); + emitEnd(node.initializer); + write("; "); + // _i++) + emitStart(node.initializer); + emitNodeWithoutSourceMap(counter); + write("++"); + emitEnd(node.initializer); + emitToken(17 /* CloseParenToken */, node.expression.end); + // Body + write(" {"); + writeLine(); + increaseIndent(); + // Initialize LHS + // let v = _a[_i]; + var rhsIterationValue = createElementAccessExpression(rhsReference, counter); + emitStart(node.initializer); + if (node.initializer.kind === 199 /* VariableDeclarationList */) { + write("var "); + var variableDeclarationList = node.initializer; + if (variableDeclarationList.declarations.length > 0) { + var declaration = variableDeclarationList.declarations[0]; + if (ts.isBindingPattern(declaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + emitDestructuring(declaration, false, rhsIterationValue); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + emitNodeWithoutSourceMap(declaration); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // It's an empty declaration list. This can only happen in an error case, if the user wrote + // for (let of []) {} + emitNodeWithoutSourceMap(createTempVariable(0 /* Auto */)); + write(" = "); + emitNodeWithoutSourceMap(rhsIterationValue); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); + if (node.initializer.kind === 153 /* ArrayLiteralExpression */ || node.initializer.kind === 154 /* ObjectLiteralExpression */) { + // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause + // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. + emitDestructuring(assignmentExpression, true, undefined); + } + else { + emitNodeWithoutSourceMap(assignmentExpression); + } + } + emitEnd(node.initializer); + write(";"); + if (node.statement.kind === 179 /* Block */) { + emitLines(node.statement.statements); + } + else { + writeLine(); + emit(node.statement); + } + writeLine(); + decreaseIndent(); + write("}"); + } + function emitBreakOrContinueStatement(node) { + emitToken(node.kind === 190 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitOptional(" ", node.label); + write(";"); + } + function emitReturnStatement(node) { + emitToken(90 /* ReturnKeyword */, node.pos); + emitOptional(" ", node.expression); + write(";"); + } + function emitWithStatement(node) { + write("with ("); + emit(node.expression); + write(")"); + emitEmbeddedStatement(node.statement); + } + function emitSwitchStatement(node) { + var endPos = emitToken(92 /* SwitchKeyword */, node.pos); + write(" "); + emitToken(16 /* OpenParenToken */, endPos); + emit(node.expression); + endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + write(" "); + emitCaseBlock(node.caseBlock, endPos); + } + function emitCaseBlock(node, startPos) { + emitToken(14 /* OpenBraceToken */, startPos); + increaseIndent(); + emitLines(node.clauses); + decreaseIndent(); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.clauses.end); + } + function nodeStartPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function nodeEndPositionsAreOnSameLine(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, node2.end); + } + function nodeEndIsOnSameLineAsNodeStart(node1, node2) { + return ts.getLineOfLocalPosition(currentSourceFile, node1.end) === + ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node) { + if (node.kind === 220 /* CaseClause */) { + write("case "); + emit(node.expression); + write(":"); + } + else { + write("default:"); + } + if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } + } + function emitThrowStatement(node) { + write("throw "); + emit(node.expression); + write(";"); + } + function emitTryStatement(node) { + write("try "); + emit(node.tryBlock); + emit(node.catchClause); + if (node.finallyBlock) { + writeLine(); + write("finally "); + emit(node.finallyBlock); + } + } + function emitCatchClause(node) { + writeLine(); + var endPos = emitToken(68 /* CatchKeyword */, node.pos); + write(" "); + emitToken(16 /* OpenParenToken */, endPos); + emit(node.variableDeclaration); + emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + write(" "); + emitBlock(node.block); + } + function emitDebuggerStatement(node) { + emitToken(72 /* DebuggerKeyword */, node.pos); + write(";"); + } + function emitLabelledStatement(node) { + emit(node.label); + write(": "); + emit(node.statement); + } + function getContainingModule(node) { + do { + node = node.parent; + } while (node && node.kind !== 205 /* ModuleDeclaration */); + return node; + } + function emitContainingModuleName(node) { + var container = getContainingModule(node); + write(container ? getGeneratedNameForNode(container) : "exports"); + } + function emitModuleMemberName(node) { + emitStart(node.name); + if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + var container = getContainingModule(node); + if (container) { + write(getGeneratedNameForNode(container)); + write("."); + } + else if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 3 /* System */) { + write("exports."); + } + } + emitNodeWithoutSourceMap(node.name); + emitEnd(node.name); + } + function createVoidZero() { + var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + zero.text = "0"; + var result = ts.createSynthesizedNode(166 /* VoidExpression */); + result.expression = zero; + return result; + } + function emitExportMemberAssignment(node) { + if (node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + if (compilerOptions.module === 3 /* System */) { + // emit export default as + // export("default", ) + write(exportFunctionForFile + "(\""); + if (node.flags & 256 /* Default */) { + write("default"); + } + else { + emitNodeWithoutSourceMap(node.name); + } + write("\", "); + emitDeclarationName(node); + write(")"); + } + else { + if (node.flags & 256 /* Default */) { + if (languageVersion === 0 /* ES3 */) { + write("exports[\"default\"]"); + } + else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); + } + emitEnd(node); + write(";"); + } + } + function emitExportMemberAssignments(name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + writeLine(); + emitStart(specifier.name); + if (compilerOptions.module === 3 /* System */) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(specifier.name); + write("\", "); + emitExpressionIdentifier(name); + write(")"); + } + else { + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } + write(";"); + } + } + } + function emitDestructuring(root, isAssignmentExpressionStatement, value) { + var emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so + // temporary variables in an exported declaration need to have real declarations elsewhere + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + var canDefineTempVariablesInPlace = false; + if (root.kind === 198 /* VariableDeclaration */) { + var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isSourceLevelForSystemModuleKind = isSourceFileLevelDeclarationInSystemExternalModule(root, false); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === 129 /* Parameter */) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === 169 /* BinaryExpression */) { + emitAssignmentExpression(root); + } + else { + ts.Debug.assert(!isAssignmentExpressionStatement); + emitBindingElement(root, value); + } + function emitAssignment(name, value) { + if (emitCount++) { + write(", "); + } + renameNonTopLevelLetAndConst(name); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 198 /* VariableDeclaration */ || name.parent.kind === 152 /* BindingElement */); + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(name); + write("\", "); + } + if (isVariableDeclarationOrBindingElement) { + emitModuleMemberName(name.parent); + } + else { + emit(name); + } + write(" = "); + emit(value); + if (exportChanged) { + write(")"); + } + } + function ensureIdentifier(expr) { + if (expr.kind !== 65 /* Identifier */) { + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + expr = identifier; + } + return expr; + } + function createDefaultValueCheck(value, defaultValue) { + // The value expression will be evaluated twice, so for anything but a simple identifier + // we need to generate a temporary variable + value = ensureIdentifier(value); + // Return the expression 'value === void 0 ? defaultValue : value' + var equals = ts.createSynthesizedNode(169 /* BinaryExpression */); + equals.left = value; + equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); + equals.right = createVoidZero(); + return createConditionalExpression(equals, defaultValue, value); + } + function createConditionalExpression(condition, whenTrue, whenFalse) { + var cond = ts.createSynthesizedNode(170 /* ConditionalExpression */); + cond.condition = condition; + cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); + cond.whenTrue = whenTrue; + cond.colonToken = ts.createSynthesizedNode(51 /* ColonToken */); + cond.whenFalse = whenFalse; + return cond; + } + function createNumericLiteral(value) { + var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + node.text = "" + value; + return node; + } + function createPropertyAccessForDestructuringProperty(object, propName) { + if (propName.kind !== 65 /* Identifier */) { + return createElementAccessExpression(object, propName); + } + return createPropertyAccessExpression(object, propName); + } + function createSliceCall(value, sliceIndex) { + var call = ts.createSynthesizedNode(157 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); + sliceIdentifier.text = "slice"; + call.expression = createPropertyAccessExpression(value, sliceIdentifier); + call.arguments = ts.createSynthesizedNodeArray(); + call.arguments[0] = createNumericLiteral(sliceIndex); + return call; + } + function emitObjectLiteralAssignment(target, value) { + var properties = target.properties; + if (properties.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value); + } + for (var _i = 0; _i < properties.length; _i++) { + var p = properties[_i]; + if (p.kind === 224 /* PropertyAssignment */ || p.kind === 225 /* ShorthandPropertyAssignment */) { + // TODO(andersh): Computed property support + var propName = (p.name); + emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); + } + } + } + function emitArrayLiteralAssignment(target, value) { + var elements = target.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var e = elements[i]; + if (e.kind !== 175 /* OmittedExpression */) { + if (e.kind !== 173 /* SpreadElementExpression */) { + emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitDestructuringAssignment(e.expression, createSliceCall(value, i)); + } + } + } + } + function emitDestructuringAssignment(target, value) { + if (target.kind === 169 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + value = createDefaultValueCheck(value, target.right); + target = target.left; + } + if (target.kind === 154 /* ObjectLiteralExpression */) { + emitObjectLiteralAssignment(target, value); + } + else if (target.kind === 153 /* ArrayLiteralExpression */) { + emitArrayLiteralAssignment(target, value); + } + else { + emitAssignment(target, value); + } + } + function emitAssignmentExpression(root) { + var target = root.left; + var value = root.right; + if (isAssignmentExpressionStatement) { + emitDestructuringAssignment(target, value); + } + else { + if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + write("("); + } + value = ensureIdentifier(value); + emitDestructuringAssignment(target, value); + write(", "); + emit(value); + if (root.parent.kind !== 161 /* ParenthesizedExpression */) { + write(")"); + } + } + } + function emitBindingElement(target, value) { + if (target.initializer) { + // Combine value and initializer + value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; + } + else if (!value) { + // Use 'void 0' in absence of value and initializer + value = createVoidZero(); + } + if (ts.isBindingPattern(target.name)) { + var pattern = target.name; + var elements = pattern.elements; + if (elements.length !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + value = ensureIdentifier(value); + } + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + if (pattern.kind === 150 /* ObjectBindingPattern */) { + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); + } + else if (element.kind !== 175 /* OmittedExpression */) { + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); + } + else if (i === elements.length - 1) { + emitBindingElement(element, createSliceCall(value, i)); + } + } + } + } + else { + emitAssignment(target.name, value); + } + } + } + function emitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + if (languageVersion < 2 /* ES6 */) { + emitDestructuring(node, false); + } + else { + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + else { + renameNonTopLevelLetAndConst(node.name); + var initializer = node.initializer; + if (!initializer && languageVersion < 2 /* ES6 */) { + // downlevel emit for non-initialized let bindings defined in loops + // for (...) { let x; } + // should be + // for (...) { var = void 0; } + // this is necessary to preserve ES6 semantic in scenarios like + // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); + // NOTE: default initialization should not be added to let bindings in for-in\for-of statements + if (isUninitializedLet && + node.parent.parent.kind !== 187 /* ForInStatement */ && + node.parent.parent.kind !== 188 /* ForOfStatement */) { + initializer = createVoidZero(); + } + } + var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + if (exportChanged) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); + } + emitModuleMemberName(node); + emitOptional(" = ", initializer); + if (exportChanged) { + write(")"); + } + } + } + function emitExportVariableAssignments(node) { + if (node.kind === 175 /* OmittedExpression */) { + return; + } + var name = node.name; + if (name.kind === 65 /* Identifier */) { + emitExportMemberAssignments(name); + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, emitExportVariableAssignments); + } + } + function getCombinedFlagsForIdentifier(node) { + if (!node.parent || (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + return 0; + } + return ts.getCombinedNodeFlags(node.parent); + } + function renameNonTopLevelLetAndConst(node) { + // do not rename if + // - language version is ES6+ + // - node is synthesized + // - node is not identifier (can happen when tree is malformed) + // - node is definitely not name of variable declaration. + // it still can be part of parameter declaration, this check will be done next + if (languageVersion >= 2 /* ES6 */ || + ts.nodeIsSynthesized(node) || + node.kind !== 65 /* Identifier */ || + (node.parent.kind !== 198 /* VariableDeclaration */ && node.parent.kind !== 152 /* BindingElement */)) { + return; + } + var combinedFlags = getCombinedFlagsForIdentifier(node); + if (((combinedFlags & 12288 /* BlockScoped */) === 0) || combinedFlags & 1 /* Export */) { + // do not rename exported or non-block scoped variables + return; + } + // here it is known that node is a block scoped variable + var list = ts.getAncestor(node, 199 /* VariableDeclarationList */); + if (list.parent.kind === 180 /* VariableStatement */) { + var isSourceFileLevelBinding = list.parent.parent.kind === 227 /* SourceFile */; + var isModuleLevelBinding = list.parent.parent.kind === 206 /* ModuleBlock */; + var isFunctionLevelBinding = list.parent.parent.kind === 179 /* Block */ && ts.isFunctionLike(list.parent.parent.parent); + if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) { + return; + } + } + var blockScopeContainer = ts.getEnclosingBlockScopeContainer(node); + var parent = blockScopeContainer.kind === 227 /* SourceFile */ + ? blockScopeContainer + : blockScopeContainer.parent; + if (resolver.resolvesToSomeValue(parent, node.text)) { + var variableId = resolver.getBlockScopedVariableId(node); + if (!blockScopedVariableToGeneratedName) { + blockScopedVariableToGeneratedName = []; + } + var generatedName = makeUniqueName(node.text); + blockScopedVariableToGeneratedName[variableId] = generatedName; + } + } + function isES6ExportedDeclaration(node) { + return !!(node.flags & 1 /* Export */) && + languageVersion >= 2 /* ES6 */ && + node.parent.kind === 227 /* SourceFile */; + } + function emitVariableStatement(node) { + var startIsEmitted = true; + if (!(node.flags & 1 /* Export */)) { + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + else if (isES6ExportedDeclaration(node)) { + // Exported ES6 module member + write("export "); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + var atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } + } + if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + ts.forEach(node.declarationList.declarations, emitExportVariableAssignments); + } + } + function emitParameter(node) { + if (languageVersion < 2 /* ES6 */) { + if (ts.isBindingPattern(node.name)) { + var name_5 = createTempVariable(0 /* Auto */); + if (!tempParameters) { + tempParameters = []; + } + tempParameters.push(name_5); + emit(name_5); + } + else { + emit(node.name); + } + } + else { + if (node.dotDotDotToken) { + write("..."); + } + emit(node.name); + emitOptional(" = ", node.initializer); + } + } + function emitDefaultValueAssignments(node) { + if (languageVersion < 2 /* ES6 */) { + var tempIndex = 0; + ts.forEach(node.parameters, function (p) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (p.dotDotDotToken) { + return; + } + if (ts.isBindingPattern(p.name)) { + writeLine(); + write("var "); + emitDestructuring(p, false, tempParameters[tempIndex]); + write(";"); + tempIndex++; + } + else if (p.initializer) { + writeLine(); + emitStart(p); + write("if ("); + emitNodeWithoutSourceMap(p.name); + write(" === void 0)"); + emitEnd(p); + write(" { "); + emitStart(p); + emitNodeWithoutSourceMap(p.name); + write(" = "); + emitNodeWithoutSourceMap(p.initializer); + emitEnd(p); + write("; }"); + } + }); + } + } + function emitRestParameter(node) { + if (languageVersion < 2 /* ES6 */ && ts.hasRestParameters(node)) { + var restIndex = node.parameters.length - 1; + var restParam = node.parameters[restIndex]; + // A rest parameter cannot have a binding pattern, so let's just ignore it if it does. + if (ts.isBindingPattern(restParam.name)) { + return; + } + var tempName = createTempVariable(268435456 /* _i */).text; + writeLine(); + emitLeadingComments(restParam); + emitStart(restParam); + write("var "); + emitNodeWithoutSourceMap(restParam.name); + write(" = [];"); + emitEnd(restParam); + emitTrailingComments(restParam); + writeLine(); + write("for ("); + emitStart(restParam); + write("var " + tempName + " = " + restIndex + ";"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + " < arguments.length;"); + emitEnd(restParam); + write(" "); + emitStart(restParam); + write(tempName + "++"); + emitEnd(restParam); + write(") {"); + increaseIndent(); + writeLine(); + emitStart(restParam); + emitNodeWithoutSourceMap(restParam.name); + write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); + emitEnd(restParam); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitAccessor(node) { + write(node.kind === 136 /* GetAccessor */ ? "get " : "set "); + emit(node.name, false); + emitSignatureAndBody(node); + } + function shouldEmitAsArrowFunction(node) { + return node.kind === 163 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + } + function emitDeclarationName(node) { + if (node.name) { + emitNodeWithoutSourceMap(node.name); + } + else { + write(getGeneratedNameForNode(node)); + } + } + function shouldEmitFunctionName(node) { + if (node.kind === 162 /* FunctionExpression */) { + // Emit name if one is present + return !!node.name; + } + if (node.kind === 200 /* FunctionDeclaration */) { + // Emit name if one is present, or emit generated name in down-level case (for export default case) + return !!node.name || languageVersion < 2 /* ES6 */; + } + } + function emitFunctionDeclaration(node) { + if (ts.nodeIsMissing(node.body)) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + // Methods will emit the comments as part of emitting method declaration + emitLeadingComments(node); + } + // For targeting below es6, emit functions-like declaration including arrow function using function keyword. + // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead + if (!shouldEmitAsArrowFunction(node)) { + if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256 /* Default */) { + write("default "); + } + } + write("function"); + if (languageVersion >= 2 /* ES6 */ && node.asteriskToken) { + write("*"); + } + write(" "); + } + if (shouldEmitFunctionName(node)) { + emitDeclarationName(node); + } + emitSignatureAndBody(node); + if (languageVersion < 2 /* ES6 */ && node.kind === 200 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + if (node.kind !== 134 /* MethodDeclaration */ && node.kind !== 133 /* MethodSignature */) { + emitTrailingComments(node); + } + } + function emitCaptureThisForNodeIfNecessary(node) { + if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { + writeLine(); + emitStart(node); + write("var _this = this;"); + emitEnd(node); + } + } + function emitSignatureParameters(node) { + increaseIndent(); + write("("); + if (node) { + var parameters = node.parameters; + var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameters(node) ? 1 : 0; + emitList(parameters, 0, parameters.length - omitCount, false, false); + } + write(")"); + decreaseIndent(); + } + function emitSignatureParametersForArrow(node) { + // Check whether the parameter list needs parentheses and preserve no-parenthesis + if (node.parameters.length === 1 && node.pos === node.parameters[0].pos) { + emit(node.parameters[0]); + return; + } + emitSignatureParameters(node); + } + function emitSignatureAndBody(node) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + // When targeting ES6, emit arrow function natively in ES6 + if (shouldEmitAsArrowFunction(node)) { + emitSignatureParametersForArrow(node); + write(" =>"); + } + else { + emitSignatureParameters(node); + } + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else if (node.body.kind === 179 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + if (!isES6ExportedDeclaration(node)) { + emitExportMemberAssignment(node); + } + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + // Returns true if any preamble code was emitted. + function emitFunctionBodyPreamble(node) { + emitCaptureThisForNodeIfNecessary(node); + emitDefaultValueAssignments(node); + emitRestParameter(node); + } + function emitExpressionFunctionBody(node, body) { + if (languageVersion < 2 /* ES6 */) { + emitDownLevelExpressionFunctionBody(node, body); + return; + } + // For es6 and higher we can emit the expression as is. However, in the case + // where the expression might end up looking like a block when emitted, we'll + // also wrap it in parentheses first. For example if you have: a => {} + // then we need to generate: a => ({}) + write(" "); + // Unwrap all type assertions. + var current = body; + while (current.kind === 160 /* TypeAssertionExpression */) { + current = current.expression; + } + emitParenthesizedIf(body, current.kind === 154 /* ObjectLiteralExpression */); + } + function emitDownLevelExpressionFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + increaseIndent(); + var outPos = writer.getTextPos(); + emitDetachedComments(node.body); + emitFunctionBodyPreamble(node); + var preambleEmitted = writer.getTextPos() !== outPos; + decreaseIndent(); + // If we didn't have to emit any preamble code, then attempt to keep the arrow + // function on one line. + if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) { + write(" "); + emitStart(body); + write("return "); + emit(body); + emitEnd(body); + write(";"); + emitTempDeclarations(false); + write(" "); + } + else { + increaseIndent(); + writeLine(); + emitLeadingComments(node.body); + write("return "); + emit(body); + write(";"); + emitTrailingComments(node.body); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + } + emitStart(node.body); + write("}"); + emitEnd(node.body); + scopeEmitEnd(); + } + function emitBlockFunctionBody(node, body) { + write(" {"); + scopeEmitStart(node); + var initialTextPos = writer.getTextPos(); + increaseIndent(); + emitDetachedComments(body.statements); + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + var startIndex = emitDirectivePrologues(body.statements, true); + emitFunctionBodyPreamble(node); + decreaseIndent(); + var preambleEmitted = writer.getTextPos() !== initialTextPos; + if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + write(" "); + emit(statement); + } + emitTempDeclarations(false); + write(" "); + emitLeadingCommentsOfPosition(body.statements.end); + } + else { + increaseIndent(); + emitLinesStartingAt(body.statements, startIndex); + emitTempDeclarations(true); + writeLine(); + emitLeadingCommentsOfPosition(body.statements.end); + decreaseIndent(); + } + emitToken(15 /* CloseBraceToken */, body.statements.end); + scopeEmitEnd(); + } + function findInitialSuperCall(ctor) { + if (ctor.body) { + var statement = ctor.body.statements[0]; + if (statement && statement.kind === 182 /* ExpressionStatement */) { + var expr = statement.expression; + if (expr && expr.kind === 157 /* CallExpression */) { + var func = expr.expression; + if (func && func.kind === 91 /* SuperKeyword */) { + return statement; + } + } + } + } + } + function emitParameterPropertyAssignments(node) { + ts.forEach(node.parameters, function (param) { + if (param.flags & 112 /* AccessibilityModifier */) { + writeLine(); + emitStart(param); + emitStart(param.name); + write("this."); + emitNodeWithoutSourceMap(param.name); + emitEnd(param.name); + write(" = "); + emit(param.name); + write(";"); + emitEnd(param); + } + }); + } + function emitMemberAccessForPropertyName(memberName) { + // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. + if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { + write("["); + emitNodeWithoutSourceMap(memberName); + write("]"); + } + else if (memberName.kind === 127 /* ComputedPropertyName */) { + emitComputedPropertyName(memberName); + } + else { + write("."); + emitNodeWithoutSourceMap(memberName); + } + } + function getInitializedProperties(node, static) { + var properties = []; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 132 /* PropertyDeclaration */ && static === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + properties.push(member); + } + } + return properties; + } + function emitPropertyDeclarations(node, properties) { + for (var _i = 0; _i < properties.length; _i++) { + var property = properties[_i]; + emitPropertyDeclaration(node, property); + } + } + function emitPropertyDeclaration(node, property, receiver, isExpression) { + writeLine(); + emitLeadingComments(property); + emitStart(property); + emitStart(property.name); + if (receiver) { + emit(receiver); + } + else { + if (property.flags & 128 /* Static */) { + emitDeclarationName(node); + } + else { + write("this"); + } + } + emitMemberAccessForPropertyName(property.name); + emitEnd(property.name); + write(" = "); + emit(property.initializer); + if (!isExpression) { + write(";"); + } + emitEnd(property); + emitTrailingComments(property); + } + function emitMemberFunctionsForES5AndLower(node) { + ts.forEach(node.members, function (member) { + if (member.kind === 178 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + else if (member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) { + if (!member.body) { + return emitOnlyPinnedOrTripleSlashComments(member); + } + writeLine(); + emitLeadingComments(member); + emitStart(member); + emitStart(member.name); + emitClassMemberPrefix(node, member); + emitMemberAccessForPropertyName(member.name); + emitEnd(member.name); + write(" = "); + emitStart(member); + emitFunctionDeclaration(member); + emitEnd(member); + emitEnd(member); + write(";"); + emitTrailingComments(member); + } + else if (member.kind === 136 /* GetAccessor */ || member.kind === 137 /* SetAccessor */) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + writeLine(); + emitStart(member); + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(", {"); + increaseIndent(); + if (accessors.getAccessor) { + writeLine(); + emitLeadingComments(accessors.getAccessor); + write("get: "); + emitStart(accessors.getAccessor); + write("function "); + emitSignatureAndBody(accessors.getAccessor); + emitEnd(accessors.getAccessor); + emitTrailingComments(accessors.getAccessor); + write(","); + } + if (accessors.setAccessor) { + writeLine(); + emitLeadingComments(accessors.setAccessor); + write("set: "); + emitStart(accessors.setAccessor); + write("function "); + emitSignatureAndBody(accessors.setAccessor); + emitEnd(accessors.setAccessor); + emitTrailingComments(accessors.setAccessor); + write(","); + } + writeLine(); + write("enumerable: true,"); + writeLine(); + write("configurable: true"); + decreaseIndent(); + writeLine(); + write("});"); + emitEnd(member); + } + } + }); + } + function emitMemberFunctionsForES6AndHigher(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if ((member.kind === 134 /* MethodDeclaration */ || node.kind === 133 /* MethodSignature */) && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + else if (member.kind === 134 /* MethodDeclaration */ || + member.kind === 136 /* GetAccessor */ || + member.kind === 137 /* SetAccessor */) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & 128 /* Static */) { + write("static "); + } + if (member.kind === 136 /* GetAccessor */) { + write("get "); + } + else if (member.kind === 137 /* SetAccessor */) { + write("set "); + } + if (member.asteriskToken) { + write("*"); + } + emit(member.name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + else if (member.kind === 178 /* SemicolonClassElement */) { + writeLine(); + write(";"); + } + } + } + function emitConstructor(node, baseTypeElement) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + emitConstructorWorker(node, baseTypeElement); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + function emitConstructorWorker(node, baseTypeElement) { + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + var hasInstancePropertyWithInitializer = false; + // Emit the constructor overload pinned comments + ts.forEach(node.members, function (member) { + if (member.kind === 135 /* Constructor */ && !member.body) { + emitOnlyPinnedOrTripleSlashComments(member); + } + // Check if there is any non-static property assignment + if (member.kind === 132 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + var ctor = ts.getFirstConstructorWithBody(node); + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= 2 /* ES6 */ && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + if (languageVersion < 2 /* ES6 */) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeElement) { + write("(...args)"); + } + else { + write("()"); + } + } + } + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeElement) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeElement) { + writeLine(); + emitStart(baseTypeElement); + if (languageVersion < 2 /* ES6 */) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeElement); + } + } + emitPropertyDeclarations(node, getInitializedProperties(node, false)); + if (ctor) { + var statements = ctor.body.statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition(ctor.body.statements.end); + } + decreaseIndent(); + emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + } + function emitClassExpression(node) { + return emitClassLikeDeclaration(node); + } + function emitClassDeclaration(node) { + return emitClassLikeDeclaration(node); + } + function emitClassLikeDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + emitClassLikeDeclarationBelowES6(node); + } + else { + emitClassLikeDeclarationForES6AndHigher(node); + } + } + function emitClassLikeDeclarationForES6AndHigher(node) { + var thisNodeIsDecorated = ts.nodeIsDecorated(node); + if (node.kind === 201 /* ClassDeclaration */) { + if (thisNodeIsDecorated) { + // To preserve the correct runtime semantics when decorators are applied to the class, + // the emit needs to follow one of the following rules: + // + // * For a local class declaration: + // + // @dec class C { + // } + // + // The emit should be: + // + // let C = class { + // }; + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // + // * For an exported class declaration: + // + // @dec export class C { + // } + // + // The emit should be: + // + // export let C = class { + // }; + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // + // * For a default export of a class declaration with a name: + // + // @dec default export class C { + // } + // + // The emit should be: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // C = __decorate([dec], C); + // export default C; + // + // * For a default export of a class declaration without a name: + // + // @dec default export class { + // } + // + // The emit should be: + // + // let _default = class { + // } + // _default = __decorate([dec], _default); + // export default _default; + // + if (isES6ExportedDeclaration(node) && !(node.flags & 256 /* Default */)) { + write("export "); + } + write("let "); + emitDeclarationName(node); + write(" = "); + } + else if (isES6ExportedDeclaration(node)) { + write("export "); + if (node.flags & 256 /* Default */) { + write("default "); + } + } + } + // If the class has static properties, and it's a class expression, then we'll need + // to specialize the emit a bit. for a class expression of the form: + // + // class C { static a = 1; static b = 2; ... } + // + // We'll emit: + // + // (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp) + // + // This keeps the expression as an expression, while ensuring that the static parts + // of it have been initialized by the time it is used. + var staticProperties = getInitializedProperties(node, true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 174 /* ClassExpression */; + var tempVariable; + if (isClassExpressionWithStaticProperties) { + tempVariable = createAndRecordTempVariable(0 /* Auto */); + write("("); + increaseIndent(); + emit(tempVariable); + write(" = "); + } + write("class"); + // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. + if ((node.name || !(node.flags & 256 /* Default */)) && !thisNodeIsDecorated) { + write(" "); + emitDeclarationName(node); + } + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.expression); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + // For a decorated class, we need to assign its name (if it has one). This is because we emit + // the class as a class expression to avoid the double-binding of the identifier: + // + // let C = class { + // } + // Object.defineProperty(C, "name", { value: "C", configurable: true }); + // + if (thisNodeIsDecorated) { + write(";"); + if (node.name) { + writeLine(); + write("Object.defineProperty("); + emitDeclarationName(node); + write(", \"name\", { value: \""); + emitDeclarationName(node); + write("\", configurable: true });"); + writeLine(); + } + } + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using + // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. + if (isClassExpressionWithStaticProperties) { + for (var _i = 0; _i < staticProperties.length; _i++) { + var property = staticProperties[_i]; + write(","); + writeLine(); + emitPropertyDeclaration(node, property, tempVariable, true); + } + write(","); + writeLine(); + emit(tempVariable); + decreaseIndent(); + write(")"); + } + else { + writeLine(); + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node); + } + // If this is an exported class, but not on the top level (i.e. on an internal + // module), export it + if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + writeLine(); + emitStart(node); + emitModuleMemberName(node); + write(" = "); + emitDeclarationName(node); + emitEnd(node); + write(";"); + } + else if (isES6ExportedDeclaration(node) && (node.flags & 256 /* Default */) && thisNodeIsDecorated) { + // if this is a top level default export of decorated class, write the export after the declaration. + writeLine(); + write("export default "); + emitDeclarationName(node); + write(";"); + } + } + function emitClassLikeDeclarationBelowES6(node) { + if (node.kind === 201 /* ClassDeclaration */) { + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!isSourceFileLevelDeclarationInSystemExternalModule(node, false)) { + write("var "); + } + emitDeclarationName(node); + write(" = "); + } + write("(function ("); + var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + if (baseTypeNode) { + write("_super"); + } + write(") {"); + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + var saveTempParameters = tempParameters; + var saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames; + tempFlags = 0; + tempVariables = undefined; + tempParameters = undefined; + computedPropertyNamesToGeneratedNames = undefined; + increaseIndent(); + scopeEmitStart(node); + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + write("__extends("); + emitDeclarationName(node); + write(", _super);"); + emitEnd(baseTypeNode); + } + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); + emitPropertyDeclarations(node, getInitializedProperties(node, true)); + writeLine(); + emitDecoratorsOfClass(node); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.members.end, function () { + write("return "); + emitDeclarationName(node); + }); + write(";"); + emitTempDeclarations(true); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; + decreaseIndent(); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + emitStart(node); + write(")("); + if (baseTypeNode) { + emit(baseTypeNode.expression); + } + write(")"); + if (node.kind === 201 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + if (node.kind === 201 /* ClassDeclaration */) { + emitExportMemberAssignment(node); + } + if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { + emitExportMemberAssignments(node.name); + } + } + function emitClassMemberPrefix(node, member) { + emitDeclarationName(node); + if (!(member.flags & 128 /* Static */)) { + write(".prototype"); + } + } + function emitDecoratorsOfClass(node) { + emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfConstructor(node); + } + function emitDecoratorsOfConstructor(node) { + var decorators = node.decorators; + var constructor = ts.getFirstConstructorWithBody(node); + var hasDecoratedParameters = constructor && ts.forEach(constructor.parameters, ts.nodeIsDecorated); + // skip decoration of the constructor if neither it nor its parameters are decorated + if (!decorators && !hasDecoratedParameters) { + return; + } + // Emit the call to __decorate. Given the class: + // + // @dec + // class C { + // } + // + // The emit for the class is: + // + // C = __decorate([dec], C); + // + writeLine(); + emitStart(node); + emitDeclarationName(node); + write(" = __decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); + emitSerializedTypeMetadata(node, argumentsWritten >= 0); + decreaseIndent(); + writeLine(); + write("], "); + emitDeclarationName(node); + write(");"); + emitEnd(node); + writeLine(); + } + function emitDecoratorsOfMembers(node, staticFlag) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + // only emit members in the correct group + if ((member.flags & 128 /* Static */) !== staticFlag) { + continue; + } + // skip members that cannot be decorated (such as the constructor) + if (!ts.nodeCanBeDecorated(member)) { + continue; + } + // skip a member if it or any of its parameters are not decorated + if (!ts.nodeOrChildIsDecorated(member)) { + continue; + } + // skip an accessor declaration if it is not the first accessor + var decorators = void 0; + var functionLikeMember = void 0; + if (ts.isAccessor(member)) { + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member !== accessors.firstAccessor) { + continue; + } + // get the decorators from the first accessor with decorators + decorators = accessors.firstAccessor.decorators; + if (!decorators && accessors.secondAccessor) { + decorators = accessors.secondAccessor.decorators; + } + // we only decorate parameters of the set accessor + functionLikeMember = accessors.setAccessor; + } + else { + decorators = member.decorators; + // we only decorate the parameters here if this is a method + if (member.kind === 134 /* MethodDeclaration */) { + functionLikeMember = member; + } + } + // Emit the call to __decorate. Given the following: + // + // class C { + // @dec method(@dec2 x) {} + // @dec get accessor() {} + // @dec prop; + // } + // + // The emit for a method is: + // + // Object.defineProperty(C.prototype, "method", + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + // + // The emit for an accessor is: + // + // Object.defineProperty(C.prototype, "accessor", + // __decorate([ + // dec + // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + // + // The emit for a property is: + // + // __decorate([ + // dec + // ], C.prototype, "prop"); + // + writeLine(); + emitStart(member); + if (member.kind !== 132 /* PropertyDeclaration */) { + write("Object.defineProperty("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write(","); + increaseIndent(); + writeLine(); + } + write("__decorate(["); + increaseIndent(); + writeLine(); + var decoratorCount = decorators ? decorators.length : 0; + var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + emitStart(decorator); + emit(decorator.expression); + emitEnd(decorator); + }); + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + emitSerializedTypeMetadata(member, argumentsWritten > 0); + decreaseIndent(); + writeLine(); + write("], "); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + if (member.kind !== 132 /* PropertyDeclaration */) { + write(", Object.getOwnPropertyDescriptor("); + emitStart(member.name); + emitClassMemberPrefix(node, member); + write(", "); + emitExpressionForPropertyName(member.name); + emitEnd(member.name); + write("))"); + decreaseIndent(); + } + write(");"); + emitEnd(member); + writeLine(); + } + } + function emitDecoratorsOfParameters(node, leadingComma) { + var argumentsWritten = 0; + if (node) { + var parameterIndex = 0; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (ts.nodeIsDecorated(parameter)) { + var decorators = parameter.decorators; + argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + emitStart(decorator); + write("__param(" + parameterIndex + ", "); + emit(decorator.expression); + write(")"); + emitEnd(decorator); + }); + leadingComma = true; + } + ++parameterIndex; + } + } + return argumentsWritten; + } + function shouldEmitTypeMetadata(node) { + // This method determines whether to emit the "design:type" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 134 /* MethodDeclaration */: + case 136 /* GetAccessor */: + case 137 /* SetAccessor */: + case 132 /* PropertyDeclaration */: + return true; + } + return false; + } + function shouldEmitReturnTypeMetadata(node) { + // This method determines whether to emit the "design:returntype" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 134 /* MethodDeclaration */: + return true; + } + return false; + } + function shouldEmitParamTypesMetadata(node) { + // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // compiler option is set. + switch (node.kind) { + case 201 /* ClassDeclaration */: + case 134 /* MethodDeclaration */: + case 137 /* SetAccessor */: + return true; + } + return false; + } + function emitSerializedTypeMetadata(node, writeComma) { + // This method emits the serialized type metadata for a decorator target. + // The caller should have already tested whether the node has decorators. + var argumentsWritten = 0; + if (compilerOptions.emitDecoratorMetadata) { + if (shouldEmitTypeMetadata(node)) { + var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode); + if (serializedType) { + if (writeComma) { + write(", "); + } + writeLine(); + write("__metadata('design:type', "); + emitSerializedType(node, serializedType); + write(")"); + argumentsWritten++; + } + } + if (shouldEmitParamTypesMetadata(node)) { + var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode); + if (serializedTypes) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:paramtypes', ["); + for (var i = 0; i < serializedTypes.length; ++i) { + if (i > 0) { + write(", "); + } + emitSerializedType(node, serializedTypes[i]); + } + write("])"); + argumentsWritten++; + } + } + if (shouldEmitReturnTypeMetadata(node)) { + var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode); + if (serializedType) { + if (writeComma || argumentsWritten) { + write(", "); + } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedType(node, serializedType); + write(")"); + argumentsWritten++; + } + } + } + return argumentsWritten; + } + function serializeTypeNameSegment(location, path, index) { + switch (index) { + case 0: + return "typeof " + path[index] + " !== 'undefined' && " + path[index]; + case 1: + return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; + default: + var temp = createAndRecordTempVariable(0 /* Auto */).text; + return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; + } + } + function emitSerializedType(location, name) { + if (typeof name === "string") { + write(name); + return; + } + else { + ts.Debug.assert(name.length > 0, "Invalid serialized type name"); + write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); + } + } + function emitInterfaceDeclaration(node) { + emitOnlyPinnedOrTripleSlashComments(node); + } + function shouldEmitEnumDeclaration(node) { + var isConstEnum = ts.isConst(node); + return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation; + } + function emitEnumDeclaration(node) { + // const enums are completely erased during compilation. + if (!shouldEmitEnumDeclaration(node)) { + return; + } + if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + emitEnd(node); + write(";"); + } + writeLine(); + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") {"); + increaseIndent(); + scopeEmitStart(node); + emitLines(node.members); + decreaseIndent(); + writeLine(); + emitToken(15 /* CloseBraceToken */, node.members.end); + scopeEmitEnd(); + write(")("); + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */) { + writeLine(); + emitStart(node); + write("var "); + emit(node.name); + write(" = "); + emitModuleMemberName(node); + emitEnd(node); + write(";"); + } + if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile) { + emitExportMemberAssignments(node.name); + } + } + function emitEnumMember(node) { + var enumParent = node.parent; + emitStart(node); + write(getGeneratedNameForNode(enumParent)); + write("["); + write(getGeneratedNameForNode(enumParent)); + write("["); + emitExpressionForPropertyName(node.name); + write("] = "); + writeEnumMemberDeclarationValue(node); + write("] = "); + emitExpressionForPropertyName(node.name); + emitEnd(node); + write(";"); + } + function writeEnumMemberDeclarationValue(member) { + var value = resolver.getConstantValue(member); + if (value !== undefined) { + write(value.toString()); + return; + } + else if (member.initializer) { + emit(member.initializer); + } + else { + write("undefined"); + } + } + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { + if (moduleDeclaration.body.kind === 205 /* ModuleDeclaration */) { + var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } + } + function shouldEmitModuleDeclaration(node) { + return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation); + } + function isModuleMergedWithES6Class(node) { + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); + } + function emitModuleDeclaration(node) { + // Emit only if this module is non-ambient. + var shouldEmit = shouldEmitModuleDeclaration(node); + if (!shouldEmit) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + var hoistedInDeclarationScope = isSourceFileLevelDeclarationInSystemExternalModule(node, false); + var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); + if (emitVarForModule) { + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + } + write("var "); + emit(node.name); + write(";"); + emitEnd(node); + writeLine(); + } + emitStart(node); + write("(function ("); + emitStart(node.name); + write(getGeneratedNameForNode(node)); + emitEnd(node.name); + write(") "); + if (node.body.kind === 206 /* ModuleBlock */) { + var saveTempFlags = tempFlags; + var saveTempVariables = tempVariables; + tempFlags = 0; + tempVariables = undefined; + emit(node.body); + tempFlags = saveTempFlags; + tempVariables = saveTempVariables; + } + else { + write("{"); + increaseIndent(); + scopeEmitStart(node); + emitCaptureThisForNodeIfNecessary(node); + writeLine(); + emit(node.body); + decreaseIndent(); + writeLine(); + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + scopeEmitEnd(); + } + write(")("); + // write moduleDecl = containingModule.m only if it is not exported es6 module member + if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + emit(node.name); + write(" = "); + } + emitModuleMemberName(node); + write(" || ("); + emitModuleMemberName(node); + write(" = {}));"); + emitEnd(node); + if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { + if (compilerOptions.module === 3 /* System */ && (node.flags & 1 /* Export */)) { + writeLine(); + write(exportFunctionForFile + "(\""); + emitDeclarationName(node); + write("\", "); + emitDeclarationName(node); + write(")"); + } + emitExportMemberAssignments(node.name); + } + } + function emitRequire(moduleName) { + if (moduleName.kind === 8 /* StringLiteral */) { + write("require("); + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + emitToken(17 /* CloseParenToken */, moduleName.end); + } + else { + write("require()"); + } + } + function getNamespaceDeclarationNode(node) { + if (node.kind === 208 /* ImportEqualsDeclaration */) { + return node; + } + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 211 /* NamespaceImport */) { + return importClause.namedBindings; + } + } + function isDefaultImport(node) { + return node.kind === 209 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + } + function emitExportImportAssignments(node) { + if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + emitExportMemberAssignments(node.name); + } + ts.forEachChild(node, emitExportImportAssignments); + } + function emitImportDeclaration(node) { + if (languageVersion < 2 /* ES6 */) { + return emitExternalImportDeclaration(node); + } + // ES6 import + if (node.importClause) { + var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { + write("import "); + emitStart(node.importClause); + if (shouldEmitDefaultBindings) { + emit(node.importClause.name); + if (shouldEmitNamedBindings) { + write(", "); + } + } + if (shouldEmitNamedBindings) { + emitLeadingComments(node.importClause.namedBindings); + emitStart(node.importClause.namedBindings); + if (node.importClause.namedBindings.kind === 211 /* NamespaceImport */) { + write("* as "); + emit(node.importClause.namedBindings.name); + } + else { + write("{ "); + emitExportOrImportSpecifierList(node.importClause.namedBindings.elements, resolver.isReferencedAliasDeclaration); + write(" }"); + } + emitEnd(node.importClause.namedBindings); + emitTrailingComments(node.importClause.namedBindings); + } + emitEnd(node.importClause); + write(" from "); + emit(node.moduleSpecifier); + write(";"); + } + } + else { + write("import "); + emit(node.moduleSpecifier); + write(";"); + } + } + function emitExternalImportDeclaration(node) { + if (ts.contains(externalImports, node)) { + var isExportedImport = node.kind === 208 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var namespaceDeclaration = getNamespaceDeclarationNode(node); + if (compilerOptions.module !== 2 /* AMD */) { + emitLeadingComments(node); + emitStart(node); + if (namespaceDeclaration && !isDefaultImport(node)) { + // import x = require("foo") + // import * as x from "foo" + if (!isExportedImport) + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + } + else { + // import "foo" + // import x from "foo" + // import { x, y } from "foo" + // import d, * as x from "foo" + // import d, { x, y } from "foo" + var isNakedImport = 209 /* ImportDeclaration */ && !node.importClause; + if (!isNakedImport) { + write("var "); + write(getGeneratedNameForNode(node)); + write(" = "); + } + } + emitRequire(ts.getExternalModuleName(node)); + if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write(", "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + } + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + else { + if (isExportedImport) { + emitModuleMemberName(namespaceDeclaration); + write(" = "); + emit(namespaceDeclaration.name); + write(";"); + } + else if (namespaceDeclaration && isDefaultImport(node)) { + // import d, * as x from "foo" + write("var "); + emitModuleMemberName(namespaceDeclaration); + write(" = "); + write(getGeneratedNameForNode(node)); + write(";"); + } + emitExportImportAssignments(node); + } + } + } + function emitImportEqualsDeclaration(node) { + if (ts.isExternalModuleImportEqualsDeclaration(node)) { + emitExternalImportDeclaration(node); + return; + } + // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when + // - current file is not external module + // - import declaration is top level and target is value imported by entity name + if (resolver.isReferencedAliasDeclaration(node) || + (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { + emitLeadingComments(node); + emitStart(node); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } + emitModuleMemberName(node); + write(" = "); + emit(node.moduleReference); + write(";"); + emitEnd(node); + emitExportImportAssignments(node); + emitTrailingComments(node); + } + } + function emitExportDeclaration(node) { + ts.Debug.assert(compilerOptions.module !== 3 /* System */); + if (languageVersion < 2 /* ES6 */) { + if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { + emitStart(node); + var generatedName = getGeneratedNameForNode(node); + if (node.exportClause) { + // export { x, y, ... } from "foo" + if (compilerOptions.module !== 2 /* AMD */) { + write("var "); + write(generatedName); + write(" = "); + emitRequire(ts.getExternalModuleName(node)); + write(";"); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + if (resolver.isValueAliasDeclaration(specifier)) { + writeLine(); + emitStart(specifier); + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + write(" = "); + write(generatedName); + write("."); + emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + write(";"); + emitEnd(specifier); + } + } + } + else { + // export * from "foo" + writeLine(); + write("__export("); + if (compilerOptions.module !== 2 /* AMD */) { + emitRequire(ts.getExternalModuleName(node)); + } + else { + write(generatedName); + } + write(");"); + } + emitEnd(node); + } + } + else { + if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { + emitStart(node); + write("export "); + if (node.exportClause) { + // export { x, y, ... } + write("{ "); + emitExportOrImportSpecifierList(node.exportClause.elements, resolver.isValueAliasDeclaration); + write(" }"); + } + else { + write("*"); + } + if (node.moduleSpecifier) { + write(" from "); + emitNodeWithoutSourceMap(node.moduleSpecifier); + } + write(";"); + emitEnd(node); + } + } + } + function emitExportOrImportSpecifierList(specifiers, shouldEmit) { + ts.Debug.assert(languageVersion >= 2 /* ES6 */); + var needsComma = false; + for (var _i = 0; _i < specifiers.length; _i++) { + var specifier = specifiers[_i]; + if (shouldEmit(specifier)) { + if (needsComma) { + write(", "); + } + emitStart(specifier); + if (specifier.propertyName) { + emitNodeWithoutSourceMap(specifier.propertyName); + write(" as "); + } + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier); + needsComma = true; + } + } + } + function emitExportAssignment(node) { + if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { + if (languageVersion >= 2 /* ES6 */) { + writeLine(); + emitStart(node); + write("export default "); + var expression = node.expression; + emit(expression); + if (expression.kind !== 200 /* FunctionDeclaration */ && + expression.kind !== 201 /* ClassDeclaration */) { + write(";"); + } + emitEnd(node); + } + else { + writeLine(); + emitStart(node); + if (compilerOptions.module === 3 /* System */) { + write(exportFunctionForFile + "(\"default\","); + emit(node.expression); + write(")"); + } + else { + emitContainingModuleName(node); + if (languageVersion === 0 /* ES3 */) { + write("[\"default\"] = "); + } + else { + write(".default = "); + } + emit(node.expression); + } + write(";"); + emitEnd(node); + } + } + } + function collectExternalModuleInfo(sourceFile) { + externalImports = []; + exportSpecifiers = {}; + exportEquals = undefined; + hasExportStars = false; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 209 /* ImportDeclaration */: + if (!node.importClause || + resolver.isReferencedAliasDeclaration(node.importClause, true)) { + // import "mod" + // import x from "mod" where x is referenced + // import * as x from "mod" where x is referenced + // import { x, y } from "mod" where at least one import is referenced + externalImports.push(node); + } + break; + case 208 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 219 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + // import x = require("mod") where x is referenced + externalImports.push(node); + } + break; + case 215 /* ExportDeclaration */: + if (node.moduleSpecifier) { + if (!node.exportClause) { + // export * from "mod" + externalImports.push(node); + hasExportStars = true; + } + else if (resolver.isValueAliasDeclaration(node)) { + // export { x, y } from "mod" where at least one export is a value symbol + externalImports.push(node); + } + } + else { + // export { x, y } + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + var name_6 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_6] || (exportSpecifiers[name_6] = [])).push(specifier); + } + } + break; + case 214 /* ExportAssignment */: + if (node.isExportEquals && !exportEquals) { + // export = x + exportEquals = node; + } + break; + } + } + } + function emitExportStarHelper() { + if (hasExportStars) { + writeLine(); + write("function __export(m) {"); + increaseIndent(); + writeLine(); + write("for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function getLocalNameForExternalImport(importNode) { + var namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + function getExternalModuleNameText(importNode) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 8 /* StringLiteral */) { + return getLiteralText(moduleName); + } + return undefined; + } + function emitVariableDeclarationsForImports() { + if (externalImports.length === 0) { + return; + } + writeLine(); + var started = false; + for (var _i = 0; _i < externalImports.length; _i++) { + var importNode = externalImports[_i]; + // do not create variable declaration for exports and imports that lack import clause + var skipNode = importNode.kind === 215 /* ExportDeclaration */ || + (importNode.kind === 209 /* ImportDeclaration */ && !importNode.importClause); + if (skipNode) { + continue; + } + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + write(getLocalNameForExternalImport(importNode)); + } + if (started) { + write(";"); + } + } + function hoistTopLevelVariableAndFunctionDeclarations(node) { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + var hoistedVars; + var hoistedFunctionDeclarations; + visit(node); + if (hoistedVars) { + writeLine(); + write("var "); + for (var i = 0; i < hoistedVars.length; ++i) { + var local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === 201 /* ClassDeclaration */ || local.kind === 205 /* ModuleDeclaration */) { + emitDeclarationName(local); + } + else { + emit(local); + } + } + write(";"); + } + if (hoistedFunctionDeclarations) { + for (var _i = 0; _i < hoistedFunctionDeclarations.length; _i++) { + var f = hoistedFunctionDeclarations[_i]; + writeLine(); + emit(f); + } + } + function visit(node) { + if (node.kind === 200 /* FunctionDeclaration */) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + hoistedFunctionDeclarations.push(node); + return; + } + if (node.kind === 201 /* ClassDeclaration */) { + // TODO: rename block scoped classes + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 205 /* ModuleDeclaration */ && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node); + return; + } + if (node.kind === 198 /* VariableDeclaration */ || node.kind === 152 /* BindingElement */) { + if (shouldHoistVariable(node, false)) { + var name_7 = node.name; + if (name_7.kind === 65 /* Identifier */) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(name_7); + } + else { + ts.forEachChild(name_7, visit); + } + } + return; + } + if (ts.isBindingPattern(node)) { + ts.forEach(node.elements, visit); + return; + } + if (!ts.isDeclaration(node)) { + ts.forEachChild(node, visit); + } + } + } + function shouldHoistVariable(node, checkIfSourceFileLevelDecl) { + if (checkIfSourceFileLevelDecl && !isSourceFileLevelDeclarationInSystemExternalModule(node, false)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 227 /* SourceFile */; + } + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === 3 /* System */ && ts.isExternalModule(currentSourceFile); + } + function emitSystemModuleBody(node, startIndex) { + // shape of the body in system modules: + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // I.e: + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // will be transformed to + // function(exports) { + // var file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + hoistTopLevelVariableAndFunctionDeclarations(node); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(true); + decreaseIndent(); + writeLine(); + write("}"); // return + } + function emitSetters() { + write("setters:["); + for (var i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + writeLine(); + increaseIndent(); + var importNode = externalImports[i]; + var importVariableName = getLocalNameForExternalImport(importNode) || ""; + var parameterName = "_" + importVariableName; + write("function (" + parameterName + ") {"); + switch (importNode.kind) { + case 209 /* ImportDeclaration */: + if (!importNode.importClause) { + // 'import "..."' case + // module is imported only for side-effects, setter body will be empty + break; + } + // fall-through + case 208 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + writeLine(); + // save import into the local + write(importVariableName + " = " + parameterName); + writeLine(); + var defaultName = importNode.kind === 209 /* ImportDeclaration */ + ? importNode.importClause.name + : importNode.name; + if (defaultName) { + // emit re-export for imported default name + // import n1 from 'foo1' + // import n2 = require('foo2') + // export {n1} + // export {n2} + emitExportMemberAssignments(defaultName); + writeLine(); + } + if (importNode.kind === 209 /* ImportDeclaration */ && + importNode.importClause.namedBindings) { + var namedBindings = importNode.importClause.namedBindings; + if (namedBindings.kind === 211 /* NamespaceImport */) { + // emit re-export for namespace + // import * as n from 'foo' + // export {n} + emitExportMemberAssignments(namedBindings.name); + writeLine(); + } + else { + // emit re-exports for named imports + // import {a, b} from 'foo' + // export {a, b as c} + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + emitExportMemberAssignments(element.name || element.propertyName); + writeLine(); + } + } + } + decreaseIndent(); + break; + case 215 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + increaseIndent(); + if (importNode.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports('a', _foo["a"]) + // exports('c', _foo["b"]) + for (var _b = 0, _c = importNode.exportClause.elements; _b < _c.length; _b++) { + var e = _c[_b]; + writeLine(); + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(e.name); + write("\", " + parameterName + "[\""); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write("\"]);"); + } + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // for (var n in _foo) exports(n, _foo[n]); + // NOTE: it is safe to use name 'n' since parameter name always starts with '_' + write("for (var n in " + parameterName + ") " + exportFunctionForFile + "(n, " + parameterName + "[n]);"); + } + writeLine(); + decreaseIndent(); + break; + } + write("}"); + decreaseIndent(); + } + write("],"); + } + function emitExecute(node, startIndex) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (var i = startIndex; i < node.statements.length; ++i) { + var statement = node.statements[i]; + // - imports/exports are not emitted for system modules + // - function declarations are not emitted because they were already hoisted + switch (statement.kind) { + case 215 /* ExportDeclaration */: + case 209 /* ImportDeclaration */: + case 208 /* ImportEqualsDeclaration */: + case 200 /* FunctionDeclaration */: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}"); // execute + } + function emitSystemModule(node, startIndex) { + collectExternalModuleInfo(node); + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. + // 'exports' returns its 'value' argument so in most cases expressions + // that mutate exported values can be rewritten as: + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, + // see comment to 'emitPostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (var i = 0; i < externalImports.length; ++i) { + var text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write("], function(" + exportFunctionForFile + ") {"); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitAMDModule(node, startIndex) { + collectExternalModuleInfo(node); + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + var aliasedModuleNames = []; // names of modules with corresponding parameter in the + // factory function. + var unaliasedModuleNames = []; // names of modules with no corresponding parameters in + // factory function. + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push("\"" + amdDependency.path + "\""); + importAliasNames.push(amdDependency.name); + } + else { + unaliasedModuleNames.push("\"" + amdDependency.path + "\""); + } + } + for (var _b = 0; _b < externalImports.length; _b++) { + var importNode = externalImports[_b]; + // Find the name of the external module + var externalModuleName = getExternalModuleNameText(importNode); + // Find the name of the module alias, if there is one + var importAliasName = getLocalNameForExternalImport(importNode); + if (importAliasName) { + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(importAliasName); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + write("[\"require\", \"exports\""); + if (aliasedModuleNames.length) { + write(", "); + write(aliasedModuleNames.join(", ")); + } + if (unaliasedModuleNames.length) { + write(", "); + write(unaliasedModuleNames.join(", ")); + } + write("], function (require, exports"); + if (importAliasNames.length) { + write(", "); + write(importAliasNames.join(", ")); + } + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitCommonJSModule(node, startIndex) { + collectExternalModuleInfo(node); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + emitExportEquals(false); + } + function emitES6Module(node, startIndex) { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + // Emit exportDefault if it exists will happen as part + // or normal statement emit. + } + function emitExportEquals(emitAsReturn) { + if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + writeLine(); + emitStart(exportEquals); + write(emitAsReturn ? "return " : "module.exports = "); + emit(exportEquals.expression); + write(";"); + emitEnd(exportEquals); + } + } + function emitDirectivePrologues(statements, startWithNewLine) { + for (var i = 0; i < statements.length; ++i) { + if (ts.isPrologueDirective(statements[i])) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statements[i]); + } + else { + // return index of the first non prologue directive + return i; + } + } + return statements.length; + } + function writeLines(text) { + var lines = text.split(/\r\n|\r|\n/g); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line.length) { + writeLine(); + write(line); + } + } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, false); + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as is. + if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */)) { + writeLines(extendsHelper); + extendsEmitted = true; + } + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { + writeLines(decorateHelper); + if (compilerOptions.emitDecoratorMetadata) { + writeLines(metadataHelper); + } + decorateEmitted = true; + } + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { + writeLines(paramHelper); + paramEmitted = true; + } + if (ts.isExternalModule(node)) { + if (languageVersion >= 2 /* ES6 */) { + emitES6Module(node, startIndex); + } + else if (compilerOptions.module === 2 /* AMD */) { + emitAMDModule(node, startIndex); + } + else if (compilerOptions.module === 3 /* System */) { + emitSystemModule(node, startIndex); + } + else { + emitCommonJSModule(node, startIndex); + } + } + else { + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStars = false; + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(true); + } + emitLeadingComments(node.endOfFileToken); + } + function emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers) { + if (!node) { + return; + } + if (node.flags & 2 /* Ambient */) { + return emitOnlyPinnedOrTripleSlashComments(node); + } + var emitComments = shouldEmitLeadingAndTrailingComments(node); + if (emitComments) { + emitLeadingComments(node); + } + emitJavaScriptWorker(node, allowGeneratedIdentifiers); + if (emitComments) { + emitTrailingComments(node); + } + } + function shouldEmitLeadingAndTrailingComments(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 202 /* InterfaceDeclaration */: + case 200 /* FunctionDeclaration */: + case 209 /* ImportDeclaration */: + case 208 /* ImportEqualsDeclaration */: + case 203 /* TypeAliasDeclaration */: + case 214 /* ExportAssignment */: + return false; + case 205 /* ModuleDeclaration */: + // Only emit the leading/trailing comments for a module if we're actually + // emitting the module as well. + return shouldEmitModuleDeclaration(node); + case 204 /* EnumDeclaration */: + // Only emit the leading/trailing comments for an enum if we're actually + // emitting the module as well. + return shouldEmitEnumDeclaration(node); + } + // If this is the expression body of an arrow function that we're down-leveling, + // then we don't want to emit comments when we emit the body. It will have already + // been taken care of when we emitted the 'return' statement for the function + // expression body. + if (node.kind !== 179 /* Block */ && + node.parent && + node.parent.kind === 163 /* ArrowFunction */ && + node.parent.body === node && + compilerOptions.target <= 1 /* ES5 */) { + return false; + } + // Emit comments for everything else. + return true; + } + function emitJavaScriptWorker(node, allowGeneratedIdentifiers) { + if (allowGeneratedIdentifiers === void 0) { allowGeneratedIdentifiers = true; } + // Check if the node can be emitted regardless of the ScriptTarget + switch (node.kind) { + case 65 /* Identifier */: + return emitIdentifier(node, allowGeneratedIdentifiers); + case 129 /* Parameter */: + return emitParameter(node); + case 134 /* MethodDeclaration */: + case 133 /* MethodSignature */: + return emitMethod(node); + case 136 /* GetAccessor */: + case 137 /* SetAccessor */: + return emitAccessor(node); + case 93 /* ThisKeyword */: + return emitThis(node); + case 91 /* SuperKeyword */: + return emitSuper(node); + case 89 /* NullKeyword */: + return write("null"); + case 95 /* TrueKeyword */: + return write("true"); + case 80 /* FalseKeyword */: + return write("false"); + case 7 /* NumericLiteral */: + case 8 /* StringLiteral */: + case 9 /* RegularExpressionLiteral */: + case 10 /* NoSubstitutionTemplateLiteral */: + case 11 /* TemplateHead */: + case 12 /* TemplateMiddle */: + case 13 /* TemplateTail */: + return emitLiteral(node); + case 171 /* TemplateExpression */: + return emitTemplateExpression(node); + case 176 /* TemplateSpan */: + return emitTemplateSpan(node); + case 126 /* QualifiedName */: + return emitQualifiedName(node); + case 150 /* ObjectBindingPattern */: + return emitObjectBindingPattern(node); + case 151 /* ArrayBindingPattern */: + return emitArrayBindingPattern(node); + case 152 /* BindingElement */: + return emitBindingElement(node); + case 153 /* ArrayLiteralExpression */: + return emitArrayLiteral(node); + case 154 /* ObjectLiteralExpression */: + return emitObjectLiteral(node); + case 224 /* PropertyAssignment */: + return emitPropertyAssignment(node); + case 225 /* ShorthandPropertyAssignment */: + return emitShorthandPropertyAssignment(node); + case 127 /* ComputedPropertyName */: + return emitComputedPropertyName(node); + case 155 /* PropertyAccessExpression */: + return emitPropertyAccess(node); + case 156 /* ElementAccessExpression */: + return emitIndexedAccess(node); + case 157 /* CallExpression */: + return emitCallExpression(node); + case 158 /* NewExpression */: + return emitNewExpression(node); + case 159 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 160 /* TypeAssertionExpression */: + return emit(node.expression); + case 161 /* ParenthesizedExpression */: + return emitParenExpression(node); + case 200 /* FunctionDeclaration */: + case 162 /* FunctionExpression */: + case 163 /* ArrowFunction */: + return emitFunctionDeclaration(node); + case 164 /* DeleteExpression */: + return emitDeleteExpression(node); + case 165 /* TypeOfExpression */: + return emitTypeOfExpression(node); + case 166 /* VoidExpression */: + return emitVoidExpression(node); + case 167 /* PrefixUnaryExpression */: + return emitPrefixUnaryExpression(node); + case 168 /* PostfixUnaryExpression */: + return emitPostfixUnaryExpression(node); + case 169 /* BinaryExpression */: + return emitBinaryExpression(node); + case 170 /* ConditionalExpression */: + return emitConditionalExpression(node); + case 173 /* SpreadElementExpression */: + return emitSpreadElementExpression(node); + case 172 /* YieldExpression */: + return emitYieldExpression(node); + case 175 /* OmittedExpression */: + return; + case 179 /* Block */: + case 206 /* ModuleBlock */: + return emitBlock(node); + case 180 /* VariableStatement */: + return emitVariableStatement(node); + case 181 /* EmptyStatement */: + return write(";"); + case 182 /* ExpressionStatement */: + return emitExpressionStatement(node); + case 183 /* IfStatement */: + return emitIfStatement(node); + case 184 /* DoStatement */: + return emitDoStatement(node); + case 185 /* WhileStatement */: + return emitWhileStatement(node); + case 186 /* ForStatement */: + return emitForStatement(node); + case 188 /* ForOfStatement */: + case 187 /* ForInStatement */: + return emitForInOrForOfStatement(node); + case 189 /* ContinueStatement */: + case 190 /* BreakStatement */: + return emitBreakOrContinueStatement(node); + case 191 /* ReturnStatement */: + return emitReturnStatement(node); + case 192 /* WithStatement */: + return emitWithStatement(node); + case 193 /* SwitchStatement */: + return emitSwitchStatement(node); + case 220 /* CaseClause */: + case 221 /* DefaultClause */: + return emitCaseOrDefaultClause(node); + case 194 /* LabeledStatement */: + return emitLabelledStatement(node); + case 195 /* ThrowStatement */: + return emitThrowStatement(node); + case 196 /* TryStatement */: + return emitTryStatement(node); + case 223 /* CatchClause */: + return emitCatchClause(node); + case 197 /* DebuggerStatement */: + return emitDebuggerStatement(node); + case 198 /* VariableDeclaration */: + return emitVariableDeclaration(node); + case 174 /* ClassExpression */: + return emitClassExpression(node); + case 201 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 202 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 204 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 226 /* EnumMember */: + return emitEnumMember(node); + case 205 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 209 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 208 /* ImportEqualsDeclaration */: + return emitImportEqualsDeclaration(node); + case 215 /* ExportDeclaration */: + return emitExportDeclaration(node); + case 214 /* ExportAssignment */: + return emitExportAssignment(node); + case 227 /* SourceFile */: + return emitSourceFileNode(node); + } + } + function hasDetachedComments(pos) { + return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; + } + function getLeadingCommentsWithoutDetachedComments() { + // get the leading comments from detachedPos + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + if (detachedCommentsInfo.length - 1) { + detachedCommentsInfo.pop(); + } + else { + detachedCommentsInfo = undefined; + } + return leadingComments; + } + function filterComments(ranges, onlyPinnedOrTripleSlashComments) { + // If we're removing comments, then we want to strip out all but the pinned or + // triple slash comments. + if (ranges && onlyPinnedOrTripleSlashComments) { + ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); + if (ranges.length === 0) { + return undefined; + } + } + return ranges; + } + function getLeadingCommentsToEmit(node) { + // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 227 /* SourceFile */ || node.pos !== node.parent.pos) { + if (hasDetachedComments(node.pos)) { + // get comments without detached comments + return getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + return ts.getLeadingCommentRangesOfNode(node, currentSourceFile); + } + } + } + } + function getTrailingCommentsToEmit(node) { + // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments + if (node.parent) { + if (node.parent.kind === 227 /* SourceFile */ || node.end !== node.parent.end) { + return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + } + } + } + function emitOnlyPinnedOrTripleSlashComments(node) { + emitLeadingCommentsWorker(node, true); + } + function emitLeadingComments(node) { + return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + } + function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { + // If the caller only wants pinned or triple slash comments, then always filter + // down to that set. Otherwise, filter based on the current compiler options. + var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitTrailingComments(node) { + // Emit the trailing comments only if the parent's end doesn't match + var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + } + function emitLeadingCommentsOfPosition(pos) { + var leadingComments; + if (hasDetachedComments(pos)) { + // get comments without detached comments + leadingComments = getLeadingCommentsWithoutDetachedComments(); + } + else { + // get the leading comments from the node + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); + } + leadingComments = filterComments(leadingComments, compilerOptions.removeComments); + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space + ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + } + function emitDetachedComments(node) { + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + if (leadingComments) { + var detachedComments = []; + var lastComment; + ts.forEach(leadingComments, function (comment) { + if (lastComment) { + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + return detachedComments; + } + } + detachedComments.push(comment); + lastComment = comment; + }); + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); + } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; + } + } + } + } + } + function isPinnedOrTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { + return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && + currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { + return true; + } + } + } + function emitFile(jsFilePath, sourceFile) { + emitJavaScript(jsFilePath, sourceFile); + if (compilerOptions.declaration) { + ts.writeDeclarationFile(jsFilePath, sourceFile, host, resolver, diagnostics); + } + } + } + ts.emitFiles = emitFiles; +})(ts || (ts = {})); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 90d5022f6cd..48718146ac6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -34,7 +34,8 @@ var __extends = this.__extends || function (d, b) { // emit output for the __decorate helper function const decorateHelper = ` -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); @@ -44,11 +45,15 @@ var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.deco // emit output for the __metadata helper function const metadataHelper = ` -var __metadata = this.__metadata || (typeof Reflect === "object" && Reflect.metadata) || function () { };`; +if (typeof __metadata !== "function") __metadata = function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +};`; // emit output for the __param helper function const paramHelper = ` -var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } };`; +if (typeof __param !== "function") __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +};`; let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; @@ -117,6 +122,13 @@ var __param = this.__param || function(index, decorator) { return function (targ let decreaseIndent = writer.decreaseIndent; let currentSourceFile: SourceFile; + // name of an exporter function if file is a System external module + // System.register([...], function () {...}) + // exporting in System modules looks like: + // export var x; ... x = 1 + // => + // var x;... exporter("x", x = 1) + let exportFunctionForFile: string; let generatedNameSet: Map = {}; let nodeToGeneratedName: string[] = []; @@ -191,6 +203,7 @@ var __param = this.__param || function(index, decorator) { return function (targ function emitSourceFile(sourceFile: SourceFile): void { currentSourceFile = sourceFile; + exportFunctionForFile = undefined; emit(sourceFile); } @@ -1165,7 +1178,7 @@ var __param = this.__param || function(index, decorator) { return function (targ if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; } - + let generatedName = computedPropertyNamesToGeneratedNames[getNodeId(node)]; if (generatedName) { // we have already generated a variable for this node, write that value instead. @@ -1952,7 +1965,35 @@ var __param = this.__param || function(index, decorator) { return function (targ emit(node.expression); } + function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node: Node): boolean { + if (!isCurrentFileSystemExternalModule() || node.kind !== SyntaxKind.Identifier || nodeIsSynthesized(node)) { + return false; + } + + const isVariableDeclarationOrBindingElement = + node.parent && (node.parent.kind === SyntaxKind.VariableDeclaration || node.parent.kind === SyntaxKind.BindingElement); + + const targetDeclaration = + isVariableDeclarationOrBindingElement + ? node.parent + : resolver.getReferencedValueDeclaration(node); + + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); + } + function emitPrefixUnaryExpression(node: PrefixUnaryExpression) { + const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + + if (exportChanged) { + // emit + // ++x + // as + // exports('x', ++x) + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(node.operand); + write(`", `); + } + write(tokenToString(node.operator)); // In some cases, we need to emit a space between the operator and the operand. One obvious case // is when the operator is an identifier, like delete or typeof. We also need to do this for plus @@ -1976,11 +2017,69 @@ var __param = this.__param || function(index, decorator) { return function (targ } } emit(node.operand); + + if (exportChanged) { + write(")"); + } } function emitPostfixUnaryExpression(node: PostfixUnaryExpression) { - emit(node.operand); - write(tokenToString(node.operator)); + const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + if (exportChanged) { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + write(`(${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(node.operand); + write(`", `); + + write(tokenToString(node.operator)); + emit(node.operand); + + if (node.operator === SyntaxKind.PlusPlusToken) { + write(") - 1)"); + } + else { + write(") + 1)"); + } + } + else { + emit(node.operand); + write(tokenToString(node.operator)); + } + } + + function shouldHoistDeclarationInSystemJsModule(node: Node): boolean { + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); + } + + /* + * Checks if given node is a source file level declaration (not nested in module/function). + * If 'isExported' is true - then declaration must also be exported. + * This function is used in two cases: + * - check if node is a exported source file level value to determine + * if we should also export the value after its it changed + * - check if node is a source level declaration to emit it differently, + * i.e non-exported variable statement 'var x = 1' is hoisted so + * we we emit variable statement 'var' should be dropped. + */ + function isSourceFileLevelDeclarationInSystemJsModule(node: Node, isExported: boolean): boolean { + if (!node || languageVersion >= ScriptTarget.ES6 || !isCurrentFileSystemExternalModule()) { + return false; + } + + let current: Node = node; + while (current) { + if (current.kind === SyntaxKind.SourceFile) { + return !isExported || ((getCombinedNodeFlags(node) & NodeFlags.Export) !== 0) + } + else if (isFunctionLike(current) || current.kind === SyntaxKind.ModuleBlock) { + return false; + } + else { + current = current.parent; + } + } } function emitBinaryExpression(node: BinaryExpression) { @@ -1989,12 +2088,26 @@ var __param = this.__param || function(index, decorator) { return function (targ emitDestructuring(node, node.parent.kind === SyntaxKind.ExpressionStatement); } else { + const exportChanged = + node.operatorToken.kind >= SyntaxKind.FirstAssignment && + node.operatorToken.kind <= SyntaxKind.LastAssignment && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); + + if (exportChanged) { + // emit assignment 'x y' as 'exports("x", x y)' + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(node.left); + write(`", `); + } emit(node.left); let indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== SyntaxKind.CommaToken ? " " : undefined); write(tokenToString(node.operatorToken.kind)); let indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); decreaseIndentIf(indentedBeforeOperator, indentedAfterOperator); + if (exportChanged) { + write(")"); + } } } @@ -2120,7 +2233,16 @@ var __param = this.__param || function(index, decorator) { return function (targ emitEmbeddedStatement(node.statement); } - function emitStartOfVariableDeclarationList(decl: Node, startPos?: number): void { + /* Returns true if start of variable declaration list was emitted. + * Return false if nothing was written - this can happen for source file level variable declarations + * in system modules - such variable declarations are hoisted. + */ + function tryEmitStartOfVariableDeclarationList(decl: VariableDeclarationList, startPos?: number): boolean { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { + // variables in variable declaration list were already hoisted + return false; + } + let tokenKind = SyntaxKind.VarKeyword; if (decl && languageVersion >= ScriptTarget.ES6) { if (isLet(decl)) { @@ -2133,17 +2255,43 @@ var __param = this.__param || function(index, decorator) { return function (targ if (startPos !== undefined) { emitToken(tokenKind, startPos); + write(" ") } else { switch (tokenKind) { case SyntaxKind.VarKeyword: - return write("var "); + write("var "); + break; case SyntaxKind.LetKeyword: - return write("let "); + write("let "); + break; case SyntaxKind.ConstKeyword: - return write("const "); + write("const "); + break; } } + + return true; + } + + function emitVariableDeclarationListSkippingUninitializedEntries(list: VariableDeclarationList): boolean { + let started = false; + for (let decl of list.declarations) { + if (!decl.initializer) { + continue; + } + + if (!started) { + started = true; + } + else { + write(", "); + } + + emit(decl); + } + + return started; } function emitForStatement(node: ForStatement) { @@ -2152,10 +2300,13 @@ var __param = this.__param || function(index, decorator) { return function (targ endPos = emitToken(SyntaxKind.OpenParenToken, endPos); if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { let variableDeclarationList = node.initializer; - let declarations = variableDeclarationList.declarations; - emitStartOfVariableDeclarationList(declarations[0], endPos); - write(" "); - emitCommaList(declarations); + let startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + if (startIsEmitted) { + emitCommaList(variableDeclarationList.declarations); + } + else { + emitVariableDeclarationListSkippingUninitializedEntries(variableDeclarationList); + } } else if (node.initializer) { emit(node.initializer); @@ -2163,7 +2314,7 @@ var __param = this.__param || function(index, decorator) { return function (targ write(";"); emitOptional(" ", node.condition); write(";"); - emitOptional(" ", node.iterator); + emitOptional(" ", node.incrementor); write(")"); emitEmbeddedStatement(node.statement); } @@ -2179,10 +2330,8 @@ var __param = this.__param || function(index, decorator) { return function (targ if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { let variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { - let decl = variableDeclarationList.declarations[0]; - emitStartOfVariableDeclarationList(decl, endPos); - write(" "); - emit(decl); + tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); + emit(variableDeclarationList.declarations[0]); } } else { @@ -2476,7 +2625,7 @@ var __param = this.__param || function(index, decorator) { return function (targ write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < ScriptTarget.ES6) { + else if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) { write("exports."); } } @@ -2496,18 +2645,35 @@ var __param = this.__param || function(index, decorator) { return function (targ if (node.flags & NodeFlags.Export) { writeLine(); emitStart(node); - if (node.flags & NodeFlags.Default) { - if (languageVersion === ScriptTarget.ES3) { - write("exports[\"default\"]"); - } else { - write("exports.default"); + + if (compilerOptions.module === ModuleKind.System) { + // emit export default as + // export("default", ) + write(`${exportFunctionForFile}("`); + if (node.flags & NodeFlags.Default) { + write("default"); } + else { + emitNodeWithoutSourceMap(node.name); + } + write(`", `); + emitDeclarationName(node); + write(")") } else { - emitModuleMemberName(node); + if (node.flags & NodeFlags.Default) { + if (languageVersion === ScriptTarget.ES3) { + write("exports[\"default\"]"); + } else { + write("exports.default"); + } + } + else { + emitModuleMemberName(node); + } + write(" = "); + emitDeclarationName(node); } - write(" = "); - emitDeclarationName(node); emitEnd(node); write(";"); } @@ -2518,12 +2684,21 @@ var __param = this.__param || function(index, decorator) { return function (targ for (let specifier of exportSpecifiers[name.text]) { writeLine(); emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); + if (compilerOptions.module === ModuleKind.System) { + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(specifier.name); + write(`", `); + emitExpressionIdentifier(name); + write(")") + } + else { + emitContainingModuleName(specifier); + write("."); + emitNodeWithoutSourceMap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); + } write(";"); } } @@ -2531,9 +2706,21 @@ var __param = this.__param || function(index, decorator) { return function (targ function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, isAssignmentExpressionStatement: boolean, value?: Expression) { let emitCount = 0; + // An exported declaration is actually emitted as an assignment (to a property on the module object), so // temporary variables in an exported declaration need to have real declarations elsewhere - let isDeclaration = (root.kind === SyntaxKind.VariableDeclaration && !(getCombinedNodeFlags(root) & NodeFlags.Export)) || root.kind === SyntaxKind.Parameter; + // Also temporary variables should be explicitly allocated for source level declarations when module target is system + // because actual variable declarations are hoisted + let canDefineTempVariablesInPlace = false; + if (root.kind === SyntaxKind.VariableDeclaration) { + let isExported = getCombinedNodeFlags(root) & NodeFlags.Export; + let isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); + canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; + } + else if (root.kind === SyntaxKind.Parameter) { + canDefineTempVariablesInPlace = true; + } + if (root.kind === SyntaxKind.BinaryExpression) { emitAssignmentExpression(root); } @@ -2548,20 +2735,37 @@ var __param = this.__param || function(index, decorator) { return function (targ } renameNonTopLevelLetAndConst(name); - if (name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement)) { + + const isVariableDeclarationOrBindingElement = + name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement); + + let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); + + if (exportChanged) { + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(name); + write(`", `); + } + + if (isVariableDeclarationOrBindingElement) { emitModuleMemberName(name.parent); } else { emit(name); } + write(" = "); emit(value); + + if (exportChanged) { + write(")"); + } } function ensureIdentifier(expr: Expression): Expression { if (expr.kind !== SyntaxKind.Identifier) { let identifier = createTempVariable(TempFlags.Auto); - if (!isDeclaration) { + if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); } emitAssignment(identifier, expr); @@ -2741,7 +2945,6 @@ var __param = this.__param || function(index, decorator) { return function (targ } else { renameNonTopLevelLetAndConst(node.name); - emitModuleMemberName(node); let initializer = node.initializer; if (!initializer && languageVersion < ScriptTarget.ES6) { @@ -2764,7 +2967,20 @@ var __param = this.__param || function(index, decorator) { return function (targ } } + let exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); + + if (exportChanged) { + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(node.name); + write(`", `); + } + + emitModuleMemberName(node); emitOptional(" = ", initializer); + + if (exportChanged) { + write(")") + } } } @@ -2844,16 +3060,25 @@ var __param = this.__param || function(index, decorator) { return function (targ } function emitVariableStatement(node: VariableStatement) { + let startIsEmitted = true; if (!(node.flags & NodeFlags.Export)) { - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); } else if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); - emitStartOfVariableDeclarationList(node.declarationList); + startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); + } + if (startIsEmitted) { + emitCommaList(node.declarationList.declarations); + write(";"); + } + else { + let atLeastOneItem = emitVariableDeclarationListSkippingUninitializedEntries(node.declarationList); + if (atLeastOneItem) { + write(";"); + } } - emitCommaList(node.declarationList.declarations); - write(";"); if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { forEach(node.declarationList.declarations, emitExportVariableAssignments); } @@ -3744,7 +3969,10 @@ var __param = this.__param || function(index, decorator) { return function (targ function emitClassLikeDeclarationBelowES6(node: ClassLikeDeclaration) { if (node.kind === SyntaxKind.ClassDeclaration) { - write("var "); + // source file level classes in system modules are hoisted so 'var's for them are already defined + if (!shouldHoistDeclarationInSystemJsModule(node)) { + write("var "); + } emitDeclarationName(node); write(" = "); } @@ -4254,13 +4482,14 @@ var __param = this.__param || function(index, decorator) { return function (targ if (!shouldEmit) { return emitOnlyPinnedOrTripleSlashComments(node); } + let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); + let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); - if (!isModuleMergedWithES6Class(node)) { + if (emitVarForModule) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); } - write("var "); emit(node.name); write(";"); @@ -4310,6 +4539,14 @@ var __param = this.__param || function(index, decorator) { return function (targ write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { + if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + writeLine(); + write(`${exportFunctionForFile}("`); + emitDeclarationName(node); + write(`", `); + emitDeclarationName(node); + write(")"); + } emitExportMemberAssignments(node.name); } } @@ -4486,6 +4723,8 @@ var __param = this.__param || function(index, decorator) { return function (targ } function emitExportDeclaration(node: ExportDeclaration) { + Debug.assert(compilerOptions.module !== ModuleKind.System); + if (languageVersion < ScriptTarget.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); @@ -4591,13 +4830,20 @@ var __param = this.__param || function(index, decorator) { return function (targ else { writeLine(); emitStart(node); - emitContainingModuleName(node); - if (languageVersion === ScriptTarget.ES3) { - write("[\"default\"] = "); - } else { - write(".default = "); + if (compilerOptions.module === ModuleKind.System) { + write(`${exportFunctionForFile}("default",`); + emit(node.expression); + write(")"); + } + else { + emitContainingModuleName(node); + if (languageVersion === ScriptTarget.ES3) { + write("[\"default\"] = "); + } else { + write(".default = "); + } + emit(node.expression); } - emit(node.expression); write(";"); emitEnd(node); } @@ -4670,27 +4916,407 @@ var __param = this.__param || function(index, decorator) { return function (targ } } - function emitAMDModule(node: SourceFile, startIndex: number) { + function getLocalNameForExternalImport(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { + let namespaceDeclaration = getNamespaceDeclarationNode(importNode); + if (namespaceDeclaration && !isDefaultImport(importNode)) { + return getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); + } + else { + return getGeneratedNameForNode(importNode); + } + } + + function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { + let moduleName = getExternalModuleName(importNode); + if (moduleName.kind === SyntaxKind.StringLiteral) { + return getLiteralText(moduleName); + } + + return undefined; + } + + function emitVariableDeclarationsForImports(): void { + if (externalImports.length === 0) { + return; + } + + writeLine(); + let started = false; + for (let importNode of externalImports) { + // do not create variable declaration for exports and imports that lack import clause + let skipNode = + importNode.kind === SyntaxKind.ExportDeclaration || + (importNode.kind === SyntaxKind.ImportDeclaration && !(importNode).importClause) + + if (skipNode) { + continue; + } + + if (!started) { + write("var "); + started = true; + } + else { + write(", "); + } + + write(getLocalNameForExternalImport(importNode)); + } + + if (started) { + write(";"); + } + } + + function hoistTopLevelVariableAndFunctionDeclarations(node: SourceFile): void { + // per ES6 spec: + // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method + // - var declarations are initialized to undefined - 14.a.ii + // - function/generator declarations are instantiated - 16.a.iv + // this means that after module is instantiated but before its evaluation + // exported functions are already accessible at import sites + // in theory we should hoist only exported functions and its dependencies + // in practice to simplify things we'll hoist all source level functions and variable declaration + // including variables declarations for module and class declarations + let hoistedVars: (Identifier | ClassDeclaration | ModuleDeclaration)[]; + let hoistedFunctionDeclarations: FunctionDeclaration[]; + + visit(node); + + if (hoistedVars) { + writeLine(); + write("var "); + for (let i = 0; i < hoistedVars.length; ++i) { + let local = hoistedVars[i]; + if (i !== 0) { + write(", "); + } + if (local.kind === SyntaxKind.ClassDeclaration || local.kind === SyntaxKind.ModuleDeclaration) { + emitDeclarationName(local); + } + else { + emit(local); + } + } + write(";") + } + + if (hoistedFunctionDeclarations) { + for (let f of hoistedFunctionDeclarations) { + writeLine(); + emit(f); + } + } + + function visit(node: Node): void { + if (node.kind === SyntaxKind.FunctionDeclaration) { + if (!hoistedFunctionDeclarations) { + hoistedFunctionDeclarations = []; + } + + hoistedFunctionDeclarations.push(node); + return; + } + + if (node.kind === SyntaxKind.ClassDeclaration) { + // TODO: rename block scoped classes + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); + return; + } + + if (node.kind === SyntaxKind.ModuleDeclaration && shouldEmitModuleDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(node); + return; + } + + if (node.kind === SyntaxKind.VariableDeclaration || node.kind === SyntaxKind.BindingElement) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { + let name = (node).name; + if (name.kind === SyntaxKind.Identifier) { + if (!hoistedVars) { + hoistedVars = []; + } + + hoistedVars.push(name); + } + else { + forEachChild(name, visit); + } + } + return; + } + + if (isBindingPattern(node)) { + forEach((node).elements, visit); + return; + } + + if (!isDeclaration(node)) { + forEachChild(node, visit); + } + } + } + + function shouldHoistVariable(node: VariableDeclaration | VariableDeclarationList | BindingElement, checkIfSourceFileLevelDecl: boolean): boolean { + if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { + return false; + } + // hoist variable if + // - it is not block scoped + // - it is top level block scoped + // if block scoped variables are nested in some another block then + // no other functions can use them except ones that are defined at least in the same block + return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === 0 || + getEnclosingBlockScopeContainer(node).kind === SyntaxKind.SourceFile; + } + + function isCurrentFileSystemExternalModule() { + return compilerOptions.module === ModuleKind.System && isExternalModule(currentSourceFile); + } + + function emitSystemModuleBody(node: SourceFile, startIndex: number): void { + // shape of the body in system modules: + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // I.e: + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // will be transformed to + // function(exports) { + // var file1; // local alias + // var y; + // function foo() { return y + file1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + emitVariableDeclarationsForImports(); + writeLine(); + hoistTopLevelVariableAndFunctionDeclarations(node); + writeLine(); + write("return {"); + increaseIndent(); + writeLine(); + emitSetters(); + writeLine(); + emitExecute(node, startIndex); + emitTempDeclarations(/*newLine*/ true) + decreaseIndent(); + writeLine(); + write("}"); // return + } + + function emitSetters() { + write("setters:["); + for (let i = 0; i < externalImports.length; ++i) { + if (i !== 0) { + write(","); + } + + writeLine(); + increaseIndent(); + let importNode = externalImports[i]; + let importVariableName = getLocalNameForExternalImport(importNode) || ""; + let parameterName = "_" + importVariableName; + write(`function (${parameterName}) {`); + + switch (importNode.kind) { + case SyntaxKind.ImportDeclaration: + if (!(importNode).importClause) { + // 'import "..."' case + // module is imported only for side-effects, setter body will be empty + break; + } + // fall-through + case SyntaxKind.ImportEqualsDeclaration: + Debug.assert(importVariableName !== ""); + + increaseIndent(); + writeLine(); + // save import into the local + write(`${importVariableName} = ${parameterName}`); + writeLine(); + + let defaultName = + importNode.kind === SyntaxKind.ImportDeclaration + ? (importNode).importClause.name + : (importNode).name; + + if (defaultName) { + // emit re-export for imported default name + // import n1 from 'foo1' + // import n2 = require('foo2') + // export {n1} + // export {n2} + emitExportMemberAssignments(defaultName); + writeLine(); + } + + if (importNode.kind === SyntaxKind.ImportDeclaration && + (importNode).importClause.namedBindings) { + + let namedBindings = (importNode).importClause.namedBindings; + if (namedBindings.kind === SyntaxKind.NamespaceImport) { + // emit re-export for namespace + // import * as n from 'foo' + // export {n} + emitExportMemberAssignments((namedBindings).name); + writeLine(); + } + else { + // emit re-exports for named imports + // import {a, b} from 'foo' + // export {a, b as c} + for (let element of (namedBindings).elements) { + emitExportMemberAssignments(element.name || element.propertyName); + writeLine() + } + } + } + + decreaseIndent(); + break; + case SyntaxKind.ExportDeclaration: + Debug.assert(importVariableName !== ""); + + increaseIndent(); + + if ((importNode).exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports('a', _foo["a"]) + // exports('c', _foo["b"]) + for (let e of (importNode).exportClause.elements) { + writeLine(); + write(`${exportFunctionForFile}("`); + emitNodeWithoutSourceMap(e.name); + write(`", ${parameterName}["`); + emitNodeWithoutSourceMap(e.propertyName || e.name); + write(`"]);`); + } + } + else { + writeLine(); + // export * from 'foo' + // emit as: + // for (var n in _foo) exports(n, _foo[n]); + // NOTE: it is safe to use name 'n' since parameter name always starts with '_' + write(`for (var n in ${parameterName}) ${exportFunctionForFile}(n, ${parameterName}[n]);`); + } + + writeLine(); + decreaseIndent(); + break; + } + + write("}") + decreaseIndent(); + } + write("],"); + } + + function emitExecute(node: SourceFile, startIndex: number) { + write("execute: function() {"); + increaseIndent(); + writeLine(); + for (let i = startIndex; i < node.statements.length; ++i) { + let statement = node.statements[i]; + // - imports/exports are not emitted for system modules + // - function declarations are not emitted because they were already hoisted + switch (statement.kind) { + case SyntaxKind.ExportDeclaration: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.FunctionDeclaration: + continue; + } + writeLine(); + emit(statement); + } + decreaseIndent(); + writeLine(); + write("}") // execute + } + + function emitSystemModule(node: SourceFile, startIndex: number): void { collectExternalModuleInfo(node); - + // System modules has the following shape + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. + // 'exports' returns its 'value' argument so in most cases expressions + // that mutate exported values can be rewritten as: + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, + // see comment to 'emitPostfixUnaryExpression' for more details + Debug.assert(!exportFunctionForFile); + // make sure that name of 'exports' function does not conflict with existing identifiers + exportFunctionForFile = makeUniqueName("exports"); + write("System.register(["); + for (let i = 0; i < externalImports.length; ++i) { + let text = getExternalModuleNameText(externalImports[i]); + if (i !== 0) { + write(", "); + } + write(text); + } + write(`], function(${exportFunctionForFile}) {`); + writeLine(); + increaseIndent(); + emitCaptureThisForNodeIfNecessary(node); + emitSystemModuleBody(node, startIndex); + decreaseIndent(); + writeLine(); + write("});"); + } + + function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) { // An AMD define function has the following shape: // define(id?, dependencies?, factory); // // This has the shape of // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to + // The location of the alias in the parameter list in the factory function needs to // match the position of the module name in the dependency list. // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` // we need to add modules without alias names to the end of the dependencies list - - let aliasedModuleNames: string[] = []; // names of modules with corresponding parameter in the + + let aliasedModuleNames: string[] = []; // names of modules with corresponding parameter in the // factory function. let unaliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in // factory function. let importAliasNames: string[] = []; // names of the parameters in the factory function; these - // paramters need to match the indexes of the corresponding + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags @@ -4706,23 +5332,11 @@ var __param = this.__param || function(index, decorator) { return function (targ for (let importNode of externalImports) { // Find the name of the external module - let externalModuleName = ""; - let moduleName = getExternalModuleName(importNode); - if (moduleName.kind === SyntaxKind.StringLiteral) { - externalModuleName = getLiteralText(moduleName); - } + let externalModuleName = getExternalModuleNameText(importNode); - // Find the name of the module alais, if there is one - let importAliasName: string; - let namespaceDeclaration = getNamespaceDeclarationNode(importNode); - if (namespaceDeclaration && !isDefaultImport(importNode)) { - importAliasName = getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); - } - else { - importAliasName = getGeneratedNameForNode(importNode); - } - - if (importAliasName) { + // Find the name of the module alias, if there is one + let importAliasName = getLocalNameForExternalImport(importNode); + if (includeNonAmdDependencies && importAliasName) { aliasedModuleNames.push(externalModuleName); importAliasNames.push(importAliasName); } @@ -4730,12 +5344,7 @@ var __param = this.__param || function(index, decorator) { return function (targ unaliasedModuleNames.push(externalModuleName); } } - - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } + write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -4750,6 +5359,17 @@ var __param = this.__param || function(index, decorator) { return function (targ write(", "); write(importAliasNames.join(", ")); } + } + + function emitAMDModule(node: SourceFile, startIndex: number) { + collectExternalModuleInfo(node); + + writeLine(); + write("define("); + if (node.amdModuleName) { + write("\"" + node.amdModuleName + "\", "); + } + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); @@ -4771,6 +5391,31 @@ var __param = this.__param || function(index, decorator) { return function (targ emitExportEquals(/*emitAsReturn*/ false); } + function emitUMDModule(node: SourceFile, startIndex: number) { + collectExternalModuleInfo(node); + + // Module is detected first to support Browserify users that load into a browser with an AMD loader + writeLines(`(function (deps, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(deps, factory); + } +})(`); + emitAMDDependencies(node, false); + write(") {"); + increaseIndent(); + emitExportStarHelper(); + emitCaptureThisForNodeIfNecessary(node); + emitLinesStartingAt(node.statements, startIndex); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); + decreaseIndent(); + writeLine(); + write("});"); + } + function emitES6Module(node: SourceFile, startIndex: number) { externalImports = undefined; exportSpecifiers = undefined; @@ -4855,6 +5500,12 @@ var __param = this.__param || function(index, decorator) { return function (targ else if (compilerOptions.module === ModuleKind.AMD) { emitAMDModule(node, startIndex); } + else if (compilerOptions.module === ModuleKind.System) { + emitSystemModule(node, startIndex); + } + else if (compilerOptions.module === ModuleKind.UMD) { + emitUMDModule(node, startIndex); + } else { emitCommonJSModule(node, startIndex); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6ad38ac73c1..1a06a2743ba 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -194,7 +194,7 @@ module ts { case SyntaxKind.ForStatement: return visitNode(cbNode, (node).initializer) || visitNode(cbNode, (node).condition) || - visitNode(cbNode, (node).iterator) || + visitNode(cbNode, (node).incrementor) || visitNode(cbNode, (node).statement); case SyntaxKind.ForInStatement: return visitNode(cbNode, (node).initializer) || @@ -3497,7 +3497,7 @@ module ts { } parseExpected(SyntaxKind.SemicolonToken); if (token !== SyntaxKind.CloseParenToken) { - forStatement.iterator = allowInAnd(parseExpression); + forStatement.incrementor = allowInAnd(parseExpression); } parseExpected(SyntaxKind.CloseParenToken); forOrForInOrForOfStatement = forStatement; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d9bb0914355..3b34e434472 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -455,6 +455,66 @@ module ts { } } + function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string { + let commonPathComponents: string[]; + let currentDirectory = host.getCurrentDirectory(); + forEach(files, sourceFile => { + // Each file contributes into common source file path + if (isDeclarationFile(sourceFile)) { + return; + } + + let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory); + sourcePathComponents.pop(); // The base file name is not part of the common directory path + + if (!commonPathComponents) { + // first file + commonPathComponents = sourcePathComponents; + return; + } + + for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (commonPathComponents[i] !== sourcePathComponents[i]) { + if (i === 0) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return; + } + + // New common path found that is 0 -> i-1 + commonPathComponents.length = i; + break; + } + } + + // If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + + return getNormalizedPathFromPathComponents(commonPathComponents); + } + + function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean { + let allFilesBelongToPath = true; + if (sourceFiles) { + let currentDirectory = host.getCurrentDirectory(); + let absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + + for (var sourceFile of sourceFiles) { + if (!isDeclarationFile(sourceFile)) { + let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } + } + + return allFilesBelongToPath; + } + function verifyCompilerOptions() { if (options.separateCompilation) { if (options.sourceMap) { @@ -526,7 +586,7 @@ module ts { // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); + diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -536,41 +596,16 @@ module ts { (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated (!options.out || firstExternalModuleSourceFile !== undefined))) { - let commonPathComponents: string[]; - forEach(files, sourceFile => { - // Each file contributes into common source file path - if (!(sourceFile.flags & NodeFlags.DeclarationFile) - && !fileExtensionIs(sourceFile.fileName, ".js")) { - let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory()); - sourcePathComponents.pop(); // FileName is not part of directory - if (commonPathComponents) { - for (let i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + // If a rootDir is specified and is valid use it as the commonSourceDirectory + commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); + } + else { + // Compute the commonSourceDirectory from the input files + commonSourceDirectory = computeCommonSourceDirectory(files); + } - // New common path found that is 0 -> i-1 - commonPathComponents.length = i; - break; - } - } - - // If the fileComponent path completely matched and less than already found update the length - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - // first file - commonPathComponents = sourcePathComponents; - } - } - }); - - commonSourceDirectory = getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) { // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index c2b693d6772..df6c20a8107 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -352,7 +352,7 @@ module ts { export function isLineBreak(ch: number): boolean { // ES5 7.3: // The ECMAScript line terminator characters are listed in Table 3. - // Table 3 — Line Terminator Characters + // Table 3: Line Terminator Characters // Code Unit Value Name Formal Name // \u000A Line Feed // \u000D Carriage Return diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 0cbeff8204a..15cc665e351 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -208,12 +208,15 @@ module ts { if (!cachedProgram) { if (configFileName) { - var configObject = readConfigFile(configFileName); - if (!configObject) { - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFileName)); + + let result = readConfigFile(configFileName); + if (result.error) { + reportDiagnostic(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } - var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFileName)); + + let configObject = result.config; + let configParseResult = parseConfigFile(configObject, sys, getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { reportDiagnostics(configParseResult.errors); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -230,7 +233,7 @@ module ts { compilerHost.getSourceFile = getSourceFile; } - var compileResult = compile(rootFileNames, compilerOptions, compilerHost); + let compileResult = compile(rootFileNames, compilerOptions, compilerHost); if (!compilerOptions.watch) { return sys.exit(compileResult.exitStatus); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5b75ffa974d..5bc3219e4d6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -795,7 +795,7 @@ module ts { export interface ForStatement extends IterationStatement { initializer?: VariableDeclarationList | Expression; condition?: Expression; - iterator?: Expression; + incrementor?: Expression; } export interface ForInStatement extends IterationStatement { @@ -1032,6 +1032,10 @@ module ts { getCurrentDirectory(): string; } + export interface ParseConfigHost { + readDirectory(rootDir: string, extension: string): string[]; + } + export interface WriteFileCallback { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } @@ -1274,6 +1278,7 @@ module ts { getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; resolvesToSomeValue(location: Node, name: string): boolean; getBlockScopedVariableId(node: Identifier): number; + getReferencedValueDeclaration(reference: Identifier): Declaration; serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[]; serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[]; @@ -1486,6 +1491,13 @@ module ts { // Class and interface types (TypeFlags.Class and TypeFlags.Interface) export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) + } + + export interface InterfaceTypeWithBaseTypes extends InterfaceType { + baseTypes: ObjectType[]; + } + + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; // Declared members declaredCallSignatures: Signature[]; // Declared call signatures declaredConstructSignatures: Signature[]; // Declared construct signatures @@ -1493,10 +1505,6 @@ module ts { declaredNumberIndexType: Type; // Declared numeric index type } - export interface InterfaceTypeWithBaseTypes extends InterfaceType { - baseTypes: ObjectType[]; - } - // Type references (TypeFlags.Reference) export interface TypeReference extends ObjectType { target: GenericType; // Type reference target @@ -1578,7 +1586,7 @@ module ts { /* @internal */ export interface TypeMapper { - (t: Type): Type; + (t: TypeParameter): Type; } /* @internal */ @@ -1657,6 +1665,7 @@ module ts { preserveConstEnums?: boolean; project?: string; removeComments?: boolean; + rootDir?: string; sourceMap?: boolean; sourceRoot?: string; suppressImplicitAnyIndexErrors?: boolean; @@ -1673,6 +1682,8 @@ module ts { None = 0, CommonJS = 1, AMD = 2, + UMD = 3, + System = 4, } export interface LineAndCharacter { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index db0783358aa..9e77e1c5784 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -775,7 +775,7 @@ module ts { let forStatement = parent; return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || forStatement.condition === node || - forStatement.iterator === node; + forStatement.incrementor === node; case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: let forInStatement = parent; diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 09fddc2ee50..b6997e705b9 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -97,7 +97,7 @@ class CompilerBaselineRunner extends RunnerBase { program = _program; }, function (settings) { harnessCompiler.setCompilerSettings(tcSettings); - }); + }); }); beforeEach(() => { @@ -258,7 +258,7 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct type baselines for ' + fileName, () => { + it('Correct type/symbol baselines for ' + fileName, () => { if (fileName.indexOf("APISample") >= 0) { return; } @@ -295,8 +295,26 @@ class CompilerBaselineRunner extends RunnerBase { // Produce baselines. The first gives the types for all expressions. // The second gives symbols for all identifiers. - checkBaseLines(/*isSymbolBaseLine:*/ false); - checkBaseLines(/*isSymbolBaseLine:*/ true); + var e1: Error, e2: Error; + try { + checkBaseLines(/*isSymbolBaseLine:*/ false); + } + catch (e) { + e1 = e; + } + + try { + checkBaseLines(/*isSymbolBaseLine:*/ true); + } + catch (e) { + e2 = e; + } + + if (e1 || e2) { + throw e1 || e2; + } + + return; function checkBaseLines(isSymbolBaseLine: boolean) { let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a73b91cc57a..6af77e3d746 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -957,8 +957,12 @@ module Harness { if (typeof setting.value === 'string') { if (setting.value.toLowerCase() === 'amd') { options.module = ts.ModuleKind.AMD; + } else if (setting.value.toLowerCase() === 'umd') { + options.module = ts.ModuleKind.UMD; } else if (setting.value.toLowerCase() === 'commonjs') { options.module = ts.ModuleKind.CommonJS; + } else if (setting.value.toLowerCase() === 'system') { + options.module = ts.ModuleKind.System; } else if (setting.value.toLowerCase() === 'unspecified') { options.module = ts.ModuleKind.None; } else { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index bce4c9828fa..e7c60e4d862 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -186,6 +186,7 @@ module Harness.LanguageService { var script = this.getScriptInfo(fileName); return script ? script.version.toString() : undefined; } + log(s: string): void { } trace(s: string): void { } error(s: string): void { } @@ -203,7 +204,7 @@ module Harness.LanguageService { } /// Shim adapter - class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost { + class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); @@ -227,6 +228,11 @@ module Harness.LanguageService { } getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); } getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } + + readDirectory(rootDir: string, extension: string): string { + throw new Error("NYI"); + } + log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 3291128a7a5..af7d0383202 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -18,6 +18,7 @@ interface ProjectRunnerTestCase { runTest?: boolean; // Run the resulting test bug?: string; // If there is any bug associated with this test case noResolve?: boolean; + rootDir?: string; // --rootDir } interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase { @@ -160,7 +161,8 @@ class ProjectRunner extends RunnerBase { mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot, sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, module: moduleKind, - noResolve: testCase.noResolve + noResolve: testCase.noResolve, + rootDir: testCase.rootDir }; } @@ -326,7 +328,9 @@ class ProjectRunner extends RunnerBase { return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics); } - describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => { + var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName; + + describe(name, () => { function verifyCompilerResults(compilerResult: BatchCompileProjectTestCaseResult) { function getCompilerResolutionInfo() { var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = { @@ -344,6 +348,7 @@ class ProjectRunner extends RunnerBase { baselineCheck: testCase.baselineCheck, runTest: testCase.runTest, bug: testCase.bug, + rootDir: testCase.rootDir, resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName), emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName) }; @@ -402,51 +407,67 @@ class ProjectRunner extends RunnerBase { } } - // Compile using node - var nodeCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.CommonJS); - verifyCompilerResults(nodeCompilerResult); + var nodeCompilerResult: BatchCompileProjectTestCaseResult; + var amdCompilerResult: BatchCompileProjectTestCaseResult; - // Compile using amd - var amdCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.AMD); - verifyCompilerResults(amdCompilerResult); + it(name + ": node", () => { + // Compile using node + nodeCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.CommonJS); + verifyCompilerResults(nodeCompilerResult); + }); + + + it(name + ": amd", () => { + // Compile using amd + amdCompilerResult = batchCompilerProjectTestCase(ts.ModuleKind.AMD); + verifyCompilerResults(amdCompilerResult); + }); if (testCase.runTest) { - //TODO(ryanca/danquirk): Either support this or remove this option from the interface as well as test case json files - // Node results - assert.isTrue(!nodeCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); - //it("runs without error: (" + moduleNameToString(nodeCompilerResult.moduleKind) + ')', function (done: any) { - // Exec.exec("node.exe", ['"' + baseLineLocalPath(nodeCompilerResult.outputFiles[0].diskRelativeName, nodeCompilerResult.moduleKind) + '"'], function (res) { - // Harness.Assert.equal(res.stdout, ""); - // Harness.Assert.equal(res.stderr, ""); - // done(); - // }) - //}); + it(name + ": runTest", () => { + if (!nodeCompilerResult || !amdCompilerResult) { + return; + } + //TODO(ryanca/danquirk): Either support this or remove this option from the interface as well as test case json files + // Node results + assert.isTrue(!nodeCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); + //it("runs without error: (" + moduleNameToString(nodeCompilerResult.moduleKind) + ')', function (done: any) { + // Exec.exec("node.exe", ['"' + baseLineLocalPath(nodeCompilerResult.outputFiles[0].diskRelativeName, nodeCompilerResult.moduleKind) + '"'], function (res) { + // Harness.Assert.equal(res.stdout, ""); + // Harness.Assert.equal(res.stderr, ""); + // done(); + // }) + //}); - // Amd results - assert.isTrue(!amdCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); - //var amdDriverTemplate = "var requirejs = require('../r.js');\n\n" + - // "requirejs.config({\n" + - // " nodeRequire: require\n" + - // "});\n\n" + - // "requirejs(['{0}'],\n" + - // "function ({0}) {\n" + - // "});"; - //var moduleName = baseLineLocalPath(amdCompilerResult.outputFiles[0].diskRelativeName, amdCompilerResult.moduleKind).replace(/\.js$/, ""); - //sys.writeFile(testCase.projectRoot + '/driver.js', amdDriverTemplate.replace(/\{0}/g, moduleName)); - //it("runs without error (" + moduleNameToString(amdCompilerResult.moduleKind) + ')', function (done: any) { - // Exec.exec("node.exe", ['"' + testCase.projectRoot + '/driver.js"'], function (res) { - // Harness.Assert.equal(res.stdout, ""); - // Harness.Assert.equal(res.stderr, ""); - // done(); - // }) - //}); + // Amd results + assert.isTrue(!amdCompilerResult.nonSubfolderDiskFiles, "Cant run test case that generates parent folders/absolute path"); + //var amdDriverTemplate = "var requirejs = require('../r.js');\n\n" + + // "requirejs.config({\n" + + // " nodeRequire: require\n" + + // "});\n\n" + + // "requirejs(['{0}'],\n" + + // "function ({0}) {\n" + + // "});"; + //var moduleName = baseLineLocalPath(amdCompilerResult.outputFiles[0].diskRelativeName, amdCompilerResult.moduleKind).replace(/\.js$/, ""); + //sys.writeFile(testCase.projectRoot + '/driver.js', amdDriverTemplate.replace(/\{0}/g, moduleName)); + //it("runs without error (" + moduleNameToString(amdCompilerResult.moduleKind) + ')', function (done: any) { + // Exec.exec("node.exe", ['"' + testCase.projectRoot + '/driver.js"'], function (res) { + // Harness.Assert.equal(res.stdout, ""); + // Harness.Assert.equal(res.stderr, ""); + // done(); + // }) + //}); + }); + + after(() => { + nodeCompilerResult = undefined; + amdCompilerResult = undefined; + }); } after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. - nodeCompilerResult = undefined; - amdCompilerResult = undefined; testCase = undefined; testFileText = undefined; testCaseJustName = undefined; diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 822b7ca5202..c03ab344ab2 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -546,7 +546,7 @@ interface Math { */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point (y,x). + * Returns the angle (in radians) from the X axis to a point. * @param y A numeric expression representing the cartesian y-coordinate. * @param x A numeric expression representing the cartesian x-coordinate. */ diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index b81a3341a6c..71778ecf907 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -442,7 +442,7 @@ interface IteratorResult { } interface Iterator { - next(): IteratorResult; + next(value?: any): IteratorResult; return?(value?: any): IteratorResult; throw?(e?: any): IteratorResult; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 8b4ab2cffa8..9ed31c91968 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -910,7 +910,7 @@ module ts.server { return { errorMsg: "tsconfig syntax error" }; } else { - var parsedCommandLine = ts.parseConfigFile(rawConfig, dirPath); + var parsedCommandLine = ts.parseConfigFile(rawConfig, ts.sys, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { errorMsg: "tsconfig option errors" }; } diff --git a/src/server/session.ts b/src/server/session.ts index faedce0e1af..52d33234636 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -527,6 +527,9 @@ module ts.server { if (lineText.charAt(i) == " ") { indentPosition--; } + else if (lineText.charAt(i) == "\t") { + indentPosition -= editorOptions.IndentSize; + } else { break; } diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index caed0582c33..19235269f22 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -401,8 +401,8 @@ module ts.BreakpointResolver { if (forStatement.condition) { return textSpan(forStatement.condition); } - if (forStatement.iterator) { - return textSpan(forStatement.iterator); + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); } } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 73b586e3706..23c835eaec2 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -458,7 +458,11 @@ module ts.formatting { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: return true; - + + // equals in binding elements: function foo([[x, y] = [1, 2]]) + case SyntaxKind.BindingElement: + // equals in type X = ... + case SyntaxKind.TypeAliasDeclaration: // equal in import a = module('a'); case SyntaxKind.ImportEqualsDeclaration: // equal in let a = 0; @@ -475,8 +479,6 @@ module ts.formatting { // Technically, "of" is not a binary operator, but format it the same way as "in" case SyntaxKind.ForOfStatement: return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword; - case SyntaxKind.BindingElement: - return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken; } return false; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 110090daf5c..993627619cb 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -57,6 +57,12 @@ module ts { getNewLine?(): string; } + /** Public interface of the the of a config service shim instance.*/ + export interface CoreServicesShimHost extends Logger { + /** Returns a JSON-encoded value of the type: string[] */ + readDirectory(rootDir: string, extension: string): string; + } + /// /// Pre-processing /// @@ -77,7 +83,7 @@ module ts { export interface Shim { dispose(dummy: any): void; } - + export interface LanguageServiceShim extends Shim { languageService: LanguageService; @@ -188,6 +194,7 @@ module ts { export interface CoreServicesShim extends Shim { getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; + getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; } @@ -302,6 +309,17 @@ module ts { } } } + + export class CoreServicesShimHostAdapter implements ParseConfigHost { + + constructor(private shimHost: CoreServicesShimHost) { + } + + public readDirectory(rootDir: string, extension: string): string[] { + var encoded = this.shimHost.readDirectory(rootDir, extension); + return JSON.parse(encoded); + } + } function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any { logger.log(actionDescription); @@ -741,7 +759,8 @@ module ts { } class CoreServicesShimObject extends ShimBase implements CoreServicesShim { - constructor(factory: ShimFactory, public logger: Logger) { + + constructor(factory: ShimFactory, public logger: Logger, private host: CoreServicesShimHostAdapter) { super(factory); } @@ -779,6 +798,32 @@ module ts { }); } + public getTSConfigFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { + return this.forwardJSONCall( + "getTSConfigFileInfo('" + fileName + "')", + () => { + let text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + + let result = parseConfigFileText(fileName, text); + + if (result.error) { + return { + options: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + + var configFile = parseConfigFile(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); + + return { + options: configFile.options, + files: configFile.fileNames, + errors: realizeDiagnostics(configFile.errors, '\r\n') + }; + }); + } + public getDefaultCompilationSettings(): string { return this.forwardJSONCall( "getDefaultCompilationSettings()", @@ -821,12 +866,13 @@ module ts { } } - public createCoreServicesShim(logger: Logger): CoreServicesShim { + public createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim { try { - return new CoreServicesShimObject(this, logger); + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); } catch (err) { - logInternalError(logger, err); + logInternalError(host, err); throw err; } } diff --git a/tests/baselines/reference/1.0lib-noErrors.js b/tests/baselines/reference/1.0lib-noErrors.js new file mode 100644 index 00000000000..1dcfa9743b2 --- /dev/null +++ b/tests/baselines/reference/1.0lib-noErrors.js @@ -0,0 +1,1160 @@ +//// [1.0lib-noErrors.ts] +/* ***************************************************************************** +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. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * 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. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get?(): any; + set?(v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +interface Object { + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; + + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): 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. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * 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, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods 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. + */ + keys(o: any): string[]; +} + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +declare var Function: { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +interface Boolean { +} +declare var Boolean: { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; + /** Returns a date as a string value in ISO format. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +declare var Date: { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +interface RegExpExecArray { + [index: number]: string; + length: number; + + index: number; + input: string; + + toString(): string; + toLocaleString(): string; + concat(...items: string[][]): string[]; + join(separator?: string): string; + pop(): string; + push(...items: string[]): number; + reverse(): string[]; + shift(): string; + slice(start?: number, end?: number): string[]; + sort(compareFn?: (a: string, b: string) => number): string[]; + splice(start: number): string[]; + splice(start: number, deleteCount: number, ...items: string[]): string[]; + unshift(...items: string[]): number; + + indexOf(searchElement: string, fromIndex?: number): number; + lastIndexOf(searchElement: string, fromIndex?: number): number; + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +} + + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} +declare var RegExp: { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +interface Error { + name: string; + message: string; +} +declare var Error: { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +interface EvalError extends Error { +} +declare var EvalError: { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +interface RangeError extends Error { +} +declare var RangeError: { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +interface ReferenceError extends Error { +} +declare var ReferenceError: { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +interface SyntaxError extends Error { +} +declare var SyntaxError: { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +interface TypeError extends Error { +} +declare var TypeError: { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +interface URIError extends Error { +} +declare var URIError: { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @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. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @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. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @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: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + + [n: number]: T; +} +declare var Array: { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + +//// [1.0lib-noErrors.js] +/* ***************************************************************************** +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. +***************************************************************************** */ diff --git a/tests/baselines/reference/1.0lib-noErrors.symbols b/tests/baselines/reference/1.0lib-noErrors.symbols new file mode 100644 index 00000000000..789018598d1 --- /dev/null +++ b/tests/baselines/reference/1.0lib-noErrors.symbols @@ -0,0 +1,2086 @@ +=== tests/cases/conformance/decorators/1.0lib-noErrors.ts === +/* ***************************************************************************** +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. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +>NaN : Symbol(NaN, Decl(1.0lib-noErrors.ts, 21, 11)) + +declare var Infinity: number; +>Infinity : Symbol(Infinity, Decl(1.0lib-noErrors.ts, 22, 11)) + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; +>eval : Symbol(eval, Decl(1.0lib-noErrors.ts, 22, 29)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 28, 22)) + +/** + * 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. + */ +declare function parseInt(s: string, radix?: number): number; +>parseInt : Symbol(parseInt, Decl(1.0lib-noErrors.ts, 28, 38)) +>s : Symbol(s, Decl(1.0lib-noErrors.ts, 37, 26)) +>radix : Symbol(radix, Decl(1.0lib-noErrors.ts, 37, 36)) + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; +>parseFloat : Symbol(parseFloat, Decl(1.0lib-noErrors.ts, 37, 61)) +>string : Symbol(string, Decl(1.0lib-noErrors.ts, 43, 28)) + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; +>isNaN : Symbol(isNaN, Decl(1.0lib-noErrors.ts, 43, 52)) +>number : Symbol(number, Decl(1.0lib-noErrors.ts, 49, 23)) + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; +>isFinite : Symbol(isFinite, Decl(1.0lib-noErrors.ts, 49, 48)) +>number : Symbol(number, Decl(1.0lib-noErrors.ts, 55, 26)) + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; +>decodeURI : Symbol(decodeURI, Decl(1.0lib-noErrors.ts, 55, 51)) +>encodedURI : Symbol(encodedURI, Decl(1.0lib-noErrors.ts, 61, 27)) + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; +>decodeURIComponent : Symbol(decodeURIComponent, Decl(1.0lib-noErrors.ts, 61, 55)) +>encodedURIComponent : Symbol(encodedURIComponent, Decl(1.0lib-noErrors.ts, 67, 36)) + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; +>encodeURI : Symbol(encodeURI, Decl(1.0lib-noErrors.ts, 67, 73)) +>uri : Symbol(uri, Decl(1.0lib-noErrors.ts, 73, 27)) + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; +>encodeURIComponent : Symbol(encodeURIComponent, Decl(1.0lib-noErrors.ts, 73, 48)) +>uriComponent : Symbol(uriComponent, Decl(1.0lib-noErrors.ts, 79, 36)) + +interface PropertyDescriptor { +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) + + configurable?: boolean; +>configurable : Symbol(configurable, Decl(1.0lib-noErrors.ts, 81, 30)) + + enumerable?: boolean; +>enumerable : Symbol(enumerable, Decl(1.0lib-noErrors.ts, 82, 27)) + + value?: any; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 83, 25)) + + writable?: boolean; +>writable : Symbol(writable, Decl(1.0lib-noErrors.ts, 84, 16)) + + get?(): any; +>get : Symbol(get, Decl(1.0lib-noErrors.ts, 85, 23)) + + set?(v: any): void; +>set : Symbol(set, Decl(1.0lib-noErrors.ts, 86, 16)) +>v : Symbol(v, Decl(1.0lib-noErrors.ts, 87, 9)) +} + +interface PropertyDescriptorMap { +>PropertyDescriptorMap : Symbol(PropertyDescriptorMap, Decl(1.0lib-noErrors.ts, 88, 1)) + + [s: string]: PropertyDescriptor; +>s : Symbol(s, Decl(1.0lib-noErrors.ts, 91, 5)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) +} + +interface Object { +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; +>constructor : Symbol(constructor, Decl(1.0lib-noErrors.ts, 94, 18)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) + + /** Returns a string representation of an object. */ + toString(): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 96, 26)) + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; +>toLocaleString : Symbol(toLocaleString, Decl(1.0lib-noErrors.ts, 99, 23)) + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; +>valueOf : Symbol(valueOf, Decl(1.0lib-noErrors.ts, 102, 29)) +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; +>hasOwnProperty : Symbol(hasOwnProperty, Decl(1.0lib-noErrors.ts, 105, 22)) +>v : Symbol(v, Decl(1.0lib-noErrors.ts, 111, 19)) + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; +>isPrototypeOf : Symbol(isPrototypeOf, Decl(1.0lib-noErrors.ts, 111, 39)) +>v : Symbol(v, Decl(1.0lib-noErrors.ts, 117, 18)) +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +>propertyIsEnumerable : Symbol(propertyIsEnumerable, Decl(1.0lib-noErrors.ts, 117, 38)) +>v : Symbol(v, Decl(1.0lib-noErrors.ts, 123, 25)) +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + new (value?: any): Object; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 130, 9)) +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + (): any; + (value: any): any; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 132, 5)) + + /** A reference to the prototype for a class of objects. */ + prototype: Object; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 132, 22)) +>Object : Symbol(Object, Decl(1.0lib-noErrors.ts, 92, 1), Decl(1.0lib-noErrors.ts, 129, 11)) + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; +>getPrototypeOf : Symbol(getPrototypeOf, Decl(1.0lib-noErrors.ts, 135, 22)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 141, 19)) + + /** + * 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, p: string): PropertyDescriptor; +>getOwnPropertyDescriptor : Symbol(getOwnPropertyDescriptor, Decl(1.0lib-noErrors.ts, 141, 32)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 149, 29)) +>p : Symbol(p, Decl(1.0lib-noErrors.ts, 149, 36)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; +>getOwnPropertyNames : Symbol(getOwnPropertyNames, Decl(1.0lib-noErrors.ts, 149, 68)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 156, 24)) + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; +>create : Symbol(create, Decl(1.0lib-noErrors.ts, 156, 42)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 163, 11)) +>properties : Symbol(properties, Decl(1.0lib-noErrors.ts, 163, 18)) +>PropertyDescriptorMap : Symbol(PropertyDescriptorMap, Decl(1.0lib-noErrors.ts, 88, 1)) + + /** + * 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, p: string, attributes: PropertyDescriptor): any; +>defineProperty : Symbol(defineProperty, Decl(1.0lib-noErrors.ts, 163, 60)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 171, 19)) +>p : Symbol(p, Decl(1.0lib-noErrors.ts, 171, 26)) +>attributes : Symbol(attributes, Decl(1.0lib-noErrors.ts, 171, 37)) +>PropertyDescriptor : Symbol(PropertyDescriptor, Decl(1.0lib-noErrors.ts, 79, 66)) + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; +>defineProperties : Symbol(defineProperties, Decl(1.0lib-noErrors.ts, 171, 75)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 178, 21)) +>properties : Symbol(properties, Decl(1.0lib-noErrors.ts, 178, 28)) +>PropertyDescriptorMap : Symbol(PropertyDescriptorMap, Decl(1.0lib-noErrors.ts, 88, 1)) + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; +>seal : Symbol(seal, Decl(1.0lib-noErrors.ts, 178, 69)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 184, 9)) + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; +>freeze : Symbol(freeze, Decl(1.0lib-noErrors.ts, 184, 22)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 190, 11)) + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; +>preventExtensions : Symbol(preventExtensions, Decl(1.0lib-noErrors.ts, 190, 24)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 196, 22)) + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; +>isSealed : Symbol(isSealed, Decl(1.0lib-noErrors.ts, 196, 35)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 202, 13)) + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; +>isFrozen : Symbol(isFrozen, Decl(1.0lib-noErrors.ts, 202, 30)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 208, 13)) + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; +>isExtensible : Symbol(isExtensible, Decl(1.0lib-noErrors.ts, 208, 30)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 214, 17)) + + /** + * Returns the names of the enumerable properties and methods 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. + */ + keys(o: any): string[]; +>keys : Symbol(keys, Decl(1.0lib-noErrors.ts, 214, 34)) +>o : Symbol(o, Decl(1.0lib-noErrors.ts, 220, 9)) +} + +/** + * Creates a new function. + */ +interface Function { +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) + + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; +>apply : Symbol(apply, Decl(1.0lib-noErrors.ts, 226, 20)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 232, 10)) +>argArray : Symbol(argArray, Decl(1.0lib-noErrors.ts, 232, 23)) + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; +>call : Symbol(call, Decl(1.0lib-noErrors.ts, 232, 45)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 239, 9)) +>argArray : Symbol(argArray, Decl(1.0lib-noErrors.ts, 239, 22)) + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; +>bind : Symbol(bind, Decl(1.0lib-noErrors.ts, 239, 48)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 247, 9)) +>argArray : Symbol(argArray, Decl(1.0lib-noErrors.ts, 247, 22)) + + prototype: any; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 247, 48)) + + length: number; +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 249, 19)) + + // Non-standard extensions + arguments: any; +>arguments : Symbol(arguments, Decl(1.0lib-noErrors.ts, 250, 19)) + + caller: Function; +>caller : Symbol(caller, Decl(1.0lib-noErrors.ts, 253, 19)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) +} + +declare var Function: { +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) + + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; +>args : Symbol(args, Decl(1.0lib-noErrors.ts, 262, 9)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) + + (...args: string[]): Function; +>args : Symbol(args, Decl(1.0lib-noErrors.ts, 263, 5)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) + + prototype: Function; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 263, 34)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) +} + +interface IArguments { +>IArguments : Symbol(IArguments, Decl(1.0lib-noErrors.ts, 265, 1)) + + [index: number]: any; +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 268, 5)) + + length: number; +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 268, 25)) + + callee: Function; +>callee : Symbol(callee, Decl(1.0lib-noErrors.ts, 269, 19)) +>Function : Symbol(Function, Decl(1.0lib-noErrors.ts, 221, 1), Decl(1.0lib-noErrors.ts, 257, 11)) +} + +interface String { +>String : Symbol(String, Decl(1.0lib-noErrors.ts, 271, 1), Decl(1.0lib-noErrors.ts, 429, 11)) + + /** Returns a string representation of a string. */ + toString(): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 273, 18)) + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; +>charAt : Symbol(charAt, Decl(1.0lib-noErrors.ts, 275, 23)) +>pos : Symbol(pos, Decl(1.0lib-noErrors.ts, 281, 11)) + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; +>charCodeAt : Symbol(charCodeAt, Decl(1.0lib-noErrors.ts, 281, 32)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 287, 15)) + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; +>concat : Symbol(concat, Decl(1.0lib-noErrors.ts, 287, 38)) +>strings : Symbol(strings, Decl(1.0lib-noErrors.ts, 293, 11)) + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; +>indexOf : Symbol(indexOf, Decl(1.0lib-noErrors.ts, 293, 41)) +>searchString : Symbol(searchString, Decl(1.0lib-noErrors.ts, 300, 12)) +>position : Symbol(position, Decl(1.0lib-noErrors.ts, 300, 33)) + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; +>lastIndexOf : Symbol(lastIndexOf, Decl(1.0lib-noErrors.ts, 300, 61)) +>searchString : Symbol(searchString, Decl(1.0lib-noErrors.ts, 307, 16)) +>position : Symbol(position, Decl(1.0lib-noErrors.ts, 307, 37)) + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; +>localeCompare : Symbol(localeCompare, Decl(1.0lib-noErrors.ts, 307, 65)) +>that : Symbol(that, Decl(1.0lib-noErrors.ts, 313, 18)) + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; +>match : Symbol(match, Decl(1.0lib-noErrors.ts, 313, 40), Decl(1.0lib-noErrors.ts, 319, 36)) +>regexp : Symbol(regexp, Decl(1.0lib-noErrors.ts, 319, 10)) + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; +>match : Symbol(match, Decl(1.0lib-noErrors.ts, 313, 40), Decl(1.0lib-noErrors.ts, 319, 36)) +>regexp : Symbol(regexp, Decl(1.0lib-noErrors.ts, 325, 10)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; +>replace : Symbol(replace, Decl(1.0lib-noErrors.ts, 325, 36), Decl(1.0lib-noErrors.ts, 332, 63), Decl(1.0lib-noErrors.ts, 339, 102), Decl(1.0lib-noErrors.ts, 346, 63)) +>searchValue : Symbol(searchValue, Decl(1.0lib-noErrors.ts, 332, 12)) +>replaceValue : Symbol(replaceValue, Decl(1.0lib-noErrors.ts, 332, 32)) + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : Symbol(replace, Decl(1.0lib-noErrors.ts, 325, 36), Decl(1.0lib-noErrors.ts, 332, 63), Decl(1.0lib-noErrors.ts, 339, 102), Decl(1.0lib-noErrors.ts, 346, 63)) +>searchValue : Symbol(searchValue, Decl(1.0lib-noErrors.ts, 339, 12)) +>replaceValue : Symbol(replaceValue, Decl(1.0lib-noErrors.ts, 339, 32)) +>substring : Symbol(substring, Decl(1.0lib-noErrors.ts, 339, 48)) +>args : Symbol(args, Decl(1.0lib-noErrors.ts, 339, 66)) + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; +>replace : Symbol(replace, Decl(1.0lib-noErrors.ts, 325, 36), Decl(1.0lib-noErrors.ts, 332, 63), Decl(1.0lib-noErrors.ts, 339, 102), Decl(1.0lib-noErrors.ts, 346, 63)) +>searchValue : Symbol(searchValue, Decl(1.0lib-noErrors.ts, 346, 12)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) +>replaceValue : Symbol(replaceValue, Decl(1.0lib-noErrors.ts, 346, 32)) + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : Symbol(replace, Decl(1.0lib-noErrors.ts, 325, 36), Decl(1.0lib-noErrors.ts, 332, 63), Decl(1.0lib-noErrors.ts, 339, 102), Decl(1.0lib-noErrors.ts, 346, 63)) +>searchValue : Symbol(searchValue, Decl(1.0lib-noErrors.ts, 353, 12)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) +>replaceValue : Symbol(replaceValue, Decl(1.0lib-noErrors.ts, 353, 32)) +>substring : Symbol(substring, Decl(1.0lib-noErrors.ts, 353, 48)) +>args : Symbol(args, Decl(1.0lib-noErrors.ts, 353, 66)) + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; +>search : Symbol(search, Decl(1.0lib-noErrors.ts, 353, 102), Decl(1.0lib-noErrors.ts, 359, 35)) +>regexp : Symbol(regexp, Decl(1.0lib-noErrors.ts, 359, 11)) + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; +>search : Symbol(search, Decl(1.0lib-noErrors.ts, 353, 102), Decl(1.0lib-noErrors.ts, 359, 35)) +>regexp : Symbol(regexp, Decl(1.0lib-noErrors.ts, 365, 11)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; +>slice : Symbol(slice, Decl(1.0lib-noErrors.ts, 365, 35)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 373, 10)) +>end : Symbol(end, Decl(1.0lib-noErrors.ts, 373, 25)) + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; +>split : Symbol(split, Decl(1.0lib-noErrors.ts, 373, 48), Decl(1.0lib-noErrors.ts, 380, 55)) +>separator : Symbol(separator, Decl(1.0lib-noErrors.ts, 380, 10)) +>limit : Symbol(limit, Decl(1.0lib-noErrors.ts, 380, 28)) + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; +>split : Symbol(split, Decl(1.0lib-noErrors.ts, 373, 48), Decl(1.0lib-noErrors.ts, 380, 55)) +>separator : Symbol(separator, Decl(1.0lib-noErrors.ts, 387, 10)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) +>limit : Symbol(limit, Decl(1.0lib-noErrors.ts, 387, 28)) + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; +>substring : Symbol(substring, Decl(1.0lib-noErrors.ts, 387, 55)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 395, 14)) +>end : Symbol(end, Decl(1.0lib-noErrors.ts, 395, 28)) + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; +>toLowerCase : Symbol(toLowerCase, Decl(1.0lib-noErrors.ts, 395, 51)) + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; +>toLocaleLowerCase : Symbol(toLocaleLowerCase, Decl(1.0lib-noErrors.ts, 398, 26)) + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; +>toUpperCase : Symbol(toUpperCase, Decl(1.0lib-noErrors.ts, 401, 32)) + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; +>toLocaleUpperCase : Symbol(toLocaleUpperCase, Decl(1.0lib-noErrors.ts, 404, 26)) + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; +>trim : Symbol(trim, Decl(1.0lib-noErrors.ts, 407, 32)) + + /** Returns the length of a String object. */ + length: number; +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 410, 19)) + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; +>substr : Symbol(substr, Decl(1.0lib-noErrors.ts, 413, 19)) +>from : Symbol(from, Decl(1.0lib-noErrors.ts, 421, 11)) +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 421, 24)) + + [index: number]: string; +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 423, 5)) +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { +>String : Symbol(String, Decl(1.0lib-noErrors.ts, 271, 1), Decl(1.0lib-noErrors.ts, 429, 11)) + + new (value?: any): String; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 430, 9)) +>String : Symbol(String, Decl(1.0lib-noErrors.ts, 271, 1), Decl(1.0lib-noErrors.ts, 429, 11)) + + (value?: any): string; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 431, 5)) + + prototype: String; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 431, 26)) +>String : Symbol(String, Decl(1.0lib-noErrors.ts, 271, 1), Decl(1.0lib-noErrors.ts, 429, 11)) + + fromCharCode(...codes: number[]): string; +>fromCharCode : Symbol(fromCharCode, Decl(1.0lib-noErrors.ts, 432, 22)) +>codes : Symbol(codes, Decl(1.0lib-noErrors.ts, 433, 17)) +} + +interface Boolean { +>Boolean : Symbol(Boolean, Decl(1.0lib-noErrors.ts, 434, 1), Decl(1.0lib-noErrors.ts, 438, 11)) +} +declare var Boolean: { +>Boolean : Symbol(Boolean, Decl(1.0lib-noErrors.ts, 434, 1), Decl(1.0lib-noErrors.ts, 438, 11)) + + new (value?: any): Boolean; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 439, 9)) +>Boolean : Symbol(Boolean, Decl(1.0lib-noErrors.ts, 434, 1), Decl(1.0lib-noErrors.ts, 438, 11)) + + (value?: any): boolean; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 440, 5)) + + prototype: Boolean; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 440, 27)) +>Boolean : Symbol(Boolean, Decl(1.0lib-noErrors.ts, 434, 1), Decl(1.0lib-noErrors.ts, 438, 11)) +} + +interface Number { +>Number : Symbol(Number, Decl(1.0lib-noErrors.ts, 442, 1), Decl(1.0lib-noErrors.ts, 471, 11)) + + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 444, 18)) +>radix : Symbol(radix, Decl(1.0lib-noErrors.ts, 449, 13)) + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; +>toFixed : Symbol(toFixed, Decl(1.0lib-noErrors.ts, 449, 37)) +>fractionDigits : Symbol(fractionDigits, Decl(1.0lib-noErrors.ts, 455, 12)) + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; +>toExponential : Symbol(toExponential, Decl(1.0lib-noErrors.ts, 455, 45)) +>fractionDigits : Symbol(fractionDigits, Decl(1.0lib-noErrors.ts, 461, 18)) + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +>toPrecision : Symbol(toPrecision, Decl(1.0lib-noErrors.ts, 461, 51)) +>precision : Symbol(precision, Decl(1.0lib-noErrors.ts, 467, 16)) +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { +>Number : Symbol(Number, Decl(1.0lib-noErrors.ts, 442, 1), Decl(1.0lib-noErrors.ts, 471, 11)) + + new (value?: any): Number; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 472, 9)) +>Number : Symbol(Number, Decl(1.0lib-noErrors.ts, 442, 1), Decl(1.0lib-noErrors.ts, 471, 11)) + + (value?: any): number; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 473, 5)) + + prototype: Number; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 473, 26)) +>Number : Symbol(Number, Decl(1.0lib-noErrors.ts, 442, 1), Decl(1.0lib-noErrors.ts, 471, 11)) + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; +>MAX_VALUE : Symbol(MAX_VALUE, Decl(1.0lib-noErrors.ts, 474, 22)) + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; +>MIN_VALUE : Symbol(MIN_VALUE, Decl(1.0lib-noErrors.ts, 477, 22)) + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; +>NaN : Symbol(NaN, Decl(1.0lib-noErrors.ts, 480, 22)) + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; +>NEGATIVE_INFINITY : Symbol(NEGATIVE_INFINITY, Decl(1.0lib-noErrors.ts, 486, 16)) + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +>POSITIVE_INFINITY : Symbol(POSITIVE_INFINITY, Decl(1.0lib-noErrors.ts, 492, 30)) +} + +interface Math { +>Math : Symbol(Math, Decl(1.0lib-noErrors.ts, 499, 1), Decl(1.0lib-noErrors.ts, 610, 11)) + + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; +>E : Symbol(E, Decl(1.0lib-noErrors.ts, 501, 16)) + + /** The natural logarithm of 10. */ + LN10: number; +>LN10 : Symbol(LN10, Decl(1.0lib-noErrors.ts, 503, 14)) + + /** The natural logarithm of 2. */ + LN2: number; +>LN2 : Symbol(LN2, Decl(1.0lib-noErrors.ts, 505, 17)) + + /** The base-2 logarithm of e. */ + LOG2E: number; +>LOG2E : Symbol(LOG2E, Decl(1.0lib-noErrors.ts, 507, 16)) + + /** The base-10 logarithm of e. */ + LOG10E: number; +>LOG10E : Symbol(LOG10E, Decl(1.0lib-noErrors.ts, 509, 18)) + + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; +>PI : Symbol(PI, Decl(1.0lib-noErrors.ts, 511, 19)) + + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; +>SQRT1_2 : Symbol(SQRT1_2, Decl(1.0lib-noErrors.ts, 513, 15)) + + /** The square root of 2. */ + SQRT2: number; +>SQRT2 : Symbol(SQRT2, Decl(1.0lib-noErrors.ts, 515, 20)) + + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; +>abs : Symbol(abs, Decl(1.0lib-noErrors.ts, 517, 18)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 523, 8)) + + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; +>acos : Symbol(acos, Decl(1.0lib-noErrors.ts, 523, 27)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 528, 9)) + + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; +>asin : Symbol(asin, Decl(1.0lib-noErrors.ts, 528, 28)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 533, 9)) + + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; +>atan : Symbol(atan, Decl(1.0lib-noErrors.ts, 533, 28)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 538, 9)) + + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; +>atan2 : Symbol(atan2, Decl(1.0lib-noErrors.ts, 538, 28)) +>y : Symbol(y, Decl(1.0lib-noErrors.ts, 544, 10)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 544, 20)) + + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; +>ceil : Symbol(ceil, Decl(1.0lib-noErrors.ts, 544, 40)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 549, 9)) + + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; +>cos : Symbol(cos, Decl(1.0lib-noErrors.ts, 549, 28)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 554, 8)) + + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; +>exp : Symbol(exp, Decl(1.0lib-noErrors.ts, 554, 27)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 559, 8)) + + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; +>floor : Symbol(floor, Decl(1.0lib-noErrors.ts, 559, 27)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 564, 10)) + + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; +>log : Symbol(log, Decl(1.0lib-noErrors.ts, 564, 29)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 569, 8)) + + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; +>max : Symbol(max, Decl(1.0lib-noErrors.ts, 569, 27)) +>values : Symbol(values, Decl(1.0lib-noErrors.ts, 574, 8)) + + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; +>min : Symbol(min, Decl(1.0lib-noErrors.ts, 574, 37)) +>values : Symbol(values, Decl(1.0lib-noErrors.ts, 579, 8)) + + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; +>pow : Symbol(pow, Decl(1.0lib-noErrors.ts, 579, 37)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 585, 8)) +>y : Symbol(y, Decl(1.0lib-noErrors.ts, 585, 18)) + + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; +>random : Symbol(random, Decl(1.0lib-noErrors.ts, 585, 38)) + + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; +>round : Symbol(round, Decl(1.0lib-noErrors.ts, 587, 21)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 592, 10)) + + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; +>sin : Symbol(sin, Decl(1.0lib-noErrors.ts, 592, 29)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 597, 8)) + + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; +>sqrt : Symbol(sqrt, Decl(1.0lib-noErrors.ts, 597, 27)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 602, 9)) + + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +>tan : Symbol(tan, Decl(1.0lib-noErrors.ts, 602, 28)) +>x : Symbol(x, Decl(1.0lib-noErrors.ts, 607, 8)) +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; +>Math : Symbol(Math, Decl(1.0lib-noErrors.ts, 499, 1), Decl(1.0lib-noErrors.ts, 610, 11)) +>Math : Symbol(Math, Decl(1.0lib-noErrors.ts, 499, 1), Decl(1.0lib-noErrors.ts, 610, 11)) + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 613, 16)) + + /** Returns a date as a string value. */ + toDateString(): string; +>toDateString : Symbol(toDateString, Decl(1.0lib-noErrors.ts, 615, 23)) + + /** Returns a time as a string value. */ + toTimeString(): string; +>toTimeString : Symbol(toTimeString, Decl(1.0lib-noErrors.ts, 617, 27)) + + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; +>toLocaleString : Symbol(toLocaleString, Decl(1.0lib-noErrors.ts, 619, 27)) + + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; +>toLocaleDateString : Symbol(toLocaleDateString, Decl(1.0lib-noErrors.ts, 621, 29)) + + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; +>toLocaleTimeString : Symbol(toLocaleTimeString, Decl(1.0lib-noErrors.ts, 623, 33)) + + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; +>valueOf : Symbol(valueOf, Decl(1.0lib-noErrors.ts, 625, 33)) + + /** Gets the time value in milliseconds. */ + getTime(): number; +>getTime : Symbol(getTime, Decl(1.0lib-noErrors.ts, 627, 22)) + + /** Gets the year, using local time. */ + getFullYear(): number; +>getFullYear : Symbol(getFullYear, Decl(1.0lib-noErrors.ts, 629, 22)) + + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; +>getUTCFullYear : Symbol(getUTCFullYear, Decl(1.0lib-noErrors.ts, 631, 26)) + + /** Gets the month, using local time. */ + getMonth(): number; +>getMonth : Symbol(getMonth, Decl(1.0lib-noErrors.ts, 633, 29)) + + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; +>getUTCMonth : Symbol(getUTCMonth, Decl(1.0lib-noErrors.ts, 635, 23)) + + /** Gets the day-of-the-month, using local time. */ + getDate(): number; +>getDate : Symbol(getDate, Decl(1.0lib-noErrors.ts, 637, 26)) + + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; +>getUTCDate : Symbol(getUTCDate, Decl(1.0lib-noErrors.ts, 639, 22)) + + /** Gets the day of the week, using local time. */ + getDay(): number; +>getDay : Symbol(getDay, Decl(1.0lib-noErrors.ts, 641, 25)) + + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; +>getUTCDay : Symbol(getUTCDay, Decl(1.0lib-noErrors.ts, 643, 21)) + + /** Gets the hours in a date, using local time. */ + getHours(): number; +>getHours : Symbol(getHours, Decl(1.0lib-noErrors.ts, 645, 24)) + + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; +>getUTCHours : Symbol(getUTCHours, Decl(1.0lib-noErrors.ts, 647, 23)) + + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; +>getMinutes : Symbol(getMinutes, Decl(1.0lib-noErrors.ts, 649, 26)) + + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; +>getUTCMinutes : Symbol(getUTCMinutes, Decl(1.0lib-noErrors.ts, 651, 25)) + + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; +>getSeconds : Symbol(getSeconds, Decl(1.0lib-noErrors.ts, 653, 28)) + + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; +>getUTCSeconds : Symbol(getUTCSeconds, Decl(1.0lib-noErrors.ts, 655, 25)) + + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; +>getMilliseconds : Symbol(getMilliseconds, Decl(1.0lib-noErrors.ts, 657, 28)) + + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; +>getUTCMilliseconds : Symbol(getUTCMilliseconds, Decl(1.0lib-noErrors.ts, 659, 30)) + + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; +>getTimezoneOffset : Symbol(getTimezoneOffset, Decl(1.0lib-noErrors.ts, 661, 33)) + + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; +>setTime : Symbol(setTime, Decl(1.0lib-noErrors.ts, 663, 32)) +>time : Symbol(time, Decl(1.0lib-noErrors.ts, 668, 12)) + + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; +>setMilliseconds : Symbol(setMilliseconds, Decl(1.0lib-noErrors.ts, 668, 34)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 673, 20)) + + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; +>setUTCMilliseconds : Symbol(setUTCMilliseconds, Decl(1.0lib-noErrors.ts, 673, 40)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 678, 23)) + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; +>setSeconds : Symbol(setSeconds, Decl(1.0lib-noErrors.ts, 678, 43)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 685, 15)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 685, 27)) + + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; +>setUTCSeconds : Symbol(setUTCSeconds, Decl(1.0lib-noErrors.ts, 685, 49)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 691, 18)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 691, 30)) + + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; +>setMinutes : Symbol(setMinutes, Decl(1.0lib-noErrors.ts, 691, 52)) +>min : Symbol(min, Decl(1.0lib-noErrors.ts, 698, 15)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 698, 27)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 698, 41)) + + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; +>setUTCMinutes : Symbol(setUTCMinutes, Decl(1.0lib-noErrors.ts, 698, 63)) +>min : Symbol(min, Decl(1.0lib-noErrors.ts, 705, 18)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 705, 30)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 705, 44)) + + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; +>setHours : Symbol(setHours, Decl(1.0lib-noErrors.ts, 705, 66)) +>hours : Symbol(hours, Decl(1.0lib-noErrors.ts, 713, 13)) +>min : Symbol(min, Decl(1.0lib-noErrors.ts, 713, 27)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 713, 41)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 713, 55)) + + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; +>setUTCHours : Symbol(setUTCHours, Decl(1.0lib-noErrors.ts, 713, 77)) +>hours : Symbol(hours, Decl(1.0lib-noErrors.ts, 721, 16)) +>min : Symbol(min, Decl(1.0lib-noErrors.ts, 721, 30)) +>sec : Symbol(sec, Decl(1.0lib-noErrors.ts, 721, 44)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 721, 58)) + + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; +>setDate : Symbol(setDate, Decl(1.0lib-noErrors.ts, 721, 80)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 726, 12)) + + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; +>setUTCDate : Symbol(setUTCDate, Decl(1.0lib-noErrors.ts, 726, 34)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 731, 15)) + + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; +>setMonth : Symbol(setMonth, Decl(1.0lib-noErrors.ts, 731, 37)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 737, 13)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 737, 27)) + + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; +>setUTCMonth : Symbol(setUTCMonth, Decl(1.0lib-noErrors.ts, 737, 51)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 743, 16)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 743, 30)) + + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; +>setFullYear : Symbol(setFullYear, Decl(1.0lib-noErrors.ts, 743, 54)) +>year : Symbol(year, Decl(1.0lib-noErrors.ts, 750, 16)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 750, 29)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 750, 45)) + + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; +>setUTCFullYear : Symbol(setUTCFullYear, Decl(1.0lib-noErrors.ts, 750, 69)) +>year : Symbol(year, Decl(1.0lib-noErrors.ts, 757, 19)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 757, 32)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 757, 48)) + + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; +>toUTCString : Symbol(toUTCString, Decl(1.0lib-noErrors.ts, 757, 72)) + + /** Returns a date as a string value in ISO format. */ + toISOString(): string; +>toISOString : Symbol(toISOString, Decl(1.0lib-noErrors.ts, 759, 26)) + + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +>toJSON : Symbol(toJSON, Decl(1.0lib-noErrors.ts, 761, 26)) +>key : Symbol(key, Decl(1.0lib-noErrors.ts, 763, 11)) +} + +declare var Date: { +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + new (): Date; +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + new (value: number): Date; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 768, 9)) +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + new (value: string): Date; +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 769, 9)) +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; +>year : Symbol(year, Decl(1.0lib-noErrors.ts, 770, 9)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 770, 22)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 770, 37)) +>hours : Symbol(hours, Decl(1.0lib-noErrors.ts, 770, 52)) +>minutes : Symbol(minutes, Decl(1.0lib-noErrors.ts, 770, 68)) +>seconds : Symbol(seconds, Decl(1.0lib-noErrors.ts, 770, 86)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 770, 104)) +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + (): string; + prototype: Date; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 771, 15)) +>Date : Symbol(Date, Decl(1.0lib-noErrors.ts, 610, 23), Decl(1.0lib-noErrors.ts, 766, 11)) + + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; +>parse : Symbol(parse, Decl(1.0lib-noErrors.ts, 772, 20)) +>s : Symbol(s, Decl(1.0lib-noErrors.ts, 777, 10)) + + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; +>UTC : Symbol(UTC, Decl(1.0lib-noErrors.ts, 777, 29)) +>year : Symbol(year, Decl(1.0lib-noErrors.ts, 788, 8)) +>month : Symbol(month, Decl(1.0lib-noErrors.ts, 788, 21)) +>date : Symbol(date, Decl(1.0lib-noErrors.ts, 788, 36)) +>hours : Symbol(hours, Decl(1.0lib-noErrors.ts, 788, 51)) +>minutes : Symbol(minutes, Decl(1.0lib-noErrors.ts, 788, 67)) +>seconds : Symbol(seconds, Decl(1.0lib-noErrors.ts, 788, 85)) +>ms : Symbol(ms, Decl(1.0lib-noErrors.ts, 788, 103)) + + now(): number; +>now : Symbol(now, Decl(1.0lib-noErrors.ts, 788, 125)) +} + +interface RegExpExecArray { +>RegExpExecArray : Symbol(RegExpExecArray, Decl(1.0lib-noErrors.ts, 790, 1)) + + [index: number]: string; +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 793, 5)) + + length: number; +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 793, 28)) + + index: number; +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 794, 19)) + + input: string; +>input : Symbol(input, Decl(1.0lib-noErrors.ts, 796, 18)) + + toString(): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 797, 18)) + + toLocaleString(): string; +>toLocaleString : Symbol(toLocaleString, Decl(1.0lib-noErrors.ts, 799, 23)) + + concat(...items: string[][]): string[]; +>concat : Symbol(concat, Decl(1.0lib-noErrors.ts, 800, 29)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 801, 11)) + + join(separator?: string): string; +>join : Symbol(join, Decl(1.0lib-noErrors.ts, 801, 43)) +>separator : Symbol(separator, Decl(1.0lib-noErrors.ts, 802, 9)) + + pop(): string; +>pop : Symbol(pop, Decl(1.0lib-noErrors.ts, 802, 37)) + + push(...items: string[]): number; +>push : Symbol(push, Decl(1.0lib-noErrors.ts, 803, 18)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 804, 9)) + + reverse(): string[]; +>reverse : Symbol(reverse, Decl(1.0lib-noErrors.ts, 804, 37)) + + shift(): string; +>shift : Symbol(shift, Decl(1.0lib-noErrors.ts, 805, 24)) + + slice(start?: number, end?: number): string[]; +>slice : Symbol(slice, Decl(1.0lib-noErrors.ts, 806, 20)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 807, 10)) +>end : Symbol(end, Decl(1.0lib-noErrors.ts, 807, 25)) + + sort(compareFn?: (a: string, b: string) => number): string[]; +>sort : Symbol(sort, Decl(1.0lib-noErrors.ts, 807, 50)) +>compareFn : Symbol(compareFn, Decl(1.0lib-noErrors.ts, 808, 9)) +>a : Symbol(a, Decl(1.0lib-noErrors.ts, 808, 22)) +>b : Symbol(b, Decl(1.0lib-noErrors.ts, 808, 32)) + + splice(start: number): string[]; +>splice : Symbol(splice, Decl(1.0lib-noErrors.ts, 808, 65), Decl(1.0lib-noErrors.ts, 809, 36)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 809, 11)) + + splice(start: number, deleteCount: number, ...items: string[]): string[]; +>splice : Symbol(splice, Decl(1.0lib-noErrors.ts, 808, 65), Decl(1.0lib-noErrors.ts, 809, 36)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 810, 11)) +>deleteCount : Symbol(deleteCount, Decl(1.0lib-noErrors.ts, 810, 25)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 810, 46)) + + unshift(...items: string[]): number; +>unshift : Symbol(unshift, Decl(1.0lib-noErrors.ts, 810, 77)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 811, 12)) + + indexOf(searchElement: string, fromIndex?: number): number; +>indexOf : Symbol(indexOf, Decl(1.0lib-noErrors.ts, 811, 40)) +>searchElement : Symbol(searchElement, Decl(1.0lib-noErrors.ts, 813, 12)) +>fromIndex : Symbol(fromIndex, Decl(1.0lib-noErrors.ts, 813, 34)) + + lastIndexOf(searchElement: string, fromIndex?: number): number; +>lastIndexOf : Symbol(lastIndexOf, Decl(1.0lib-noErrors.ts, 813, 63)) +>searchElement : Symbol(searchElement, Decl(1.0lib-noErrors.ts, 814, 16)) +>fromIndex : Symbol(fromIndex, Decl(1.0lib-noErrors.ts, 814, 38)) + + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; +>every : Symbol(every, Decl(1.0lib-noErrors.ts, 814, 67)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 815, 10)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 815, 23)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 815, 37)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 815, 52)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 815, 81)) + + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; +>some : Symbol(some, Decl(1.0lib-noErrors.ts, 815, 106)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 816, 9)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 816, 22)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 816, 36)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 816, 51)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 816, 80)) + + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; +>forEach : Symbol(forEach, Decl(1.0lib-noErrors.ts, 816, 105)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 817, 12)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 817, 25)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 817, 39)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 817, 54)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 817, 80)) + + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; +>map : Symbol(map, Decl(1.0lib-noErrors.ts, 817, 102)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 818, 8)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 818, 21)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 818, 35)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 818, 50)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 818, 75)) + + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; +>filter : Symbol(filter, Decl(1.0lib-noErrors.ts, 818, 98)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 819, 11)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 819, 24)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 819, 38)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 819, 53)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 819, 82)) + + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +>reduce : Symbol(reduce, Decl(1.0lib-noErrors.ts, 819, 108)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 820, 11)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 820, 24)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 820, 43)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 820, 62)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 820, 84)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 820, 109)) + + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +>reduceRight : Symbol(reduceRight, Decl(1.0lib-noErrors.ts, 820, 135)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 821, 16)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 821, 29)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 821, 48)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 821, 67)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 821, 89)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 821, 114)) +} + + +interface RegExp { +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; +>exec : Symbol(exec, Decl(1.0lib-noErrors.ts, 825, 18)) +>string : Symbol(string, Decl(1.0lib-noErrors.ts, 830, 9)) +>RegExpExecArray : Symbol(RegExpExecArray, Decl(1.0lib-noErrors.ts, 790, 1)) + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; +>test : Symbol(test, Decl(1.0lib-noErrors.ts, 830, 42)) +>string : Symbol(string, Decl(1.0lib-noErrors.ts, 836, 9)) + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; +>source : Symbol(source, Decl(1.0lib-noErrors.ts, 836, 34)) + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; +>global : Symbol(global, Decl(1.0lib-noErrors.ts, 839, 19)) + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; +>ignoreCase : Symbol(ignoreCase, Decl(1.0lib-noErrors.ts, 842, 20)) + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; +>multiline : Symbol(multiline, Decl(1.0lib-noErrors.ts, 845, 24)) + + lastIndex: number; +>lastIndex : Symbol(lastIndex, Decl(1.0lib-noErrors.ts, 848, 23)) + + // Non-standard extensions + compile(): RegExp; +>compile : Symbol(compile, Decl(1.0lib-noErrors.ts, 850, 22)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) +} +declare var RegExp: { +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + new (pattern: string, flags?: string): RegExp; +>pattern : Symbol(pattern, Decl(1.0lib-noErrors.ts, 856, 9)) +>flags : Symbol(flags, Decl(1.0lib-noErrors.ts, 856, 25)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + (pattern: string, flags?: string): RegExp; +>pattern : Symbol(pattern, Decl(1.0lib-noErrors.ts, 857, 5)) +>flags : Symbol(flags, Decl(1.0lib-noErrors.ts, 857, 21)) +>RegExp : Symbol(RegExp, Decl(1.0lib-noErrors.ts, 822, 1), Decl(1.0lib-noErrors.ts, 855, 11)) + + // Non-standard extensions + $1: string; +>$1 : Symbol($1, Decl(1.0lib-noErrors.ts, 857, 46)) + + $2: string; +>$2 : Symbol($2, Decl(1.0lib-noErrors.ts, 860, 15)) + + $3: string; +>$3 : Symbol($3, Decl(1.0lib-noErrors.ts, 861, 15)) + + $4: string; +>$4 : Symbol($4, Decl(1.0lib-noErrors.ts, 862, 15)) + + $5: string; +>$5 : Symbol($5, Decl(1.0lib-noErrors.ts, 863, 15)) + + $6: string; +>$6 : Symbol($6, Decl(1.0lib-noErrors.ts, 864, 15)) + + $7: string; +>$7 : Symbol($7, Decl(1.0lib-noErrors.ts, 865, 15)) + + $8: string; +>$8 : Symbol($8, Decl(1.0lib-noErrors.ts, 866, 15)) + + $9: string; +>$9 : Symbol($9, Decl(1.0lib-noErrors.ts, 867, 15)) + + lastMatch: string; +>lastMatch : Symbol(lastMatch, Decl(1.0lib-noErrors.ts, 868, 15)) +} + +interface Error { +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) + + name: string; +>name : Symbol(name, Decl(1.0lib-noErrors.ts, 872, 17)) + + message: string; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 873, 17)) +} +declare var Error: { +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) + + new (message?: string): Error; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 877, 9)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) + + (message?: string): Error; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 878, 5)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) + + prototype: Error; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 878, 30)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} + +interface EvalError extends Error { +>EvalError : Symbol(EvalError, Decl(1.0lib-noErrors.ts, 880, 1), Decl(1.0lib-noErrors.ts, 884, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var EvalError: { +>EvalError : Symbol(EvalError, Decl(1.0lib-noErrors.ts, 880, 1), Decl(1.0lib-noErrors.ts, 884, 11)) + + new (message?: string): EvalError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 885, 9)) +>EvalError : Symbol(EvalError, Decl(1.0lib-noErrors.ts, 880, 1), Decl(1.0lib-noErrors.ts, 884, 11)) + + (message?: string): EvalError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 886, 5)) +>EvalError : Symbol(EvalError, Decl(1.0lib-noErrors.ts, 880, 1), Decl(1.0lib-noErrors.ts, 884, 11)) + + prototype: EvalError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 886, 34)) +>EvalError : Symbol(EvalError, Decl(1.0lib-noErrors.ts, 880, 1), Decl(1.0lib-noErrors.ts, 884, 11)) +} + +interface RangeError extends Error { +>RangeError : Symbol(RangeError, Decl(1.0lib-noErrors.ts, 888, 1), Decl(1.0lib-noErrors.ts, 892, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var RangeError: { +>RangeError : Symbol(RangeError, Decl(1.0lib-noErrors.ts, 888, 1), Decl(1.0lib-noErrors.ts, 892, 11)) + + new (message?: string): RangeError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 893, 9)) +>RangeError : Symbol(RangeError, Decl(1.0lib-noErrors.ts, 888, 1), Decl(1.0lib-noErrors.ts, 892, 11)) + + (message?: string): RangeError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 894, 5)) +>RangeError : Symbol(RangeError, Decl(1.0lib-noErrors.ts, 888, 1), Decl(1.0lib-noErrors.ts, 892, 11)) + + prototype: RangeError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 894, 35)) +>RangeError : Symbol(RangeError, Decl(1.0lib-noErrors.ts, 888, 1), Decl(1.0lib-noErrors.ts, 892, 11)) +} + +interface ReferenceError extends Error { +>ReferenceError : Symbol(ReferenceError, Decl(1.0lib-noErrors.ts, 896, 1), Decl(1.0lib-noErrors.ts, 900, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var ReferenceError: { +>ReferenceError : Symbol(ReferenceError, Decl(1.0lib-noErrors.ts, 896, 1), Decl(1.0lib-noErrors.ts, 900, 11)) + + new (message?: string): ReferenceError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 901, 9)) +>ReferenceError : Symbol(ReferenceError, Decl(1.0lib-noErrors.ts, 896, 1), Decl(1.0lib-noErrors.ts, 900, 11)) + + (message?: string): ReferenceError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 902, 5)) +>ReferenceError : Symbol(ReferenceError, Decl(1.0lib-noErrors.ts, 896, 1), Decl(1.0lib-noErrors.ts, 900, 11)) + + prototype: ReferenceError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 902, 39)) +>ReferenceError : Symbol(ReferenceError, Decl(1.0lib-noErrors.ts, 896, 1), Decl(1.0lib-noErrors.ts, 900, 11)) +} + +interface SyntaxError extends Error { +>SyntaxError : Symbol(SyntaxError, Decl(1.0lib-noErrors.ts, 904, 1), Decl(1.0lib-noErrors.ts, 908, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var SyntaxError: { +>SyntaxError : Symbol(SyntaxError, Decl(1.0lib-noErrors.ts, 904, 1), Decl(1.0lib-noErrors.ts, 908, 11)) + + new (message?: string): SyntaxError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 909, 9)) +>SyntaxError : Symbol(SyntaxError, Decl(1.0lib-noErrors.ts, 904, 1), Decl(1.0lib-noErrors.ts, 908, 11)) + + (message?: string): SyntaxError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 910, 5)) +>SyntaxError : Symbol(SyntaxError, Decl(1.0lib-noErrors.ts, 904, 1), Decl(1.0lib-noErrors.ts, 908, 11)) + + prototype: SyntaxError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 910, 36)) +>SyntaxError : Symbol(SyntaxError, Decl(1.0lib-noErrors.ts, 904, 1), Decl(1.0lib-noErrors.ts, 908, 11)) +} + +interface TypeError extends Error { +>TypeError : Symbol(TypeError, Decl(1.0lib-noErrors.ts, 912, 1), Decl(1.0lib-noErrors.ts, 916, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var TypeError: { +>TypeError : Symbol(TypeError, Decl(1.0lib-noErrors.ts, 912, 1), Decl(1.0lib-noErrors.ts, 916, 11)) + + new (message?: string): TypeError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 917, 9)) +>TypeError : Symbol(TypeError, Decl(1.0lib-noErrors.ts, 912, 1), Decl(1.0lib-noErrors.ts, 916, 11)) + + (message?: string): TypeError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 918, 5)) +>TypeError : Symbol(TypeError, Decl(1.0lib-noErrors.ts, 912, 1), Decl(1.0lib-noErrors.ts, 916, 11)) + + prototype: TypeError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 918, 34)) +>TypeError : Symbol(TypeError, Decl(1.0lib-noErrors.ts, 912, 1), Decl(1.0lib-noErrors.ts, 916, 11)) +} + +interface URIError extends Error { +>URIError : Symbol(URIError, Decl(1.0lib-noErrors.ts, 920, 1), Decl(1.0lib-noErrors.ts, 924, 11)) +>Error : Symbol(Error, Decl(1.0lib-noErrors.ts, 870, 1), Decl(1.0lib-noErrors.ts, 876, 11)) +} +declare var URIError: { +>URIError : Symbol(URIError, Decl(1.0lib-noErrors.ts, 920, 1), Decl(1.0lib-noErrors.ts, 924, 11)) + + new (message?: string): URIError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 925, 9)) +>URIError : Symbol(URIError, Decl(1.0lib-noErrors.ts, 920, 1), Decl(1.0lib-noErrors.ts, 924, 11)) + + (message?: string): URIError; +>message : Symbol(message, Decl(1.0lib-noErrors.ts, 926, 5)) +>URIError : Symbol(URIError, Decl(1.0lib-noErrors.ts, 920, 1), Decl(1.0lib-noErrors.ts, 924, 11)) + + prototype: URIError; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 926, 33)) +>URIError : Symbol(URIError, Decl(1.0lib-noErrors.ts, 920, 1), Decl(1.0lib-noErrors.ts, 924, 11)) +} + +interface JSON { +>JSON : Symbol(JSON, Decl(1.0lib-noErrors.ts, 928, 1), Decl(1.0lib-noErrors.ts, 973, 11)) + + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; +>parse : Symbol(parse, Decl(1.0lib-noErrors.ts, 930, 16)) +>text : Symbol(text, Decl(1.0lib-noErrors.ts, 937, 10)) +>reviver : Symbol(reviver, Decl(1.0lib-noErrors.ts, 937, 23)) +>key : Symbol(key, Decl(1.0lib-noErrors.ts, 937, 35)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 937, 44)) + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; +>stringify : Symbol(stringify, Decl(1.0lib-noErrors.ts, 937, 70), Decl(1.0lib-noErrors.ts, 942, 34), Decl(1.0lib-noErrors.ts, 948, 78), Decl(1.0lib-noErrors.ts, 954, 51), Decl(1.0lib-noErrors.ts, 961, 90)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 942, 14)) + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; +>stringify : Symbol(stringify, Decl(1.0lib-noErrors.ts, 937, 70), Decl(1.0lib-noErrors.ts, 942, 34), Decl(1.0lib-noErrors.ts, 948, 78), Decl(1.0lib-noErrors.ts, 954, 51), Decl(1.0lib-noErrors.ts, 961, 90)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 948, 14)) +>replacer : Symbol(replacer, Decl(1.0lib-noErrors.ts, 948, 25)) +>key : Symbol(key, Decl(1.0lib-noErrors.ts, 948, 37)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 948, 49)) + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; +>stringify : Symbol(stringify, Decl(1.0lib-noErrors.ts, 937, 70), Decl(1.0lib-noErrors.ts, 942, 34), Decl(1.0lib-noErrors.ts, 948, 78), Decl(1.0lib-noErrors.ts, 954, 51), Decl(1.0lib-noErrors.ts, 961, 90)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 954, 14)) +>replacer : Symbol(replacer, Decl(1.0lib-noErrors.ts, 954, 25)) + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; +>stringify : Symbol(stringify, Decl(1.0lib-noErrors.ts, 937, 70), Decl(1.0lib-noErrors.ts, 942, 34), Decl(1.0lib-noErrors.ts, 948, 78), Decl(1.0lib-noErrors.ts, 954, 51), Decl(1.0lib-noErrors.ts, 961, 90)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 961, 14)) +>replacer : Symbol(replacer, Decl(1.0lib-noErrors.ts, 961, 25)) +>key : Symbol(key, Decl(1.0lib-noErrors.ts, 961, 37)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 961, 49)) +>space : Symbol(space, Decl(1.0lib-noErrors.ts, 961, 69)) + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +>stringify : Symbol(stringify, Decl(1.0lib-noErrors.ts, 937, 70), Decl(1.0lib-noErrors.ts, 942, 34), Decl(1.0lib-noErrors.ts, 948, 78), Decl(1.0lib-noErrors.ts, 954, 51), Decl(1.0lib-noErrors.ts, 961, 90)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 968, 14)) +>replacer : Symbol(replacer, Decl(1.0lib-noErrors.ts, 968, 25)) +>space : Symbol(space, Decl(1.0lib-noErrors.ts, 968, 42)) +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; +>JSON : Symbol(JSON, Decl(1.0lib-noErrors.ts, 928, 1), Decl(1.0lib-noErrors.ts, 973, 11)) +>JSON : Symbol(JSON, Decl(1.0lib-noErrors.ts, 928, 1), Decl(1.0lib-noErrors.ts, 973, 11)) + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { +>Array : Symbol(Array, Decl(1.0lib-noErrors.ts, 973, 23), Decl(1.0lib-noErrors.ts, 1133, 11)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Returns a string representation of an array. + */ + toString(): string; +>toString : Symbol(toString, Decl(1.0lib-noErrors.ts, 980, 20)) + + toLocaleString(): string; +>toLocaleString : Symbol(toLocaleString, Decl(1.0lib-noErrors.ts, 984, 23)) + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; +>concat : Symbol(concat, Decl(1.0lib-noErrors.ts, 985, 29), Decl(1.0lib-noErrors.ts, 990, 46)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 990, 11)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 990, 26)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 990, 11)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; +>concat : Symbol(concat, Decl(1.0lib-noErrors.ts, 985, 29), Decl(1.0lib-noErrors.ts, 990, 46)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 995, 11)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; +>join : Symbol(join, Decl(1.0lib-noErrors.ts, 995, 31)) +>separator : Symbol(separator, Decl(1.0lib-noErrors.ts, 1000, 9)) + + /** + * Removes the last element from an array and returns it. + */ + pop(): T; +>pop : Symbol(pop, Decl(1.0lib-noErrors.ts, 1000, 37)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; +>push : Symbol(push, Decl(1.0lib-noErrors.ts, 1004, 13)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 1009, 9)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; +>reverse : Symbol(reverse, Decl(1.0lib-noErrors.ts, 1009, 32)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Removes the first element from an array and returns it. + */ + shift(): T; +>shift : Symbol(shift, Decl(1.0lib-noErrors.ts, 1013, 19)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; +>slice : Symbol(slice, Decl(1.0lib-noErrors.ts, 1017, 15)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 1023, 10)) +>end : Symbol(end, Decl(1.0lib-noErrors.ts, 1023, 25)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; +>sort : Symbol(sort, Decl(1.0lib-noErrors.ts, 1023, 45)) +>compareFn : Symbol(compareFn, Decl(1.0lib-noErrors.ts, 1029, 9)) +>a : Symbol(a, Decl(1.0lib-noErrors.ts, 1029, 22)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>b : Symbol(b, Decl(1.0lib-noErrors.ts, 1029, 27)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; +>splice : Symbol(splice, Decl(1.0lib-noErrors.ts, 1029, 50), Decl(1.0lib-noErrors.ts, 1035, 31)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 1035, 11)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; +>splice : Symbol(splice, Decl(1.0lib-noErrors.ts, 1029, 50), Decl(1.0lib-noErrors.ts, 1035, 31)) +>start : Symbol(start, Decl(1.0lib-noErrors.ts, 1043, 11)) +>deleteCount : Symbol(deleteCount, Decl(1.0lib-noErrors.ts, 1043, 25)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 1043, 46)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; +>unshift : Symbol(unshift, Decl(1.0lib-noErrors.ts, 1043, 67)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 1049, 12)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; +>indexOf : Symbol(indexOf, Decl(1.0lib-noErrors.ts, 1049, 35)) +>searchElement : Symbol(searchElement, Decl(1.0lib-noErrors.ts, 1056, 12)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>fromIndex : Symbol(fromIndex, Decl(1.0lib-noErrors.ts, 1056, 29)) + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; +>lastIndexOf : Symbol(lastIndexOf, Decl(1.0lib-noErrors.ts, 1056, 58)) +>searchElement : Symbol(searchElement, Decl(1.0lib-noErrors.ts, 1063, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>fromIndex : Symbol(fromIndex, Decl(1.0lib-noErrors.ts, 1063, 33)) + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @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. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; +>every : Symbol(every, Decl(1.0lib-noErrors.ts, 1063, 62)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1070, 10)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 1070, 23)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 1070, 32)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1070, 47)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 1070, 71)) + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @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. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; +>some : Symbol(some, Decl(1.0lib-noErrors.ts, 1070, 96)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1077, 9)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 1077, 22)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 1077, 31)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1077, 46)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 1077, 70)) + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @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: T, index: number, array: T[]) => void, thisArg?: any): void; +>forEach : Symbol(forEach, Decl(1.0lib-noErrors.ts, 1077, 95)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1084, 12)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 1084, 25)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 1084, 34)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1084, 49)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 1084, 70)) + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; +>map : Symbol(map, Decl(1.0lib-noErrors.ts, 1084, 92)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1091, 8)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1091, 11)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 1091, 24)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 1091, 33)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1091, 48)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1091, 8)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 1091, 66)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1091, 8)) + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; +>filter : Symbol(filter, Decl(1.0lib-noErrors.ts, 1091, 87)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1098, 11)) +>value : Symbol(value, Decl(1.0lib-noErrors.ts, 1098, 24)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>index : Symbol(index, Decl(1.0lib-noErrors.ts, 1098, 33)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1098, 48)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>thisArg : Symbol(thisArg, Decl(1.0lib-noErrors.ts, 1098, 72)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; +>reduce : Symbol(reduce, Decl(1.0lib-noErrors.ts, 1098, 93), Decl(1.0lib-noErrors.ts, 1105, 120)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1105, 11)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 1105, 24)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 1105, 41)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 1105, 58)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1105, 80)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 1105, 98)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +>reduce : Symbol(reduce, Decl(1.0lib-noErrors.ts, 1098, 93), Decl(1.0lib-noErrors.ts, 1105, 120)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1111, 11)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1111, 14)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 1111, 27)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1111, 11)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 1111, 44)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 1111, 61)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1111, 83)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1111, 11)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 1111, 101)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1111, 11)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1111, 11)) + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; +>reduceRight : Symbol(reduceRight, Decl(1.0lib-noErrors.ts, 1111, 122), Decl(1.0lib-noErrors.ts, 1118, 125)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1118, 16)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 1118, 29)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 1118, 46)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 1118, 63)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1118, 85)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 1118, 103)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +>reduceRight : Symbol(reduceRight, Decl(1.0lib-noErrors.ts, 1111, 122), Decl(1.0lib-noErrors.ts, 1118, 125)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1124, 16)) +>callbackfn : Symbol(callbackfn, Decl(1.0lib-noErrors.ts, 1124, 19)) +>previousValue : Symbol(previousValue, Decl(1.0lib-noErrors.ts, 1124, 32)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1124, 16)) +>currentValue : Symbol(currentValue, Decl(1.0lib-noErrors.ts, 1124, 49)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>currentIndex : Symbol(currentIndex, Decl(1.0lib-noErrors.ts, 1124, 66)) +>array : Symbol(array, Decl(1.0lib-noErrors.ts, 1124, 88)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1124, 16)) +>initialValue : Symbol(initialValue, Decl(1.0lib-noErrors.ts, 1124, 106)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1124, 16)) +>U : Symbol(U, Decl(1.0lib-noErrors.ts, 1124, 16)) + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; +>length : Symbol(length, Decl(1.0lib-noErrors.ts, 1124, 127)) + + [n: number]: T; +>n : Symbol(n, Decl(1.0lib-noErrors.ts, 1131, 5)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 980, 16)) +} +declare var Array: { +>Array : Symbol(Array, Decl(1.0lib-noErrors.ts, 973, 23), Decl(1.0lib-noErrors.ts, 1133, 11)) + + new (arrayLength?: number): any[]; +>arrayLength : Symbol(arrayLength, Decl(1.0lib-noErrors.ts, 1134, 9)) + + new (arrayLength: number): T[]; +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1135, 9)) +>arrayLength : Symbol(arrayLength, Decl(1.0lib-noErrors.ts, 1135, 12)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1135, 9)) + + new (...items: T[]): T[]; +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1136, 9)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 1136, 12)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1136, 9)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1136, 9)) + + (arrayLength?: number): any[]; +>arrayLength : Symbol(arrayLength, Decl(1.0lib-noErrors.ts, 1137, 5)) + + (arrayLength: number): T[]; +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1138, 5)) +>arrayLength : Symbol(arrayLength, Decl(1.0lib-noErrors.ts, 1138, 8)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1138, 5)) + + (...items: T[]): T[]; +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1139, 5)) +>items : Symbol(items, Decl(1.0lib-noErrors.ts, 1139, 8)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1139, 5)) +>T : Symbol(T, Decl(1.0lib-noErrors.ts, 1139, 5)) + + isArray(arg: any): boolean; +>isArray : Symbol(isArray, Decl(1.0lib-noErrors.ts, 1139, 28)) +>arg : Symbol(arg, Decl(1.0lib-noErrors.ts, 1140, 12)) + + prototype: Array; +>prototype : Symbol(prototype, Decl(1.0lib-noErrors.ts, 1140, 31)) +>Array : Symbol(Array, Decl(1.0lib-noErrors.ts, 973, 23), Decl(1.0lib-noErrors.ts, 1133, 11)) +} diff --git a/tests/baselines/reference/1.0lib-noErrors.types b/tests/baselines/reference/1.0lib-noErrors.types new file mode 100644 index 00000000000..96e5acc7049 --- /dev/null +++ b/tests/baselines/reference/1.0lib-noErrors.types @@ -0,0 +1,2086 @@ +=== tests/cases/conformance/decorators/1.0lib-noErrors.ts === +/* ***************************************************************************** +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. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +>NaN : number + +declare var Infinity: number; +>Infinity : number + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; +>eval : (x: string) => any +>x : string + +/** + * 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. + */ +declare function parseInt(s: string, radix?: number): number; +>parseInt : (s: string, radix?: number) => number +>s : string +>radix : number + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; +>parseFloat : (string: string) => number +>string : string + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; +>isNaN : (number: number) => boolean +>number : number + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; +>isFinite : (number: number) => boolean +>number : number + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; +>decodeURI : (encodedURI: string) => string +>encodedURI : string + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +declare function decodeURIComponent(encodedURIComponent: string): string; +>decodeURIComponent : (encodedURIComponent: string) => string +>encodedURIComponent : string + +/** + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ +declare function encodeURI(uri: string): string; +>encodeURI : (uri: string) => string +>uri : string + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; +>encodeURIComponent : (uriComponent: string) => string +>uriComponent : string + +interface PropertyDescriptor { +>PropertyDescriptor : PropertyDescriptor + + configurable?: boolean; +>configurable : boolean + + enumerable?: boolean; +>enumerable : boolean + + value?: any; +>value : any + + writable?: boolean; +>writable : boolean + + get?(): any; +>get : () => any + + set?(v: any): void; +>set : (v: any) => void +>v : any +} + +interface PropertyDescriptorMap { +>PropertyDescriptorMap : PropertyDescriptorMap + + [s: string]: PropertyDescriptor; +>s : string +>PropertyDescriptor : PropertyDescriptor +} + +interface Object { +>Object : Object + + /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ + constructor: Function; +>constructor : Function +>Function : Function + + /** Returns a string representation of an object. */ + toString(): string; +>toString : () => string + + /** Returns a date converted to a string using the current locale. */ + toLocaleString(): string; +>toLocaleString : () => string + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; +>valueOf : () => Object +>Object : Object + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; +>hasOwnProperty : (v: string) => boolean +>v : string + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; +>isPrototypeOf : (v: Object) => boolean +>v : Object +>Object : Object + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +>propertyIsEnumerable : (v: string) => boolean +>v : string +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { +>Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } + + new (value?: any): Object; +>value : any +>Object : Object + + (): any; + (value: any): any; +>value : any + + /** A reference to the prototype for a class of objects. */ + prototype: Object; +>prototype : Object +>Object : Object + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; +>getPrototypeOf : (o: any) => any +>o : 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. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; +>getOwnPropertyDescriptor : (o: any, p: string) => PropertyDescriptor +>o : any +>p : string +>PropertyDescriptor : PropertyDescriptor + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; +>getOwnPropertyNames : (o: any) => string[] +>o : any + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; +>create : (o: any, properties?: PropertyDescriptorMap) => any +>o : any +>properties : PropertyDescriptorMap +>PropertyDescriptorMap : PropertyDescriptorMap + + /** + * 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, p: string, attributes: PropertyDescriptor): any; +>defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any +>o : any +>p : string +>attributes : PropertyDescriptor +>PropertyDescriptor : PropertyDescriptor + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; +>defineProperties : (o: any, properties: PropertyDescriptorMap) => any +>o : any +>properties : PropertyDescriptorMap +>PropertyDescriptorMap : PropertyDescriptorMap + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; +>seal : (o: any) => any +>o : any + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; +>freeze : (o: any) => any +>o : any + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; +>preventExtensions : (o: any) => any +>o : any + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; +>isSealed : (o: any) => boolean +>o : any + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; +>isFrozen : (o: any) => boolean +>o : any + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; +>isExtensible : (o: any) => boolean +>o : any + + /** + * Returns the names of the enumerable properties and methods 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. + */ + keys(o: any): string[]; +>keys : (o: any) => string[] +>o : any +} + +/** + * Creates a new function. + */ +interface Function { +>Function : Function + + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; +>apply : (thisArg: any, argArray?: any) => any +>thisArg : any +>argArray : any + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; +>call : (thisArg: any, ...argArray: any[]) => any +>thisArg : any +>argArray : any[] + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; +>bind : (thisArg: any, ...argArray: any[]) => any +>thisArg : any +>argArray : any[] + + prototype: any; +>prototype : any + + length: number; +>length : number + + // Non-standard extensions + arguments: any; +>arguments : any + + caller: Function; +>caller : Function +>Function : Function +} + +declare var Function: { +>Function : { (...args: string[]): Function; new (...args: string[]): Function; prototype: Function; } + + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; +>args : string[] +>Function : Function + + (...args: string[]): Function; +>args : string[] +>Function : Function + + prototype: Function; +>prototype : Function +>Function : Function +} + +interface IArguments { +>IArguments : IArguments + + [index: number]: any; +>index : number + + length: number; +>length : number + + callee: Function; +>callee : Function +>Function : Function +} + +interface String { +>String : String + + /** Returns a string representation of a string. */ + toString(): string; +>toString : () => string + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; +>charAt : (pos: number) => string +>pos : number + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; +>charCodeAt : (index: number) => number +>index : number + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; +>concat : (...strings: string[]) => string +>strings : string[] + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; +>indexOf : (searchString: string, position?: number) => number +>searchString : string +>position : number + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; +>lastIndexOf : (searchString: string, position?: number) => number +>searchString : string +>position : number + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; +>localeCompare : (that: string) => number +>that : string + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; +>match : { (regexp: string): string[]; (regexp: RegExp): string[]; } +>regexp : string + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; +>match : { (regexp: string): string[]; (regexp: RegExp): string[]; } +>regexp : RegExp +>RegExp : RegExp + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : string +>replaceValue : string + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : string +>replaceValue : (substring: string, ...args: any[]) => string +>substring : string +>args : any[] + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : RegExp +>RegExp : RegExp +>replaceValue : string + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : RegExp +>RegExp : RegExp +>replaceValue : (substring: string, ...args: any[]) => string +>substring : string +>args : any[] + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; +>search : { (regexp: string): number; (regexp: RegExp): number; } +>regexp : string + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; +>search : { (regexp: string): number; (regexp: RegExp): number; } +>regexp : RegExp +>RegExp : RegExp + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; +>slice : (start?: number, end?: number) => string +>start : number +>end : number + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; +>split : { (separator: string, limit?: number): string[]; (separator: RegExp, limit?: number): string[]; } +>separator : string +>limit : number + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; +>split : { (separator: string, limit?: number): string[]; (separator: RegExp, limit?: number): string[]; } +>separator : RegExp +>RegExp : RegExp +>limit : number + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; +>substring : (start: number, end?: number) => string +>start : number +>end : number + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; +>toLowerCase : () => string + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; +>toLocaleLowerCase : () => string + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; +>toUpperCase : () => string + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; +>toLocaleUpperCase : () => string + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; +>trim : () => string + + /** Returns the length of a String object. */ + length: number; +>length : number + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; +>substr : (from: number, length?: number) => string +>from : number +>length : number + + [index: number]: string; +>index : number +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { +>String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } + + new (value?: any): String; +>value : any +>String : String + + (value?: any): string; +>value : any + + prototype: String; +>prototype : String +>String : String + + fromCharCode(...codes: number[]): string; +>fromCharCode : (...codes: number[]) => string +>codes : number[] +} + +interface Boolean { +>Boolean : Boolean +} +declare var Boolean: { +>Boolean : { (value?: any): boolean; new (value?: any): Boolean; prototype: Boolean; } + + new (value?: any): Boolean; +>value : any +>Boolean : Boolean + + (value?: any): boolean; +>value : any + + prototype: Boolean; +>prototype : Boolean +>Boolean : Boolean +} + +interface Number { +>Number : Number + + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; +>toString : (radix?: number) => string +>radix : number + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; +>toFixed : (fractionDigits?: number) => string +>fractionDigits : number + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; +>toExponential : (fractionDigits?: number) => string +>fractionDigits : number + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +>toPrecision : (precision?: number) => string +>precision : number +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { +>Number : { (value?: any): number; new (value?: any): Number; prototype: Number; MAX_VALUE: number; MIN_VALUE: number; NaN: number; NEGATIVE_INFINITY: number; POSITIVE_INFINITY: number; } + + new (value?: any): Number; +>value : any +>Number : Number + + (value?: any): number; +>value : any + + prototype: Number; +>prototype : Number +>Number : Number + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; +>MAX_VALUE : number + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; +>MIN_VALUE : number + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; +>NaN : number + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; +>NEGATIVE_INFINITY : number + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +>POSITIVE_INFINITY : number +} + +interface Math { +>Math : Math + + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; +>E : number + + /** The natural logarithm of 10. */ + LN10: number; +>LN10 : number + + /** The natural logarithm of 2. */ + LN2: number; +>LN2 : number + + /** The base-2 logarithm of e. */ + LOG2E: number; +>LOG2E : number + + /** The base-10 logarithm of e. */ + LOG10E: number; +>LOG10E : number + + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; +>PI : number + + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; +>SQRT1_2 : number + + /** The square root of 2. */ + SQRT2: number; +>SQRT2 : number + + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; +>abs : (x: number) => number +>x : number + + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; +>acos : (x: number) => number +>x : number + + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; +>asin : (x: number) => number +>x : number + + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; +>atan : (x: number) => number +>x : number + + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; +>atan2 : (y: number, x: number) => number +>y : number +>x : number + + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; +>ceil : (x: number) => number +>x : number + + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; +>cos : (x: number) => number +>x : number + + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; +>exp : (x: number) => number +>x : number + + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; +>floor : (x: number) => number +>x : number + + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; +>log : (x: number) => number +>x : number + + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; +>max : (...values: number[]) => number +>values : number[] + + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; +>min : (...values: number[]) => number +>values : number[] + + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; +>pow : (x: number, y: number) => number +>x : number +>y : number + + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; +>random : () => number + + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; +>round : (x: number) => number +>x : number + + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; +>sin : (x: number) => number +>x : number + + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; +>sqrt : (x: number) => number +>x : number + + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +>tan : (x: number) => number +>x : number +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; +>Math : Math +>Math : Math + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { +>Date : Date + + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; +>toString : () => string + + /** Returns a date as a string value. */ + toDateString(): string; +>toDateString : () => string + + /** Returns a time as a string value. */ + toTimeString(): string; +>toTimeString : () => string + + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; +>toLocaleString : () => string + + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; +>toLocaleDateString : () => string + + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; +>toLocaleTimeString : () => string + + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; +>valueOf : () => number + + /** Gets the time value in milliseconds. */ + getTime(): number; +>getTime : () => number + + /** Gets the year, using local time. */ + getFullYear(): number; +>getFullYear : () => number + + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; +>getUTCFullYear : () => number + + /** Gets the month, using local time. */ + getMonth(): number; +>getMonth : () => number + + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; +>getUTCMonth : () => number + + /** Gets the day-of-the-month, using local time. */ + getDate(): number; +>getDate : () => number + + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; +>getUTCDate : () => number + + /** Gets the day of the week, using local time. */ + getDay(): number; +>getDay : () => number + + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; +>getUTCDay : () => number + + /** Gets the hours in a date, using local time. */ + getHours(): number; +>getHours : () => number + + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; +>getUTCHours : () => number + + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; +>getMinutes : () => number + + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; +>getUTCMinutes : () => number + + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; +>getSeconds : () => number + + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; +>getUTCSeconds : () => number + + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; +>getMilliseconds : () => number + + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; +>getUTCMilliseconds : () => number + + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; +>getTimezoneOffset : () => number + + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + setTime(time: number): number; +>setTime : (time: number) => number +>time : number + + /** + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ + setMilliseconds(ms: number): number; +>setMilliseconds : (ms: number) => number +>ms : number + + /** + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ + setUTCMilliseconds(ms: number): number; +>setUTCMilliseconds : (ms: number) => number +>ms : number + + /** + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setSeconds(sec: number, ms?: number): number; +>setSeconds : (sec: number, ms?: number) => number +>sec : number +>ms : number + + /** + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCSeconds(sec: number, ms?: number): number; +>setUTCSeconds : (sec: number, ms?: number) => number +>sec : number +>ms : number + + /** + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setMinutes(min: number, sec?: number, ms?: number): number; +>setMinutes : (min: number, sec?: number, ms?: number) => number +>min : number +>sec : number +>ms : number + + /** + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCMinutes(min: number, sec?: number, ms?: number): number; +>setUTCMinutes : (min: number, sec?: number, ms?: number) => number +>min : number +>sec : number +>ms : number + + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; +>setHours : (hours: number, min?: number, sec?: number, ms?: number) => number +>hours : number +>min : number +>sec : number +>ms : number + + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; +>setUTCHours : (hours: number, min?: number, sec?: number, ms?: number) => number +>hours : number +>min : number +>sec : number +>ms : number + + /** + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ + setDate(date: number): number; +>setDate : (date: number) => number +>date : number + + /** + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ + setUTCDate(date: number): number; +>setUTCDate : (date: number) => number +>date : number + + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ + setMonth(month: number, date?: number): number; +>setMonth : (month: number, date?: number) => number +>month : number +>date : number + + /** + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ + setUTCMonth(month: number, date?: number): number; +>setUTCMonth : (month: number, date?: number) => number +>month : number +>date : number + + /** + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ + setFullYear(year: number, month?: number, date?: number): number; +>setFullYear : (year: number, month?: number, date?: number) => number +>year : number +>month : number +>date : number + + /** + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ + setUTCFullYear(year: number, month?: number, date?: number): number; +>setUTCFullYear : (year: number, month?: number, date?: number) => number +>year : number +>month : number +>date : number + + /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ + toUTCString(): string; +>toUTCString : () => string + + /** Returns a date as a string value in ISO format. */ + toISOString(): string; +>toISOString : () => string + + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +>toJSON : (key?: any) => string +>key : any +} + +declare var Date: { +>Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } + + new (): Date; +>Date : Date + + new (value: number): Date; +>value : number +>Date : Date + + new (value: string): Date; +>value : string +>Date : Date + + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; +>year : number +>month : number +>date : number +>hours : number +>minutes : number +>seconds : number +>ms : number +>Date : Date + + (): string; + prototype: Date; +>prototype : Date +>Date : Date + + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; +>parse : (s: string) => number +>s : string + + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; +>UTC : (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number) => number +>year : number +>month : number +>date : number +>hours : number +>minutes : number +>seconds : number +>ms : number + + now(): number; +>now : () => number +} + +interface RegExpExecArray { +>RegExpExecArray : RegExpExecArray + + [index: number]: string; +>index : number + + length: number; +>length : number + + index: number; +>index : number + + input: string; +>input : string + + toString(): string; +>toString : () => string + + toLocaleString(): string; +>toLocaleString : () => string + + concat(...items: string[][]): string[]; +>concat : (...items: string[][]) => string[] +>items : string[][] + + join(separator?: string): string; +>join : (separator?: string) => string +>separator : string + + pop(): string; +>pop : () => string + + push(...items: string[]): number; +>push : (...items: string[]) => number +>items : string[] + + reverse(): string[]; +>reverse : () => string[] + + shift(): string; +>shift : () => string + + slice(start?: number, end?: number): string[]; +>slice : (start?: number, end?: number) => string[] +>start : number +>end : number + + sort(compareFn?: (a: string, b: string) => number): string[]; +>sort : (compareFn?: (a: string, b: string) => number) => string[] +>compareFn : (a: string, b: string) => number +>a : string +>b : string + + splice(start: number): string[]; +>splice : { (start: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +>start : number + + splice(start: number, deleteCount: number, ...items: string[]): string[]; +>splice : { (start: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +>start : number +>deleteCount : number +>items : string[] + + unshift(...items: string[]): number; +>unshift : (...items: string[]) => number +>items : string[] + + indexOf(searchElement: string, fromIndex?: number): number; +>indexOf : (searchElement: string, fromIndex?: number) => number +>searchElement : string +>fromIndex : number + + lastIndexOf(searchElement: string, fromIndex?: number): number; +>lastIndexOf : (searchElement: string, fromIndex?: number) => number +>searchElement : string +>fromIndex : number + + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; +>every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>callbackfn : (value: string, index: number, array: string[]) => boolean +>value : string +>index : number +>array : string[] +>thisArg : any + + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; +>some : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>callbackfn : (value: string, index: number, array: string[]) => boolean +>value : string +>index : number +>array : string[] +>thisArg : any + + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; +>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>callbackfn : (value: string, index: number, array: string[]) => void +>value : string +>index : number +>array : string[] +>thisArg : any + + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; +>map : (callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any) => any[] +>callbackfn : (value: string, index: number, array: string[]) => any +>value : string +>index : number +>array : string[] +>thisArg : any + + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; +>filter : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => string[] +>callbackfn : (value: string, index: number, array: string[]) => boolean +>value : string +>index : number +>array : string[] +>thisArg : any + + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +>reduce : (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any) => any +>callbackfn : (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any +>previousValue : any +>currentValue : any +>currentIndex : number +>array : string[] +>initialValue : any + + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +>reduceRight : (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any) => any +>callbackfn : (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any +>previousValue : any +>currentValue : any +>currentIndex : number +>array : string[] +>initialValue : any +} + + +interface RegExp { +>RegExp : RegExp + + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + exec(string: string): RegExpExecArray; +>exec : (string: string) => RegExpExecArray +>string : string +>RegExpExecArray : RegExpExecArray + + /** + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ + test(string: string): boolean; +>test : (string: string) => boolean +>string : string + + /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ + source: string; +>source : string + + /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ + global: boolean; +>global : boolean + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; +>ignoreCase : boolean + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; +>multiline : boolean + + lastIndex: number; +>lastIndex : number + + // Non-standard extensions + compile(): RegExp; +>compile : () => RegExp +>RegExp : RegExp +} +declare var RegExp: { +>RegExp : { (pattern: string, flags?: string): RegExp; new (pattern: string, flags?: string): RegExp; $1: string; $2: string; $3: string; $4: string; $5: string; $6: string; $7: string; $8: string; $9: string; lastMatch: string; } + + new (pattern: string, flags?: string): RegExp; +>pattern : string +>flags : string +>RegExp : RegExp + + (pattern: string, flags?: string): RegExp; +>pattern : string +>flags : string +>RegExp : RegExp + + // Non-standard extensions + $1: string; +>$1 : string + + $2: string; +>$2 : string + + $3: string; +>$3 : string + + $4: string; +>$4 : string + + $5: string; +>$5 : string + + $6: string; +>$6 : string + + $7: string; +>$7 : string + + $8: string; +>$8 : string + + $9: string; +>$9 : string + + lastMatch: string; +>lastMatch : string +} + +interface Error { +>Error : Error + + name: string; +>name : string + + message: string; +>message : string +} +declare var Error: { +>Error : { (message?: string): Error; new (message?: string): Error; prototype: Error; } + + new (message?: string): Error; +>message : string +>Error : Error + + (message?: string): Error; +>message : string +>Error : Error + + prototype: Error; +>prototype : Error +>Error : Error +} + +interface EvalError extends Error { +>EvalError : EvalError +>Error : Error +} +declare var EvalError: { +>EvalError : { (message?: string): EvalError; new (message?: string): EvalError; prototype: EvalError; } + + new (message?: string): EvalError; +>message : string +>EvalError : EvalError + + (message?: string): EvalError; +>message : string +>EvalError : EvalError + + prototype: EvalError; +>prototype : EvalError +>EvalError : EvalError +} + +interface RangeError extends Error { +>RangeError : RangeError +>Error : Error +} +declare var RangeError: { +>RangeError : { (message?: string): RangeError; new (message?: string): RangeError; prototype: RangeError; } + + new (message?: string): RangeError; +>message : string +>RangeError : RangeError + + (message?: string): RangeError; +>message : string +>RangeError : RangeError + + prototype: RangeError; +>prototype : RangeError +>RangeError : RangeError +} + +interface ReferenceError extends Error { +>ReferenceError : ReferenceError +>Error : Error +} +declare var ReferenceError: { +>ReferenceError : { (message?: string): ReferenceError; new (message?: string): ReferenceError; prototype: ReferenceError; } + + new (message?: string): ReferenceError; +>message : string +>ReferenceError : ReferenceError + + (message?: string): ReferenceError; +>message : string +>ReferenceError : ReferenceError + + prototype: ReferenceError; +>prototype : ReferenceError +>ReferenceError : ReferenceError +} + +interface SyntaxError extends Error { +>SyntaxError : SyntaxError +>Error : Error +} +declare var SyntaxError: { +>SyntaxError : { (message?: string): SyntaxError; new (message?: string): SyntaxError; prototype: SyntaxError; } + + new (message?: string): SyntaxError; +>message : string +>SyntaxError : SyntaxError + + (message?: string): SyntaxError; +>message : string +>SyntaxError : SyntaxError + + prototype: SyntaxError; +>prototype : SyntaxError +>SyntaxError : SyntaxError +} + +interface TypeError extends Error { +>TypeError : TypeError +>Error : Error +} +declare var TypeError: { +>TypeError : { (message?: string): TypeError; new (message?: string): TypeError; prototype: TypeError; } + + new (message?: string): TypeError; +>message : string +>TypeError : TypeError + + (message?: string): TypeError; +>message : string +>TypeError : TypeError + + prototype: TypeError; +>prototype : TypeError +>TypeError : TypeError +} + +interface URIError extends Error { +>URIError : URIError +>Error : Error +} +declare var URIError: { +>URIError : { (message?: string): URIError; new (message?: string): URIError; prototype: URIError; } + + new (message?: string): URIError; +>message : string +>URIError : URIError + + (message?: string): URIError; +>message : string +>URIError : URIError + + prototype: URIError; +>prototype : URIError +>URIError : URIError +} + +interface JSON { +>JSON : JSON + + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; +>parse : (text: string, reviver?: (key: any, value: any) => any) => any +>text : string +>reviver : (key: any, value: any) => any +>key : any +>value : any + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; +>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; } +>value : any + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; +>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; } +>value : any +>replacer : (key: string, value: any) => any +>key : string +>value : any + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; +>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; } +>value : any +>replacer : any[] + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; +>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; } +>value : any +>replacer : (key: string, value: any) => any +>key : string +>value : any +>space : any + + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; } +>value : any +>replacer : any[] +>space : any +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; +>JSON : JSON +>JSON : JSON + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { +>Array : T[] +>T : T + + /** + * Returns a string representation of an array. + */ + toString(): string; +>toString : () => string + + toLocaleString(): string; +>toLocaleString : () => string + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; +>concat : { (...items: U[]): T[]; (...items: T[]): T[]; } +>U : U +>T : T +>items : U[] +>U : U +>T : T + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; +>concat : { (...items: U[]): T[]; (...items: T[]): T[]; } +>items : T[] +>T : T +>T : T + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; +>join : (separator?: string) => string +>separator : string + + /** + * Removes the last element from an array and returns it. + */ + pop(): T; +>pop : () => T +>T : T + + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; +>push : (...items: T[]) => number +>items : T[] +>T : T + + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; +>reverse : () => T[] +>T : T + + /** + * Removes the first element from an array and returns it. + */ + shift(): T; +>shift : () => T +>T : T + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; +>slice : (start?: number, end?: number) => T[] +>start : number +>end : number +>T : T + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; +>sort : (compareFn?: (a: T, b: T) => number) => T[] +>compareFn : (a: T, b: T) => number +>a : T +>T : T +>b : T +>T : T +>T : T + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; +>splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>start : number +>T : T + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; +>splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>start : number +>deleteCount : number +>items : T[] +>T : T +>T : T + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; +>unshift : (...items: T[]) => number +>items : T[] +>T : T + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; +>indexOf : (searchElement: T, fromIndex?: number) => number +>searchElement : T +>T : T +>fromIndex : number + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; +>lastIndexOf : (searchElement: T, fromIndex?: number) => number +>searchElement : T +>T : T +>fromIndex : number + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @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. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; +>every : (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => boolean +>callbackfn : (value: T, index: number, array: T[]) => boolean +>value : T +>T : T +>index : number +>array : T[] +>T : T +>thisArg : any + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @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. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; +>some : (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => boolean +>callbackfn : (value: T, index: number, array: T[]) => boolean +>value : T +>T : T +>index : number +>array : T[] +>T : T +>thisArg : any + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @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: T, index: number, array: T[]) => void, thisArg?: any): void; +>forEach : (callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any) => void +>callbackfn : (value: T, index: number, array: T[]) => void +>value : T +>T : T +>index : number +>array : T[] +>T : T +>thisArg : any + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; +>map : (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[] +>U : U +>callbackfn : (value: T, index: number, array: T[]) => U +>value : T +>T : T +>index : number +>array : T[] +>T : T +>U : U +>thisArg : any +>U : U + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; +>filter : (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => T[] +>callbackfn : (value: T, index: number, array: T[]) => boolean +>value : T +>T : T +>index : number +>array : T[] +>T : T +>thisArg : any +>T : T + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; +>reduce : { (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; (callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>callbackfn : (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T +>previousValue : T +>T : T +>currentValue : T +>T : T +>currentIndex : number +>array : T[] +>T : T +>T : T +>initialValue : T +>T : T +>T : T + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +>reduce : { (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; (callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>U : U +>callbackfn : (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U +>previousValue : U +>U : U +>currentValue : T +>T : T +>currentIndex : number +>array : T[] +>T : T +>U : U +>initialValue : U +>U : U +>U : U + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; +>reduceRight : { (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; (callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>callbackfn : (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T +>previousValue : T +>T : T +>currentValue : T +>T : T +>currentIndex : number +>array : T[] +>T : T +>T : T +>initialValue : T +>T : T +>T : T + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +>reduceRight : { (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; (callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>U : U +>callbackfn : (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U +>previousValue : U +>U : U +>currentValue : T +>T : T +>currentIndex : number +>array : T[] +>T : T +>U : U +>initialValue : U +>U : U +>U : U + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; +>length : number + + [n: number]: T; +>n : number +>T : T +} +declare var Array: { +>Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } + + new (arrayLength?: number): any[]; +>arrayLength : number + + new (arrayLength: number): T[]; +>T : T +>arrayLength : number +>T : T + + new (...items: T[]): T[]; +>T : T +>items : T[] +>T : T +>T : T + + (arrayLength?: number): any[]; +>arrayLength : number + + (arrayLength: number): T[]; +>T : T +>arrayLength : number +>T : T + + (...items: T[]): T[]; +>T : T +>items : T[] +>T : T +>T : T + + isArray(arg: any): boolean; +>isArray : (arg: any) => boolean +>arg : any + + prototype: Array; +>prototype : any[] +>Array : T[] +} diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js new file mode 100644 index 00000000000..97180f42133 --- /dev/null +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -0,0 +1,72 @@ +//// [baseTypeWrappingInstantiationChain.ts] +class C extends CBase { + public works() { + new CBaseBase>(this); + } + public alsoWorks() { + new CBase(this); // Should not error, parameter is of type Parameter> + } + + public method(t: Wrapper) { } +} + +class CBase extends CBaseBase> { + +} + +class CBaseBase { + constructor(x: Parameter) { } +} + +class Parameter { + method(t: T4) { } +} + +class Wrapper { + property: T5; +} + +//// [baseTypeWrappingInstantiationChain.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.works = function () { + new CBaseBase(this); + }; + C.prototype.alsoWorks = function () { + new CBase(this); // Should not error, parameter is of type Parameter> + }; + C.prototype.method = function (t) { }; + return C; +})(CBase); +var CBase = (function (_super) { + __extends(CBase, _super); + function CBase() { + _super.apply(this, arguments); + } + return CBase; +})(CBaseBase); +var CBaseBase = (function () { + function CBaseBase(x) { + } + return CBaseBase; +})(); +var Parameter = (function () { + function Parameter() { + } + Parameter.prototype.method = function (t) { }; + return Parameter; +})(); +var Wrapper = (function () { + function Wrapper() { + } + return Wrapper; +})(); diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.symbols b/tests/baselines/reference/baseTypeWrappingInstantiationChain.symbols new file mode 100644 index 00000000000..1e8ab089b90 --- /dev/null +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts === +class C extends CBase { +>C : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0)) +>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8)) +>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1)) +>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8)) + + public works() { +>works : Symbol(works, Decl(baseTypeWrappingInstantiationChain.ts, 0, 31)) + + new CBaseBase>(this); +>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1)) +>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1)) +>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8)) +>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0)) + } + public alsoWorks() { +>alsoWorks : Symbol(alsoWorks, Decl(baseTypeWrappingInstantiationChain.ts, 3, 5)) + + new CBase(this); // Should not error, parameter is of type Parameter> +>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1)) +>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8)) +>this : Symbol(C, Decl(baseTypeWrappingInstantiationChain.ts, 0, 0)) + } + + public method(t: Wrapper) { } +>method : Symbol(method, Decl(baseTypeWrappingInstantiationChain.ts, 6, 5)) +>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 8, 18)) +>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1)) +>T1 : Symbol(T1, Decl(baseTypeWrappingInstantiationChain.ts, 0, 8)) +} + +class CBase extends CBaseBase> { +>CBase : Symbol(CBase, Decl(baseTypeWrappingInstantiationChain.ts, 9, 1)) +>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12)) +>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1)) +>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1)) +>T2 : Symbol(T2, Decl(baseTypeWrappingInstantiationChain.ts, 11, 12)) + +} + +class CBaseBase { +>CBaseBase : Symbol(CBaseBase, Decl(baseTypeWrappingInstantiationChain.ts, 13, 1)) +>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16)) + + constructor(x: Parameter) { } +>x : Symbol(x, Decl(baseTypeWrappingInstantiationChain.ts, 16, 16)) +>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1)) +>T3 : Symbol(T3, Decl(baseTypeWrappingInstantiationChain.ts, 15, 16)) +} + +class Parameter { +>Parameter : Symbol(Parameter, Decl(baseTypeWrappingInstantiationChain.ts, 17, 1)) +>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16)) + + method(t: T4) { } +>method : Symbol(method, Decl(baseTypeWrappingInstantiationChain.ts, 19, 21)) +>t : Symbol(t, Decl(baseTypeWrappingInstantiationChain.ts, 20, 11)) +>T4 : Symbol(T4, Decl(baseTypeWrappingInstantiationChain.ts, 19, 16)) +} + +class Wrapper { +>Wrapper : Symbol(Wrapper, Decl(baseTypeWrappingInstantiationChain.ts, 21, 1)) +>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14)) + + property: T5; +>property : Symbol(property, Decl(baseTypeWrappingInstantiationChain.ts, 23, 19)) +>T5 : Symbol(T5, Decl(baseTypeWrappingInstantiationChain.ts, 23, 14)) +} diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types new file mode 100644 index 00000000000..61919bad212 --- /dev/null +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types @@ -0,0 +1,71 @@ +=== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts === +class C extends CBase { +>C : C +>T1 : T1 +>CBase : CBase +>T1 : T1 + + public works() { +>works : () => void + + new CBaseBase>(this); +>new CBaseBase>(this) : CBaseBase> +>CBaseBase : typeof CBaseBase +>Wrapper : Wrapper +>T1 : T1 +>this : C + } + public alsoWorks() { +>alsoWorks : () => void + + new CBase(this); // Should not error, parameter is of type Parameter> +>new CBase(this) : CBase +>CBase : typeof CBase +>T1 : T1 +>this : C + } + + public method(t: Wrapper) { } +>method : (t: Wrapper) => void +>t : Wrapper +>Wrapper : Wrapper +>T1 : T1 +} + +class CBase extends CBaseBase> { +>CBase : CBase +>T2 : T2 +>CBaseBase : CBaseBase +>Wrapper : Wrapper +>T2 : T2 + +} + +class CBaseBase { +>CBaseBase : CBaseBase +>T3 : T3 + + constructor(x: Parameter) { } +>x : Parameter +>Parameter : Parameter +>T3 : T3 +} + +class Parameter { +>Parameter : Parameter +>T4 : T4 + + method(t: T4) { } +>method : (t: T4) => void +>t : T4 +>T4 : T4 +} + +class Wrapper { +>Wrapper : Wrapper +>T5 : T5 + + property: T5; +>property : T5 +>T5 : T5 +} diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithClass.js b/tests/baselines/reference/circularTypeAliasForUnionWithClass.js new file mode 100644 index 00000000000..90a11364897 --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithClass.js @@ -0,0 +1,39 @@ +//// [circularTypeAliasForUnionWithClass.ts] +var v0: T0; +type T0 = string | I0; +class I0 { + x: T0; +} + +var v3: T3; +type T3 = string | I3; +class I3 { + [x: number]: T3; +} + +var v4: T4; +type T4 = string | I4; +class I4 { + [x: string]: T4; +} + + +//// [circularTypeAliasForUnionWithClass.js] +var v0; +var I0 = (function () { + function I0() { + } + return I0; +})(); +var v3; +var I3 = (function () { + function I3() { + } + return I3; +})(); +var v4; +var I4 = (function () { + function I4() { + } + return I4; +})(); diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithClass.symbols b/tests/baselines/reference/circularTypeAliasForUnionWithClass.symbols new file mode 100644 index 00000000000..ecfba63332d --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithClass.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithClass.ts === +var v0: T0; +>v0 : Symbol(v0, Decl(circularTypeAliasForUnionWithClass.ts, 0, 3)) +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithClass.ts, 0, 11)) + +type T0 = string | I0; +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithClass.ts, 0, 11)) +>I0 : Symbol(I0, Decl(circularTypeAliasForUnionWithClass.ts, 1, 22)) + +class I0 { +>I0 : Symbol(I0, Decl(circularTypeAliasForUnionWithClass.ts, 1, 22)) + + x: T0; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithClass.ts, 2, 10)) +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithClass.ts, 0, 11)) +} + +var v3: T3; +>v3 : Symbol(v3, Decl(circularTypeAliasForUnionWithClass.ts, 6, 3)) +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithClass.ts, 6, 11)) + +type T3 = string | I3; +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithClass.ts, 6, 11)) +>I3 : Symbol(I3, Decl(circularTypeAliasForUnionWithClass.ts, 7, 22)) + +class I3 { +>I3 : Symbol(I3, Decl(circularTypeAliasForUnionWithClass.ts, 7, 22)) + + [x: number]: T3; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithClass.ts, 9, 5)) +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithClass.ts, 6, 11)) +} + +var v4: T4; +>v4 : Symbol(v4, Decl(circularTypeAliasForUnionWithClass.ts, 12, 3)) +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithClass.ts, 12, 11)) + +type T4 = string | I4; +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithClass.ts, 12, 11)) +>I4 : Symbol(I4, Decl(circularTypeAliasForUnionWithClass.ts, 13, 22)) + +class I4 { +>I4 : Symbol(I4, Decl(circularTypeAliasForUnionWithClass.ts, 13, 22)) + + [x: string]: T4; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithClass.ts, 15, 5)) +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithClass.ts, 12, 11)) +} + diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithClass.types b/tests/baselines/reference/circularTypeAliasForUnionWithClass.types new file mode 100644 index 00000000000..99a05f3d66a --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithClass.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithClass.ts === +var v0: T0; +>v0 : string | I0 +>T0 : string | I0 + +type T0 = string | I0; +>T0 : string | I0 +>I0 : I0 + +class I0 { +>I0 : I0 + + x: T0; +>x : string | I0 +>T0 : string | I0 +} + +var v3: T3; +>v3 : string | I3 +>T3 : string | I3 + +type T3 = string | I3; +>T3 : string | I3 +>I3 : I3 + +class I3 { +>I3 : I3 + + [x: number]: T3; +>x : number +>T3 : string | I3 +} + +var v4: T4; +>v4 : string | I4 +>T4 : string | I4 + +type T4 = string | I4; +>T4 : string | I4 +>I4 : I4 + +class I4 { +>I4 : I4 + + [x: string]: T4; +>x : string +>T4 : string | I4 +} + diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithInterface.js b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.js new file mode 100644 index 00000000000..60f4df9a8b6 --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.js @@ -0,0 +1,38 @@ +//// [circularTypeAliasForUnionWithInterface.ts] +var v0: T0; +type T0 = string | I0; +interface I0 { + x: T0; +} + +var v1: T1; +type T1 = string | I1; +interface I1 { + (): T1; +} + +var v2: T2; +type T2 = string | I2; +interface I2 { + new (): T2; +} + +var v3: T3; +type T3 = string | I3; +interface I3 { + [x: number]: T3; +} + +var v4: T4; +type T4 = string | I4; +interface I4 { + [x: string]: T4; +} + + +//// [circularTypeAliasForUnionWithInterface.js] +var v0; +var v1; +var v2; +var v3; +var v4; diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithInterface.symbols b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.symbols new file mode 100644 index 00000000000..29bc3098d91 --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.symbols @@ -0,0 +1,79 @@ +=== tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithInterface.ts === +var v0: T0; +>v0 : Symbol(v0, Decl(circularTypeAliasForUnionWithInterface.ts, 0, 3)) +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithInterface.ts, 0, 11)) + +type T0 = string | I0; +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithInterface.ts, 0, 11)) +>I0 : Symbol(I0, Decl(circularTypeAliasForUnionWithInterface.ts, 1, 22)) + +interface I0 { +>I0 : Symbol(I0, Decl(circularTypeAliasForUnionWithInterface.ts, 1, 22)) + + x: T0; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithInterface.ts, 2, 14)) +>T0 : Symbol(T0, Decl(circularTypeAliasForUnionWithInterface.ts, 0, 11)) +} + +var v1: T1; +>v1 : Symbol(v1, Decl(circularTypeAliasForUnionWithInterface.ts, 6, 3)) +>T1 : Symbol(T1, Decl(circularTypeAliasForUnionWithInterface.ts, 6, 11)) + +type T1 = string | I1; +>T1 : Symbol(T1, Decl(circularTypeAliasForUnionWithInterface.ts, 6, 11)) +>I1 : Symbol(I1, Decl(circularTypeAliasForUnionWithInterface.ts, 7, 22)) + +interface I1 { +>I1 : Symbol(I1, Decl(circularTypeAliasForUnionWithInterface.ts, 7, 22)) + + (): T1; +>T1 : Symbol(T1, Decl(circularTypeAliasForUnionWithInterface.ts, 6, 11)) +} + +var v2: T2; +>v2 : Symbol(v2, Decl(circularTypeAliasForUnionWithInterface.ts, 12, 3)) +>T2 : Symbol(T2, Decl(circularTypeAliasForUnionWithInterface.ts, 12, 11)) + +type T2 = string | I2; +>T2 : Symbol(T2, Decl(circularTypeAliasForUnionWithInterface.ts, 12, 11)) +>I2 : Symbol(I2, Decl(circularTypeAliasForUnionWithInterface.ts, 13, 22)) + +interface I2 { +>I2 : Symbol(I2, Decl(circularTypeAliasForUnionWithInterface.ts, 13, 22)) + + new (): T2; +>T2 : Symbol(T2, Decl(circularTypeAliasForUnionWithInterface.ts, 12, 11)) +} + +var v3: T3; +>v3 : Symbol(v3, Decl(circularTypeAliasForUnionWithInterface.ts, 18, 3)) +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithInterface.ts, 18, 11)) + +type T3 = string | I3; +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithInterface.ts, 18, 11)) +>I3 : Symbol(I3, Decl(circularTypeAliasForUnionWithInterface.ts, 19, 22)) + +interface I3 { +>I3 : Symbol(I3, Decl(circularTypeAliasForUnionWithInterface.ts, 19, 22)) + + [x: number]: T3; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithInterface.ts, 21, 5)) +>T3 : Symbol(T3, Decl(circularTypeAliasForUnionWithInterface.ts, 18, 11)) +} + +var v4: T4; +>v4 : Symbol(v4, Decl(circularTypeAliasForUnionWithInterface.ts, 24, 3)) +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithInterface.ts, 24, 11)) + +type T4 = string | I4; +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithInterface.ts, 24, 11)) +>I4 : Symbol(I4, Decl(circularTypeAliasForUnionWithInterface.ts, 25, 22)) + +interface I4 { +>I4 : Symbol(I4, Decl(circularTypeAliasForUnionWithInterface.ts, 25, 22)) + + [x: string]: T4; +>x : Symbol(x, Decl(circularTypeAliasForUnionWithInterface.ts, 27, 5)) +>T4 : Symbol(T4, Decl(circularTypeAliasForUnionWithInterface.ts, 24, 11)) +} + diff --git a/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types new file mode 100644 index 00000000000..4325f9c774a --- /dev/null +++ b/tests/baselines/reference/circularTypeAliasForUnionWithInterface.types @@ -0,0 +1,79 @@ +=== tests/cases/conformance/types/typeAliases/circularTypeAliasForUnionWithInterface.ts === +var v0: T0; +>v0 : string | I0 +>T0 : string | I0 + +type T0 = string | I0; +>T0 : string | I0 +>I0 : I0 + +interface I0 { +>I0 : I0 + + x: T0; +>x : string | I0 +>T0 : string | I0 +} + +var v1: T1; +>v1 : string | I1 +>T1 : string | I1 + +type T1 = string | I1; +>T1 : string | I1 +>I1 : I1 + +interface I1 { +>I1 : I1 + + (): T1; +>T1 : string | I1 +} + +var v2: T2; +>v2 : string | I2 +>T2 : string | I2 + +type T2 = string | I2; +>T2 : string | I2 +>I2 : I2 + +interface I2 { +>I2 : I2 + + new (): T2; +>T2 : string | I2 +} + +var v3: T3; +>v3 : string | I3 +>T3 : string | I3 + +type T3 = string | I3; +>T3 : string | I3 +>I3 : I3 + +interface I3 { +>I3 : I3 + + [x: number]: T3; +>x : number +>T3 : string | I3 +} + +var v4: T4; +>v4 : string | I4 +>T4 : string | I4 + +type T4 = string | I4; +>T4 : string | I4 +>I4 : I4 + +interface I4 { +>I4 : I4 + + [x: string]: T4; +>x : string +>T4 : string | I4 +} + diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index 3e255398904..754d6199115 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -2,7 +2,8 @@ var v = @decorate class C { static p = 1 }; //// [classExpressionWithDecorator1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/constDeclarations-access5.errors.txt b/tests/baselines/reference/constDeclarations-access5.errors.txt index a098b0e72c6..0669e519093 100644 --- a/tests/baselines/reference/constDeclarations-access5.errors.txt +++ b/tests/baselines/reference/constDeclarations-access5.errors.txt @@ -1,4 +1,4 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant. @@ -20,7 +20,7 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ==== /// import m = require('constDeclarations_access_1'); diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.js b/tests/baselines/reference/decoratedClassFromExternalModule.js index a58eb01a426..da31e7c2f92 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.js +++ b/tests/baselines/reference/decoratedClassFromExternalModule.js @@ -10,7 +10,8 @@ export default class Decorated { } import Decorated from 'decorated'; //// [decorated.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js index cd5c51e7a93..49b2b27ac8b 100644 --- a/tests/baselines/reference/decoratorOnClass1.js +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClass1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index fbd9a106ddf..71ac2358555 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -6,7 +6,8 @@ export class C { } //// [decoratorOnClass2.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index 21536028091..37da7043615 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -7,7 +7,8 @@ class C { } //// [decoratorOnClass3.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js index 5099d16b5b4..e56e427b797 100644 --- a/tests/baselines/reference/decoratorOnClass4.js +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClass4.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js index 0555f618e7e..b415fcf8f9a 100644 --- a/tests/baselines/reference/decoratorOnClass5.js +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClass5.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js index fad73c0c8fc..500cdcf4511 100644 --- a/tests/baselines/reference/decoratorOnClass8.js +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClass8.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js index 68fa7ccec0a..2e0f3520b43 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.js +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js index 17d3e2e422d..a339c3b1663 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.js +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor2.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index 23e689f3114..843a1113255 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor3.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js index 77bcb568fe1..416472ba5ff 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.js +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor4.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js index 37fc33abefd..ba4e20955e9 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.js +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor5.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index 465e13ebb1d..05f0651e1e5 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassAccessor6.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js index a1748a725ba..aa477bcdaef 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -6,14 +6,17 @@ class C { } //// [decoratorOnClassConstructorParameter1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } }; +if (typeof __param !== "function") __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; var C = (function () { function C(p) { } diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js index 9d2b4a690ab..7b7f418ed02 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -6,14 +6,17 @@ class C { } //// [decoratorOnClassConstructorParameter4.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } }; +if (typeof __param !== "function") __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; var C = (function () { function C(public, p) { } diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js index 23be1094305..c2f64cb0639 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.js +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js index f87e3137777..ad934eb6d08 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.js +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod10.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index f8276de2fe3..b55cdf81b24 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -9,7 +9,8 @@ module M { } //// [decoratorOnClassMethod11.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 7f23947929c..4c2c19bd6a5 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -16,7 +16,8 @@ var __extends = this.__extends || function (d, b) { __.prototype = b.prototype; d.prototype = new __(); }; -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod13.js b/tests/baselines/reference/decoratorOnClassMethod13.js index 4321bbb0156..be6d7449ee4 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.js +++ b/tests/baselines/reference/decoratorOnClassMethod13.js @@ -7,7 +7,8 @@ class C { } //// [decoratorOnClassMethod13.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js index 33a22f419d4..7500cebc12d 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.js +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod2.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js index f93b7d7a6b2..54b2ae20d87 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod3.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod4.js b/tests/baselines/reference/decoratorOnClassMethod4.js index 038432f2cf0..7ce4596fc17 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.js +++ b/tests/baselines/reference/decoratorOnClassMethod4.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod4.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod5.js b/tests/baselines/reference/decoratorOnClassMethod5.js index 460c11f145b..9f768816b47 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.js +++ b/tests/baselines/reference/decoratorOnClassMethod5.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod5.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod6.js b/tests/baselines/reference/decoratorOnClassMethod6.js index 9f120599183..064992b1c7a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.js +++ b/tests/baselines/reference/decoratorOnClassMethod6.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod6.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod7.js b/tests/baselines/reference/decoratorOnClassMethod7.js index 6ab01e68bba..8635fe25b6a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.js +++ b/tests/baselines/reference/decoratorOnClassMethod7.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod7.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js index 3e88f8c2793..e63de6d4db3 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.js +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassMethod8.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index d228ed9302b..a81cdaa19c8 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -6,14 +6,17 @@ class C { } //// [decoratorOnClassMethodParameter1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; -var __param = this.__param || function(index, decorator) { return function (target, key) { decorator(target, key, index); } }; +if (typeof __param !== "function") __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; var C = (function () { function C() { } diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js index aa38252b995..23e5eec1cc0 100644 --- a/tests/baselines/reference/decoratorOnClassProperty1.js +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty1.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js index bccbc0bb737..b3848e73d57 100644 --- a/tests/baselines/reference/decoratorOnClassProperty10.js +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty10.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js index f31e40d3c40..72ad6f276de 100644 --- a/tests/baselines/reference/decoratorOnClassProperty11.js +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty11.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js index 477320b40fa..72fb1bcb331 100644 --- a/tests/baselines/reference/decoratorOnClassProperty2.js +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty2.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js index 05476c66e7d..af72503b914 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.js +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty3.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js index 46e2d5fc069..a8621e253e8 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.js +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty6.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js index 14ca0612cb1..6c7b3292235 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.js +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -6,7 +6,8 @@ class C { } //// [decoratorOnClassProperty7.js] -var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) { +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); diff --git a/tests/baselines/reference/es5-umd.js b/tests/baselines/reference/es5-umd.js new file mode 100644 index 00000000000..0175e8e9fe8 --- /dev/null +++ b/tests/baselines/reference/es5-umd.js @@ -0,0 +1,32 @@ +//// [es5-umd.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5-umd.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +//# sourceMappingURL=es5-umd.js.map + +//// [es5-umd.d.ts] +declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es5-umd.js.map b/tests/baselines/reference/es5-umd.js.map new file mode 100644 index 00000000000..5e29a48796e --- /dev/null +++ b/tests/baselines/reference/es5-umd.js.map @@ -0,0 +1,2 @@ +//// [es5-umd.js.map] +{"version":3,"file":"es5-umd.js","sourceRoot":"","sources":["es5-umd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd.sourcemap.txt b/tests/baselines/reference/es5-umd.sourcemap.txt new file mode 100644 index 00000000000..bdbdec5fa9e --- /dev/null +++ b/tests/baselines/reference/es5-umd.sourcemap.txt @@ -0,0 +1,115 @@ +=================================================================== +JsFile: es5-umd.js +mapUrl: es5-umd.js.map +sourceRoot: +sources: es5-umd.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es5-umd.js +sourceFile:es5-umd.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1->class A + >{ + > +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +--- +>>>//# sourceMappingURL=es5-umd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd.symbols b/tests/baselines/reference/es5-umd.symbols new file mode 100644 index 00000000000..f570afd9548 --- /dev/null +++ b/tests/baselines/reference/es5-umd.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es5-umd.ts === + +class A +>A : Symbol(A, Decl(es5-umd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-umd.ts, 6, 5)) + { + return 42; + } +} + diff --git a/tests/baselines/reference/es5-umd.types b/tests/baselines/reference/es5-umd.types new file mode 100644 index 00000000000..60987d429e0 --- /dev/null +++ b/tests/baselines/reference/es5-umd.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es5-umd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + diff --git a/tests/baselines/reference/es5-umd2.js b/tests/baselines/reference/es5-umd2.js new file mode 100644 index 00000000000..cb0265bf92f --- /dev/null +++ b/tests/baselines/reference/es5-umd2.js @@ -0,0 +1,42 @@ +//// [es5-umd2.ts] + +export class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5-umd2.js] +(function (deps, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(deps, factory); + } +})(["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; + })(); + exports.A = A; +}); +//# sourceMappingURL=es5-umd2.js.map + +//// [es5-umd2.d.ts] +export declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es5-umd2.js.map b/tests/baselines/reference/es5-umd2.js.map new file mode 100644 index 00000000000..13a785b2edc --- /dev/null +++ b/tests/baselines/reference/es5-umd2.js.map @@ -0,0 +1,2 @@ +//// [es5-umd2.js.map] +{"version":3,"file":"es5-umd2.js","sourceRoot":"","sources":["es5-umd2.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAXY,SAAC,IAWb,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd2.sourcemap.txt b/tests/baselines/reference/es5-umd2.sourcemap.txt new file mode 100644 index 00000000000..bfadd9615f3 --- /dev/null +++ b/tests/baselines/reference/es5-umd2.sourcemap.txt @@ -0,0 +1,149 @@ +=================================================================== +JsFile: es5-umd2.js +mapUrl: es5-umd2.js.map +sourceRoot: +sources: es5-umd2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es5-umd2.js +sourceFile:es5-umd2.ts +------------------------------------------------------------------- +>>>(function (deps, factory) { +>>> if (typeof module === 'object' && typeof module.exports === 'object') { +>>> var v = factory(require, exports); if (v !== undefined) module.exports = v; +>>> } +>>> else if (typeof define === 'function' && define.amd) { +>>> define(deps, factory); +>>> } +>>>})(["require", "exports"], function (require, exports) { +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1->export class A + >{ + > +1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) +--- +>>> exports.A = A; +1->^^^^ +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +1-> +2 > A +3 > + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +4 > +1->Emitted(17, 5) Source(2, 14) + SourceIndex(0) +2 >Emitted(17, 14) Source(2, 15) + SourceIndex(0) +3 >Emitted(17, 18) Source(13, 2) + SourceIndex(0) +4 >Emitted(17, 19) Source(13, 2) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=es5-umd2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd2.symbols b/tests/baselines/reference/es5-umd2.symbols new file mode 100644 index 00000000000..3b911d7e6f0 --- /dev/null +++ b/tests/baselines/reference/es5-umd2.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es5-umd2.ts === + +export class A +>A : Symbol(A, Decl(es5-umd2.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-umd2.ts, 6, 5)) + { + return 42; + } +} + diff --git a/tests/baselines/reference/es5-umd2.types b/tests/baselines/reference/es5-umd2.types new file mode 100644 index 00000000000..fab4e9dfc01 --- /dev/null +++ b/tests/baselines/reference/es5-umd2.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es5-umd2.ts === + +export class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js new file mode 100644 index 00000000000..2d18e2eecc3 --- /dev/null +++ b/tests/baselines/reference/es5-umd3.js @@ -0,0 +1,42 @@ +//// [es5-umd3.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5-umd3.js] +(function (deps, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(deps, factory); + } +})(["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; + })(); + exports.default = A; +}); +//# sourceMappingURL=es5-umd3.js.map + +//// [es5-umd3.d.ts] +export default class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es5-umd3.js.map b/tests/baselines/reference/es5-umd3.js.map new file mode 100644 index 00000000000..8b955f11936 --- /dev/null +++ b/tests/baselines/reference/es5-umd3.js.map @@ -0,0 +1,2 @@ +//// [es5-umd3.js.map] +{"version":3,"file":"es5-umd3.js","sourceRoot":"","sources":["es5-umd3.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAXD,mBAWC,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd3.sourcemap.txt b/tests/baselines/reference/es5-umd3.sourcemap.txt new file mode 100644 index 00000000000..afb879ac713 --- /dev/null +++ b/tests/baselines/reference/es5-umd3.sourcemap.txt @@ -0,0 +1,146 @@ +=================================================================== +JsFile: es5-umd3.js +mapUrl: es5-umd3.js.map +sourceRoot: +sources: es5-umd3.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es5-umd3.js +sourceFile:es5-umd3.ts +------------------------------------------------------------------- +>>>(function (deps, factory) { +>>> if (typeof module === 'object' && typeof module.exports === 'object') { +>>> var v = factory(require, exports); if (v !== undefined) module.exports = v; +>>> } +>>> else if (typeof define === 'function' && define.amd) { +>>> define(deps, factory); +>>> } +>>>})(["require", "exports"], function (require, exports) { +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1->export default class A + >{ + > +1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^-> +1 > +2 > } +3 > +4 > export default class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) +--- +>>> exports.default = A; +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +1-> +2 > export default class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +3 > +1->Emitted(17, 5) Source(2, 1) + SourceIndex(0) +2 >Emitted(17, 24) Source(13, 2) + SourceIndex(0) +3 >Emitted(17, 25) Source(13, 2) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=es5-umd3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd3.symbols b/tests/baselines/reference/es5-umd3.symbols new file mode 100644 index 00000000000..3f830ae3637 --- /dev/null +++ b/tests/baselines/reference/es5-umd3.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es5-umd3.ts === + +export default class A +>A : Symbol(A, Decl(es5-umd3.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-umd3.ts, 6, 5)) + { + return 42; + } +} + diff --git a/tests/baselines/reference/es5-umd3.types b/tests/baselines/reference/es5-umd3.types new file mode 100644 index 00000000000..b4b5f0dc366 --- /dev/null +++ b/tests/baselines/reference/es5-umd3.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es5-umd3.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + diff --git a/tests/baselines/reference/es5-umd4.js b/tests/baselines/reference/es5-umd4.js new file mode 100644 index 00000000000..85683f8f3c2 --- /dev/null +++ b/tests/baselines/reference/es5-umd4.js @@ -0,0 +1,45 @@ +//// [es5-umd4.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +export = A; + + +//// [es5-umd4.js] +(function (deps, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(deps, factory); + } +})(["require", "exports"], function (require, exports) { + var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; + })(); + return A; +}); +//# sourceMappingURL=es5-umd4.js.map + +//// [es5-umd4.d.ts] +declare class A { + constructor(); + B(): number; +} +export = A; diff --git a/tests/baselines/reference/es5-umd4.js.map b/tests/baselines/reference/es5-umd4.js.map new file mode 100644 index 00000000000..0a47d679ed9 --- /dev/null +++ b/tests/baselines/reference/es5-umd4.js.map @@ -0,0 +1,2 @@ +//// [es5-umd4.js.map] +{"version":3,"file":"es5-umd4.js","sourceRoot":"","sources":["es5-umd4.ts"],"names":["A","A.constructor","A.B"],"mappings":";;;;;;;;IACA;QAEIA;QAGAC,CAACA;QAEMD,aAACA,GAARA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;QACLF,QAACA;IAADA,CAACA,AAXD,IAWC;IAEU,AAAX,OAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd4.sourcemap.txt b/tests/baselines/reference/es5-umd4.sourcemap.txt new file mode 100644 index 00000000000..9afd8effecf --- /dev/null +++ b/tests/baselines/reference/es5-umd4.sourcemap.txt @@ -0,0 +1,143 @@ +=================================================================== +JsFile: es5-umd4.js +mapUrl: es5-umd4.js.map +sourceRoot: +sources: es5-umd4.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es5-umd4.js +sourceFile:es5-umd4.ts +------------------------------------------------------------------- +>>>(function (deps, factory) { +>>> if (typeof module === 'object' && typeof module.exports === 'object') { +>>> var v = factory(require, exports); if (v !== undefined) module.exports = v; +>>> } +>>> else if (typeof define === 'function' && define.amd) { +>>> define(deps, factory); +>>> } +>>>})(["require", "exports"], function (require, exports) { +>>> var A = (function () { +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(9, 5) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^^^^^ +2 > ^^-> +1->class A + >{ + > +1->Emitted(10, 9) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(11, 9) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(11, 10) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> A.prototype.B = function () { +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^ +3 > ^^^ +1-> + > + > public +2 > B +3 > +1->Emitted(12, 9) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(12, 22) Source(9, 13) + SourceIndex(0) name (A) +3 >Emitted(12, 25) Source(9, 5) + SourceIndex(0) name (A) +--- +>>> return 42; +1 >^^^^^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1 >public B() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1 >Emitted(13, 13) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(13, 19) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(13, 20) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(13, 22) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(13, 23) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> }; +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1 > + > +2 > } +1 >Emitted(14, 9) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(14, 10) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>> return A; +1->^^^^^^^^ +2 > ^^^^^^^^ +1-> + > +2 > } +1->Emitted(15, 9) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(15, 17) Source(13, 2) + SourceIndex(0) name (A) +--- +>>> })(); +1 >^^^^ +2 > ^ +3 > +4 > ^^^^ +5 > ^^^^^-> +1 > +2 > } +3 > +4 > class A + > { + > constructor () + > { + > + > } + > + > public B() + > { + > return 42; + > } + > } +1 >Emitted(16, 5) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(16, 6) Source(13, 2) + SourceIndex(0) name (A) +3 >Emitted(16, 6) Source(2, 1) + SourceIndex(0) +4 >Emitted(16, 10) Source(13, 2) + SourceIndex(0) +--- +>>> return A; +1->^^^^ +2 > +3 > ^^^^^^^ +4 > ^ +5 > ^ +1-> + > + >export = A; +2 > +3 > export = +4 > A +5 > ; +1->Emitted(17, 5) Source(15, 12) + SourceIndex(0) +2 >Emitted(17, 5) Source(15, 1) + SourceIndex(0) +3 >Emitted(17, 12) Source(15, 10) + SourceIndex(0) +4 >Emitted(17, 13) Source(15, 11) + SourceIndex(0) +5 >Emitted(17, 14) Source(15, 12) + SourceIndex(0) +--- +>>>}); +>>>//# sourceMappingURL=es5-umd4.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es5-umd4.symbols b/tests/baselines/reference/es5-umd4.symbols new file mode 100644 index 00000000000..cdf1e135cf7 --- /dev/null +++ b/tests/baselines/reference/es5-umd4.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/es5-umd4.ts === + +class A +>A : Symbol(A, Decl(es5-umd4.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es5-umd4.ts, 6, 5)) + { + return 42; + } +} + +export = A; +>A : Symbol(A, Decl(es5-umd4.ts, 0, 0)) + diff --git a/tests/baselines/reference/es5-umd4.types b/tests/baselines/reference/es5-umd4.types new file mode 100644 index 00000000000..59d23e6bd8d --- /dev/null +++ b/tests/baselines/reference/es5-umd4.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/es5-umd4.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} + +export = A; +>A : A + diff --git a/tests/baselines/reference/es6-amd.errors.txt b/tests/baselines/reference/es6-amd.errors.txt index cb1ef4b1287..4dc8610ad13 100644 --- a/tests/baselines/reference/es6-amd.errors.txt +++ b/tests/baselines/reference/es6-amd.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6-amd.ts (0 errors) ==== class A diff --git a/tests/baselines/reference/es6-declaration-amd.errors.txt b/tests/baselines/reference/es6-declaration-amd.errors.txt index 18319504dc9..28e26bc6a98 100644 --- a/tests/baselines/reference/es6-declaration-amd.errors.txt +++ b/tests/baselines/reference/es6-declaration-amd.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ==== class A diff --git a/tests/baselines/reference/es6-sourcemap-amd.errors.txt b/tests/baselines/reference/es6-sourcemap-amd.errors.txt index 24a83f8ee12..aa29c54f6bc 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.errors.txt +++ b/tests/baselines/reference/es6-sourcemap-amd.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ==== class A diff --git a/tests/baselines/reference/es6-umd.errors.txt b/tests/baselines/reference/es6-umd.errors.txt new file mode 100644 index 00000000000..49d59b714e4 --- /dev/null +++ b/tests/baselines/reference/es6-umd.errors.txt @@ -0,0 +1,18 @@ +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. + + +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. +==== tests/cases/compiler/es6-umd.ts (0 errors) ==== + + class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.js b/tests/baselines/reference/es6-umd.js new file mode 100644 index 00000000000..74cd671f5ef --- /dev/null +++ b/tests/baselines/reference/es6-umd.js @@ -0,0 +1,30 @@ +//// [es6-umd.ts] + +class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6-umd.js] +class A { + constructor() { + } + B() { + return 42; + } +} +//# sourceMappingURL=es6-umd.js.map + +//// [es6-umd.d.ts] +declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es6-umd.js.map b/tests/baselines/reference/es6-umd.js.map new file mode 100644 index 00000000000..a5e82f7ccfd --- /dev/null +++ b/tests/baselines/reference/es6-umd.js.map @@ -0,0 +1,2 @@ +//// [es6-umd.js.map] +{"version":3,"file":"es6-umd.js","sourceRoot":"","sources":["es6-umd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.sourcemap.txt b/tests/baselines/reference/es6-umd.sourcemap.txt new file mode 100644 index 00000000000..bb8281ce741 --- /dev/null +++ b/tests/baselines/reference/es6-umd.sourcemap.txt @@ -0,0 +1,91 @@ +=================================================================== +JsFile: es6-umd.js +mapUrl: es6-umd.js.map +sourceRoot: +sources: es6-umd.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es6-umd.js +sourceFile:es6-umd.ts +------------------------------------------------------------------- +>>>class A { +1 > +2 >^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> constructor() { +1->^^^^ +2 > ^^-> +1->class A + >{ + > +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> B() { +1->^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> +1-> + > + > public +2 > B +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) +--- +>>> return 42; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1->() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> } +1 >^^^^ +2 > ^ +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>//# sourceMappingURL=es6-umd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.errors.txt b/tests/baselines/reference/es6-umd2.errors.txt new file mode 100644 index 00000000000..b4f2ea4d5be --- /dev/null +++ b/tests/baselines/reference/es6-umd2.errors.txt @@ -0,0 +1,18 @@ +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. + + +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. +==== tests/cases/compiler/es6-umd2.ts (0 errors) ==== + + export class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js new file mode 100644 index 00000000000..b12d35aacf8 --- /dev/null +++ b/tests/baselines/reference/es6-umd2.js @@ -0,0 +1,30 @@ +//// [es6-umd2.ts] + +export class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6-umd2.js] +export class A { + constructor() { + } + B() { + return 42; + } +} +//# sourceMappingURL=es6-umd2.js.map + +//// [es6-umd2.d.ts] +export declare class A { + constructor(); + B(): number; +} diff --git a/tests/baselines/reference/es6-umd2.js.map b/tests/baselines/reference/es6-umd2.js.map new file mode 100644 index 00000000000..81f3d85a6cd --- /dev/null +++ b/tests/baselines/reference/es6-umd2.js.map @@ -0,0 +1,2 @@ +//// [es6-umd2.js.map] +{"version":3,"file":"es6-umd2.js","sourceRoot":"","sources":["es6-umd2.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.sourcemap.txt b/tests/baselines/reference/es6-umd2.sourcemap.txt new file mode 100644 index 00000000000..d032aa3d6c7 --- /dev/null +++ b/tests/baselines/reference/es6-umd2.sourcemap.txt @@ -0,0 +1,91 @@ +=================================================================== +JsFile: es6-umd2.js +mapUrl: es6-umd2.js.map +sourceRoot: +sources: es6-umd2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/es6-umd2.js +sourceFile:es6-umd2.ts +------------------------------------------------------------------- +>>>export class A { +1 > +2 >^^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> constructor() { +1->^^^^ +2 > ^^-> +1->export class A + >{ + > +1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^-> +1->constructor () + > { + > + > +2 > } +1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) +--- +>>> B() { +1->^^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> +1-> + > + > public +2 > B +1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) +--- +>>> return 42; +1->^^^^^^^^ +2 > ^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +1->() + > { + > +2 > return +3 > +4 > 42 +5 > ; +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) +3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) +4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) +5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) +--- +>>> } +1 >^^^^ +2 > ^ +1 > + > +2 > } +1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) +2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) +--- +>>>} +1 > +2 >^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > +2 >} +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) +--- +>>>//# sourceMappingURL=es6-umd2.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt index 34bb303a571..00f71bd0478 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ==== export var a = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt index 635bb955c00..1b0834aa146 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt +++ b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ==== export var a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImport.errors.txt b/tests/baselines/reference/es6ImportNamedImport.errors.txt index 5723b5c20d4..b61b377cfb2 100644 --- a/tests/baselines/reference/es6ImportNamedImport.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImport.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ==== export var a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt index 41d3f160938..aaf36b8495b 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt @@ -1,8 +1,8 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ==== export var a = 10; diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt index bbe0d8b78b6..f48ff298d6a 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ==== export class A { diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt index 87f53cb7810..b6f160f11c8 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt @@ -1,7 +1,7 @@ -error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher. +!!! error TS1204: Cannot compile external modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. ==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ==== export class A { diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js new file mode 100644 index 00000000000..4b1564b5ab2 --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImportsWithContextualKeywordNames01.ts] //// + +//// [t1.ts] + +let set = { + set foo(x: number) { + } +} +let get = 10; + +export { set, get }; + +//// [t2.ts] +import * as set from "./t1"; + +//// [t3.ts] +import { set as yield } from "./t1"; + +//// [t4.ts] +import { get } from "./t1"; + +//// [t1.js] +var set = { + set foo(x) { + } +}; +exports.set = set; +var get = 10; +exports.get = get; +//// [t2.js] +//// [t3.js] +//// [t4.js] diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols new file mode 100644 index 00000000000..f6695a9cf37 --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +let set = { +>set : Symbol(set, Decl(t1.ts, 1, 3)) + + set foo(x: number) { +>foo : Symbol(foo, Decl(t1.ts, 1, 11)) +>x : Symbol(x, Decl(t1.ts, 2, 12)) + } +} +let get = 10; +>get : Symbol(get, Decl(t1.ts, 5, 3)) + +export { set, get }; +>set : Symbol(set, Decl(t1.ts, 7, 8)) +>get : Symbol(get, Decl(t1.ts, 7, 13)) + +=== tests/cases/conformance/es6/modules/t2.ts === +import * as set from "./t1"; +>set : Symbol(set, Decl(t2.ts, 0, 6)) + +=== tests/cases/conformance/es6/modules/t3.ts === +import { set as yield } from "./t1"; +>set : Symbol(yield, Decl(t3.ts, 0, 8)) +>yield : Symbol(yield, Decl(t3.ts, 0, 8)) + +=== tests/cases/conformance/es6/modules/t4.ts === +import { get } from "./t1"; +>get : Symbol(get, Decl(t4.ts, 0, 8)) + diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types new file mode 100644 index 00000000000..a687787c462 --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames01.types @@ -0,0 +1,32 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +let set = { +>set : { foo: number; } +>{ set foo(x: number) { }} : { foo: number; } + + set foo(x: number) { +>foo : number +>x : number + } +} +let get = 10; +>get : number +>10 : number + +export { set, get }; +>set : { foo: number; } +>get : number + +=== tests/cases/conformance/es6/modules/t2.ts === +import * as set from "./t1"; +>set : typeof set + +=== tests/cases/conformance/es6/modules/t3.ts === +import { set as yield } from "./t1"; +>set : { foo: number; } +>yield : { foo: number; } + +=== tests/cases/conformance/es6/modules/t4.ts === +import { get } from "./t1"; +>get : number + diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js new file mode 100644 index 00000000000..e9a0b45446f --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/es6/modules/exportsAndImportsWithContextualKeywordNames02.ts] //// + +//// [t1.ts] + +let as = 100; + +export { as as return, as }; + +//// [t2.ts] +import * as as from "./t1"; +var x = as.as; +var y = as.return; + +//// [t3.ts] +import { as as as } from "./t1"; + +//// [t4.ts] +import { as } from "./t1"; + +//// [t1.js] +var as = 100; +exports.return = as; +exports.as = as; +//// [t2.js] +var as = require("./t1"); +var x = as.as; +var y = as.return; +//// [t3.js] +//// [t4.js] diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.symbols b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.symbols new file mode 100644 index 00000000000..4bc53e9d4b6 --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +let as = 100; +>as : Symbol(as, Decl(t1.ts, 1, 3)) + +export { as as return, as }; +>as : Symbol(return, Decl(t1.ts, 3, 8)) +>return : Symbol(return, Decl(t1.ts, 3, 8)) +>as : Symbol(as, Decl(t1.ts, 3, 22)) + +=== tests/cases/conformance/es6/modules/t2.ts === +import * as as from "./t1"; +>as : Symbol(as, Decl(t2.ts, 0, 6)) + +var x = as.as; +>x : Symbol(x, Decl(t2.ts, 1, 3)) +>as.as : Symbol(as.as, Decl(t1.ts, 3, 22)) +>as : Symbol(as, Decl(t2.ts, 0, 6)) +>as : Symbol(as.as, Decl(t1.ts, 3, 22)) + +var y = as.return; +>y : Symbol(y, Decl(t2.ts, 2, 3)) +>as.return : Symbol(as.return, Decl(t1.ts, 3, 8)) +>as : Symbol(as, Decl(t2.ts, 0, 6)) +>return : Symbol(as.return, Decl(t1.ts, 3, 8)) + +=== tests/cases/conformance/es6/modules/t3.ts === +import { as as as } from "./t1"; +>as : Symbol(as, Decl(t3.ts, 0, 8)) +>as : Symbol(as, Decl(t3.ts, 0, 8)) + +=== tests/cases/conformance/es6/modules/t4.ts === +import { as } from "./t1"; +>as : Symbol(as, Decl(t4.ts, 0, 8)) + diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types new file mode 100644 index 00000000000..853fa787f0a --- /dev/null +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/es6/modules/t1.ts === + +let as = 100; +>as : number +>100 : number + +export { as as return, as }; +>as : number +>return : number +>as : number + +=== tests/cases/conformance/es6/modules/t2.ts === +import * as as from "./t1"; +>as : typeof as + +var x = as.as; +>x : number +>as.as : number +>as : typeof as +>as : number + +var y = as.return; +>y : number +>as.return : number +>as : typeof as +>return : number + +=== tests/cases/conformance/es6/modules/t3.ts === +import { as as as } from "./t1"; +>as : number +>as : number + +=== tests/cases/conformance/es6/modules/t4.ts === +import { as } from "./t1"; +>as : number + diff --git a/tests/baselines/reference/for-of31.errors.txt b/tests/baselines/reference/for-of31.errors.txt index 74afff00e99..6d5f6e816be 100644 --- a/tests/baselines/reference/for-of31.errors.txt +++ b/tests/baselines/reference/for-of31.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty Type '() => StringIterator' is not assignable to type '() => Iterator'. Type 'StringIterator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '() => { value: string; }' is not assignable to type '() => IteratorResult'. + Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. Type '{ value: string; }' is not assignable to type 'IteratorResult'. Property 'done' is missing in type '{ value: string; }'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty !!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. !!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: string; }' is not assignable to type '() => IteratorResult'. +!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. !!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. !!! error TS2322: Property 'done' is missing in type '{ value: string; }'. diff --git a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt index e0e3d061f16..90b8bdbeb46 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 Type '() => SymbolIterator' is not assignable to type '() => Iterator'. Type 'SymbolIterator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '() => { value: symbol; }' is not assignable to type '() => IteratorResult'. + Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. Property 'done' is missing in type '{ value: symbol; }'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 !!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. !!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '() => IteratorResult'. +!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. !!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. !!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'. diff --git a/tests/baselines/reference/missingDecoratorType.errors.txt b/tests/baselines/reference/missingDecoratorType.errors.txt new file mode 100644 index 00000000000..0b159a8fcb2 --- /dev/null +++ b/tests/baselines/reference/missingDecoratorType.errors.txt @@ -0,0 +1,23 @@ +error TS2318: Cannot find global type 'ClassDecorator'. + + +!!! error TS2318: Cannot find global type 'ClassDecorator'. +==== tests/cases/conformance/decorators/a.ts (0 errors) ==== + + interface Object { } + interface Array { } + interface String { } + interface Boolean { } + interface Number { } + interface Function { } + interface RegExp { } + interface IArguments { } + +==== tests/cases/conformance/decorators/b.ts (0 errors) ==== + declare var dec: any; + + @dec + class C { + } + + \ No newline at end of file diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js new file mode 100644 index 00000000000..974c884ecd1 --- /dev/null +++ b/tests/baselines/reference/missingDecoratorType.js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/decorators/missingDecoratorType.ts] //// + +//// [a.ts] + +interface Object { } +interface Array { } +interface String { } +interface Boolean { } +interface Number { } +interface Function { } +interface RegExp { } +interface IArguments { } + +//// [b.ts] +declare var dec: any; + +@dec +class C { +} + + + +//// [a.js] +//// [b.js] +if (typeof __decorate !== "function") __decorate = function (decorators, target, key, desc) { + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); + switch (arguments.length) { + case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); + case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); + case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); + } +}; +var C = (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +})(); diff --git a/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.js b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.js new file mode 100644 index 00000000000..6a7041a6733 --- /dev/null +++ b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.js @@ -0,0 +1,25 @@ +//// [nameCollisionWithBlockScopedVariable1.ts] +module M { + export class C { } +} +module M { + { + let M = 0; + new C(); + } +} + +//// [nameCollisionWithBlockScopedVariable1.js] +var M; +(function (M) { + class C { + } + M.C = C; +})(M || (M = {})); +var M; +(function (M_1) { + { + let M = 0; + new M_1.C(); + } +})(M || (M = {})); diff --git a/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.symbols b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.symbols new file mode 100644 index 00000000000..9c0d01bd8e9 --- /dev/null +++ b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/nameCollisionWithBlockScopedVariable1.ts === +module M { +>M : Symbol(M, Decl(nameCollisionWithBlockScopedVariable1.ts, 0, 0), Decl(nameCollisionWithBlockScopedVariable1.ts, 2, 1)) + + export class C { } +>C : Symbol(C, Decl(nameCollisionWithBlockScopedVariable1.ts, 0, 10)) +} +module M { +>M : Symbol(M, Decl(nameCollisionWithBlockScopedVariable1.ts, 0, 0), Decl(nameCollisionWithBlockScopedVariable1.ts, 2, 1)) + { + let M = 0; +>M : Symbol(M, Decl(nameCollisionWithBlockScopedVariable1.ts, 5, 11)) + + new C(); +>C : Symbol(C, Decl(nameCollisionWithBlockScopedVariable1.ts, 0, 10)) + } +} diff --git a/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types new file mode 100644 index 00000000000..7a3c07af187 --- /dev/null +++ b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/nameCollisionWithBlockScopedVariable1.ts === +module M { +>M : typeof M + + export class C { } +>C : C +} +module M { +>M : typeof M + { + let M = 0; +>M : number +>0 : number + + new C(); +>new C() : C +>C : typeof C + } +} diff --git a/tests/baselines/reference/noDefaultLib.errors.txt b/tests/baselines/reference/noDefaultLib.errors.txt index c73f3e0b948..b8f42ba7c33 100644 --- a/tests/baselines/reference/noDefaultLib.errors.txt +++ b/tests/baselines/reference/noDefaultLib.errors.txt @@ -1,19 +1,9 @@ -error TS2318: Cannot find global type 'TypedPropertyDescriptor'. -error TS2318: Cannot find global type 'PropertyDecorator'. -error TS2318: Cannot find global type 'ParameterDecorator'. -error TS2318: Cannot find global type 'MethodDecorator'. error TS2318: Cannot find global type 'IArguments'. -error TS2318: Cannot find global type 'ClassDecorator'. error TS2318: Cannot find global type 'Boolean'. tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s). -!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'. -!!! error TS2318: Cannot find global type 'PropertyDecorator'. -!!! error TS2318: Cannot find global type 'ParameterDecorator'. -!!! error TS2318: Cannot find global type 'MethodDecorator'. !!! error TS2318: Cannot find global type 'IArguments'. -!!! error TS2318: Cannot find global type 'ClassDecorator'. !!! error TS2318: Cannot find global type 'Boolean'. ==== tests/cases/compiler/noDefaultLib.ts (1 errors) ==== /// diff --git a/tests/baselines/reference/parser509698.errors.txt b/tests/baselines/reference/parser509698.errors.txt index 3dd70275e5c..85485dd6501 100644 --- a/tests/baselines/reference/parser509698.errors.txt +++ b/tests/baselines/reference/parser509698.errors.txt @@ -1,31 +1,21 @@ -error TS2318: Cannot find global type 'Number'. -error TS2318: Cannot find global type 'TypedPropertyDescriptor'. -error TS2318: Cannot find global type 'Object'. -error TS2318: Cannot find global type 'Array'. -error TS2318: Cannot find global type 'ClassDecorator'. error TS2318: Cannot find global type 'String'. error TS2318: Cannot find global type 'RegExp'. -error TS2318: Cannot find global type 'PropertyDecorator'. -error TS2318: Cannot find global type 'ParameterDecorator'. +error TS2318: Cannot find global type 'Object'. +error TS2318: Cannot find global type 'Number'. +error TS2318: Cannot find global type 'IArguments'. error TS2318: Cannot find global type 'Function'. error TS2318: Cannot find global type 'Boolean'. -error TS2318: Cannot find global type 'MethodDecorator'. -error TS2318: Cannot find global type 'IArguments'. +error TS2318: Cannot find global type 'Array'. -!!! error TS2318: Cannot find global type 'Number'. -!!! error TS2318: Cannot find global type 'TypedPropertyDescriptor'. -!!! error TS2318: Cannot find global type 'Object'. -!!! error TS2318: Cannot find global type 'Array'. -!!! error TS2318: Cannot find global type 'ClassDecorator'. !!! error TS2318: Cannot find global type 'String'. !!! error TS2318: Cannot find global type 'RegExp'. -!!! error TS2318: Cannot find global type 'PropertyDecorator'. -!!! error TS2318: Cannot find global type 'ParameterDecorator'. +!!! error TS2318: Cannot find global type 'Object'. +!!! error TS2318: Cannot find global type 'Number'. +!!! error TS2318: Cannot find global type 'IArguments'. !!! error TS2318: Cannot find global type 'Function'. !!! error TS2318: Cannot find global type 'Boolean'. -!!! error TS2318: Cannot find global type 'MethodDecorator'. -!!! error TS2318: Cannot find global type 'IArguments'. +!!! error TS2318: Cannot find global type 'Array'. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ==== ///