diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea44fb0f3bd74..a5d2c717a05ef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7123,6 +7123,15 @@ namespace ts { let stringIndexInfo: IndexInfo | undefined; if (symbol.exports) { members = getExportsOfSymbol(symbol); + if (symbol === globalThisSymbol) { + const varsOnly = createMap() as SymbolTable; + members.forEach(p => { + if (!(p.flags & SymbolFlags.BlockScoped)) { + varsOnly.set(p.escapedName, p); + } + }); + members = varsOnly; + } } setStructuredTypeMembers(type, members, emptyArray, emptyArray, undefined, undefined); if (symbol.flags & SymbolFlags.Class) { @@ -9880,6 +9889,7 @@ namespace ts { getNodeLinks(accessNode!).resolvedSymbol = prop; } } + const propType = getTypeOfSymbol(prop); return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ? getFlowTypeOfReference(accessExpression, propType) : @@ -9923,7 +9933,10 @@ namespace ts { return anyType; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports!.has(propName) && (globalThisSymbol.exports!.get(propName)!.flags & SymbolFlags.BlockScoped)) { + error(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(propName), typeToString(objectType)); + } + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { error(accessExpression, Diagnostics.Property_0_is_a_static_member_of_type_1, propName as string, typeToString(objectType)); } @@ -19518,7 +19531,10 @@ namespace ts { return anyType; } if (leftType.symbol === globalThisSymbol) { - if (noImplicitAny) { + if (globalThisSymbol.exports!.has(right.escapedText) && (globalThisSymbol.exports!.get(right.escapedText)!.flags & SymbolFlags.BlockScoped)) { + error(right, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); + } + else if (noImplicitAny) { error(right, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType)); } return anyType; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c41418cbbb04a..089a2630dd8c6 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4425,7 +4425,7 @@ namespace FourSlashInterface { } export namespace Completion { const functionEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "function", kindModifiers: "declare" }); - const constEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "const", kindModifiers: "declare" }); + const varEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "var", kindModifiers: "declare" }); const moduleEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "module", kindModifiers: "declare" }); const keywordEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "keyword" }); const methodEntry = (name: string): ExpectedCompletionEntryObject => ({ name, kind: "method", kindModifiers: "declare" }); @@ -4448,48 +4448,48 @@ namespace FourSlashInterface { typeEntry("PropertyKey"), interfaceEntry("PropertyDescriptor"), interfaceEntry("PropertyDescriptorMap"), - constEntry("Object"), + varEntry("Object"), interfaceEntry("ObjectConstructor"), - constEntry("Function"), + varEntry("Function"), interfaceEntry("FunctionConstructor"), typeEntry("ThisParameterType"), typeEntry("OmitThisParameter"), interfaceEntry("CallableFunction"), interfaceEntry("NewableFunction"), interfaceEntry("IArguments"), - constEntry("String"), + varEntry("String"), interfaceEntry("StringConstructor"), - constEntry("Boolean"), + varEntry("Boolean"), interfaceEntry("BooleanConstructor"), - constEntry("Number"), + varEntry("Number"), interfaceEntry("NumberConstructor"), interfaceEntry("TemplateStringsArray"), interfaceEntry("ImportMeta"), - constEntry("Math"), - constEntry("Date"), + varEntry("Math"), + varEntry("Date"), interfaceEntry("DateConstructor"), interfaceEntry("RegExpMatchArray"), interfaceEntry("RegExpExecArray"), - constEntry("RegExp"), + varEntry("RegExp"), interfaceEntry("RegExpConstructor"), - constEntry("Error"), + varEntry("Error"), interfaceEntry("ErrorConstructor"), - constEntry("EvalError"), + varEntry("EvalError"), interfaceEntry("EvalErrorConstructor"), - constEntry("RangeError"), + varEntry("RangeError"), interfaceEntry("RangeErrorConstructor"), - constEntry("ReferenceError"), + varEntry("ReferenceError"), interfaceEntry("ReferenceErrorConstructor"), - constEntry("SyntaxError"), + varEntry("SyntaxError"), interfaceEntry("SyntaxErrorConstructor"), - constEntry("TypeError"), + varEntry("TypeError"), interfaceEntry("TypeErrorConstructor"), - constEntry("URIError"), + varEntry("URIError"), interfaceEntry("URIErrorConstructor"), - constEntry("JSON"), + varEntry("JSON"), interfaceEntry("ReadonlyArray"), interfaceEntry("ConcatArray"), - constEntry("Array"), + varEntry("Array"), interfaceEntry("ArrayConstructor"), interfaceEntry("TypedPropertyDescriptor"), typeEntry("ClassDecorator"), @@ -4513,30 +4513,30 @@ namespace FourSlashInterface { typeEntry("ReturnType"), typeEntry("InstanceType"), interfaceEntry("ThisType"), - constEntry("ArrayBuffer"), + varEntry("ArrayBuffer"), interfaceEntry("ArrayBufferTypes"), typeEntry("ArrayBufferLike"), interfaceEntry("ArrayBufferConstructor"), interfaceEntry("ArrayBufferView"), - constEntry("DataView"), + varEntry("DataView"), interfaceEntry("DataViewConstructor"), - constEntry("Int8Array"), + varEntry("Int8Array"), interfaceEntry("Int8ArrayConstructor"), - constEntry("Uint8Array"), + varEntry("Uint8Array"), interfaceEntry("Uint8ArrayConstructor"), - constEntry("Uint8ClampedArray"), + varEntry("Uint8ClampedArray"), interfaceEntry("Uint8ClampedArrayConstructor"), - constEntry("Int16Array"), + varEntry("Int16Array"), interfaceEntry("Int16ArrayConstructor"), - constEntry("Uint16Array"), + varEntry("Uint16Array"), interfaceEntry("Uint16ArrayConstructor"), - constEntry("Int32Array"), + varEntry("Int32Array"), interfaceEntry("Int32ArrayConstructor"), - constEntry("Uint32Array"), + varEntry("Uint32Array"), interfaceEntry("Uint32ArrayConstructor"), - constEntry("Float32Array"), + varEntry("Float32Array"), interfaceEntry("Float32ArrayConstructor"), - constEntry("Float64Array"), + varEntry("Float64Array"), interfaceEntry("Float64ArrayConstructor"), moduleEntry("Intl"), ]; @@ -4744,36 +4744,36 @@ namespace FourSlashInterface { functionEntry("encodeURIComponent"), functionEntry("escape"), functionEntry("unescape"), - constEntry("NaN"), - constEntry("Infinity"), - constEntry("Object"), - constEntry("Function"), - constEntry("String"), - constEntry("Boolean"), - constEntry("Number"), - constEntry("Math"), - constEntry("Date"), - constEntry("RegExp"), - constEntry("Error"), - constEntry("EvalError"), - constEntry("RangeError"), - constEntry("ReferenceError"), - constEntry("SyntaxError"), - constEntry("TypeError"), - constEntry("URIError"), - constEntry("JSON"), - constEntry("Array"), - constEntry("ArrayBuffer"), - constEntry("DataView"), - constEntry("Int8Array"), - constEntry("Uint8Array"), - constEntry("Uint8ClampedArray"), - constEntry("Int16Array"), - constEntry("Uint16Array"), - constEntry("Int32Array"), - constEntry("Uint32Array"), - constEntry("Float32Array"), - constEntry("Float64Array"), + varEntry("NaN"), + varEntry("Infinity"), + varEntry("Object"), + varEntry("Function"), + varEntry("String"), + varEntry("Boolean"), + varEntry("Number"), + varEntry("Math"), + varEntry("Date"), + varEntry("RegExp"), + varEntry("Error"), + varEntry("EvalError"), + varEntry("RangeError"), + varEntry("ReferenceError"), + varEntry("SyntaxError"), + varEntry("TypeError"), + varEntry("URIError"), + varEntry("JSON"), + varEntry("Array"), + varEntry("ArrayBuffer"), + varEntry("DataView"), + varEntry("Int8Array"), + varEntry("Uint8Array"), + varEntry("Uint8ClampedArray"), + varEntry("Int16Array"), + varEntry("Uint16Array"), + varEntry("Int32Array"), + varEntry("Uint32Array"), + varEntry("Float32Array"), + varEntry("Float64Array"), moduleEntry("Intl"), ]; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 4112f5a2ae7d7..458dc8b925216 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,8 +2,8 @@ /// ECMAScript APIs ///////////////////////////// -declare const NaN: number; -declare const Infinity: number; +declare var NaN: number; +declare var Infinity: number; /** * Evaluates JavaScript code and executes it. @@ -244,7 +244,7 @@ interface ObjectConstructor { /** * Provides functionality common to all JavaScript objects. */ -declare const Object: ObjectConstructor; +declare var Object: ObjectConstructor; /** * Creates a new function. @@ -293,7 +293,7 @@ interface FunctionConstructor { readonly prototype: Function; } -declare const Function: FunctionConstructor; +declare var Function: FunctionConstructor; /** * Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter. @@ -504,7 +504,7 @@ interface StringConstructor { /** * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ -declare const String: StringConstructor; +declare var String: StringConstructor; interface Boolean { /** Returns the primitive value of the specified object. */ @@ -517,7 +517,7 @@ interface BooleanConstructor { readonly prototype: Boolean; } -declare const Boolean: BooleanConstructor; +declare var Boolean: BooleanConstructor; interface Number { /** @@ -579,7 +579,7 @@ interface NumberConstructor { } /** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare const Number: NumberConstructor; +declare var Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { readonly raw: ReadonlyArray; @@ -703,7 +703,7 @@ interface Math { tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ -declare const Math: Math; +declare var Math: Math; /** Enables basic storage and retrieval of dates and times. */ interface Date { @@ -884,7 +884,7 @@ interface DateConstructor { now(): number; } -declare const Date: DateConstructor; +declare var Date: DateConstructor; interface RegExpMatchArray extends Array { index?: number; @@ -947,7 +947,7 @@ interface RegExpConstructor { lastMatch: string; } -declare const RegExp: RegExpConstructor; +declare var RegExp: RegExpConstructor; interface Error { name: string; @@ -961,7 +961,7 @@ interface ErrorConstructor { readonly prototype: Error; } -declare const Error: ErrorConstructor; +declare var Error: ErrorConstructor; interface EvalError extends Error { } @@ -972,7 +972,7 @@ interface EvalErrorConstructor { readonly prototype: EvalError; } -declare const EvalError: EvalErrorConstructor; +declare var EvalError: EvalErrorConstructor; interface RangeError extends Error { } @@ -983,7 +983,7 @@ interface RangeErrorConstructor { readonly prototype: RangeError; } -declare const RangeError: RangeErrorConstructor; +declare var RangeError: RangeErrorConstructor; interface ReferenceError extends Error { } @@ -994,7 +994,7 @@ interface ReferenceErrorConstructor { readonly prototype: ReferenceError; } -declare const ReferenceError: ReferenceErrorConstructor; +declare var ReferenceError: ReferenceErrorConstructor; interface SyntaxError extends Error { } @@ -1005,7 +1005,7 @@ interface SyntaxErrorConstructor { readonly prototype: SyntaxError; } -declare const SyntaxError: SyntaxErrorConstructor; +declare var SyntaxError: SyntaxErrorConstructor; interface TypeError extends Error { } @@ -1016,7 +1016,7 @@ interface TypeErrorConstructor { readonly prototype: TypeError; } -declare const TypeError: TypeErrorConstructor; +declare var TypeError: TypeErrorConstructor; interface URIError extends Error { } @@ -1027,7 +1027,7 @@ interface URIErrorConstructor { readonly prototype: URIError; } -declare const URIError: URIErrorConstructor; +declare var URIError: URIErrorConstructor; interface JSON { /** @@ -1056,7 +1056,7 @@ interface JSON { /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. */ -declare const JSON: JSON; +declare var JSON: JSON; ///////////////////////////// @@ -1345,7 +1345,7 @@ interface ArrayConstructor { readonly prototype: Array; } -declare const Array: ArrayConstructor; +declare var Array: ArrayConstructor; interface TypedPropertyDescriptor { enumerable?: boolean; @@ -1504,7 +1504,7 @@ interface ArrayBufferConstructor { new(byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } -declare const ArrayBuffer: ArrayBufferConstructor; +declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** @@ -1654,7 +1654,7 @@ interface DataView { interface DataViewConstructor { new(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView; } -declare const DataView: DataViewConstructor; +declare var DataView: DataViewConstructor; /** * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested @@ -1929,7 +1929,7 @@ interface Int8ArrayConstructor { } -declare const Int8Array: Int8ArrayConstructor; +declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the @@ -2204,7 +2204,7 @@ interface Uint8ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } -declare const Uint8Array: Uint8ArrayConstructor; +declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. @@ -2478,7 +2478,7 @@ interface Uint8ClampedArrayConstructor { */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the @@ -2753,7 +2753,7 @@ interface Int16ArrayConstructor { } -declare const Int16Array: Int16ArrayConstructor; +declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the @@ -3029,7 +3029,7 @@ interface Uint16ArrayConstructor { } -declare const Uint16Array: Uint16ArrayConstructor; +declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -3303,7 +3303,7 @@ interface Int32ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } -declare const Int32Array: Int32ArrayConstructor; +declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the @@ -3577,7 +3577,7 @@ interface Uint32ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } -declare const Uint32Array: Uint32ArrayConstructor; +declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number @@ -3853,7 +3853,7 @@ interface Float32ArrayConstructor { } -declare const Float32Array: Float32ArrayConstructor; +declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested @@ -4128,7 +4128,7 @@ interface Float64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } -declare const Float64Array: Float64ArrayConstructor; +declare var Float64Array: Float64ArrayConstructor; ///////////////////////////// /// ECMAScript Internationalization API diff --git a/src/lib/esnext.bigint.d.ts b/src/lib/esnext.bigint.d.ts index 667422bf8901a..5718e4a575167 100644 --- a/src/lib/esnext.bigint.d.ts +++ b/src/lib/esnext.bigint.d.ts @@ -34,7 +34,7 @@ interface BigIntConstructor { asUintN(bits: number, int: bigint): bigint; } -declare const BigInt: BigIntConstructor; +declare var BigInt: BigIntConstructor; /** * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the @@ -303,7 +303,7 @@ interface BigInt64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; } -declare const BigInt64Array: BigInt64ArrayConstructor; +declare var BigInt64Array: BigInt64ArrayConstructor; /** * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the @@ -572,7 +572,7 @@ interface BigUint64ArrayConstructor { from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; } -declare const BigUint64Array: BigUint64ArrayConstructor; +declare var BigUint64Array: BigUint64ArrayConstructor; interface DataView { /** @@ -606,4 +606,4 @@ interface DataView { * otherwise a little-endian value should be written. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; -} \ No newline at end of file +} diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 035d912b638ff..7cd59c5a93aff 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -!!! related TS2728 /.ts/lib.es5.d.ts:1368:15: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1368:13: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '[[any]]'. diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt index 2030b47b3ec6e..59cc07d6751fc 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10): error TS2339: Property 'name' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturing.ts(6,10 var f2 = (x: string) => { this.name = x ~~~~ -!!! error TS2540: Cannot assign to 'name' because it is a read-only property. +!!! error TS2339: Property 'name' does not exist on type 'typeof globalThis'. } function foo(func: () => boolean) { } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols index e130eafd77095..e201b4c1eaf9c 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.symbols @@ -12,9 +12,7 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) this.name = x ->this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >this : Symbol(globalThis) ->name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturing.ts, 4, 10)) } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt index fb644a4127e47..1914093efb3d7 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6,10): error TS2540: Cannot assign to 'name' because it is a read-only property. +tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6,10): error TS2339: Property 'name' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/es6/arrowFunction/emitArrowFunctionThisCapturingES6.ts(6 var f2 = (x: string) => { this.name = x ~~~~ -!!! error TS2540: Cannot assign to 'name' because it is a read-only property. +!!! error TS2339: Property 'name' does not exist on type 'typeof globalThis'. } function foo(func: () => boolean){ } diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols index d370a207de69d..dbddfc5a16102 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.symbols @@ -12,9 +12,7 @@ var f2 = (x: string) => { >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) this.name = x ->this.name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >this : Symbol(globalThis) ->name : Symbol(name, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(emitArrowFunctionThisCapturingES6.ts, 4, 10)) } diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index d30cd737ab1ad..ff4531e5a0f0d 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -69,20 +69,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat var d=new XDate(); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. d.getDay(); d=new XDate(1978,2); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. d.getXDate(); var n=XDate.parse("3/2/2004"); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. n=XDate.UTC(1964,2,1); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? -!!! related TS2728 /.ts/lib.es5.d.ts:907:15: 'Date' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:907:13: 'Date' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt b/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt new file mode 100644 index 0000000000000..725e5a1643c87 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(5,12): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(6,12): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(8,1): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(9,1): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(14,40): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. +tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts(15,40): error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + + +==== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts (6 errors) ==== + var x = 1 + const y = 2 + let z = 3 + globalThis.x // ok + globalThis.y // should error, no property 'y' + ~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + globalThis.z // should error, no property 'z' + ~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + globalThis['x'] // ok + globalThis['y'] // should error, no property 'y' + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + globalThis['z'] // should error, no property 'z' + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + globalThis.Float64Array // ok + globalThis.Infinity // ok + + declare let test1: (typeof globalThis)['x'] // ok + declare let test2: (typeof globalThis)['y'] // error + ~~~ +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. + declare let test3: (typeof globalThis)['z'] // error + ~~~ +!!! error TS2339: Property 'z' does not exist on type 'typeof globalThis'. + declare let themAll: keyof typeof globalThis + \ No newline at end of file diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.js b/tests/baselines/reference/globalThisBlockscopedProperties.js new file mode 100644 index 0000000000000..0683ea4dff0a9 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.js @@ -0,0 +1,31 @@ +//// [globalThisBlockscopedProperties.ts] +var x = 1 +const y = 2 +let z = 3 +globalThis.x // ok +globalThis.y // should error, no property 'y' +globalThis.z // should error, no property 'z' +globalThis['x'] // ok +globalThis['y'] // should error, no property 'y' +globalThis['z'] // should error, no property 'z' +globalThis.Float64Array // ok +globalThis.Infinity // ok + +declare let test1: (typeof globalThis)['x'] // ok +declare let test2: (typeof globalThis)['y'] // error +declare let test3: (typeof globalThis)['z'] // error +declare let themAll: keyof typeof globalThis + + +//// [globalThisBlockscopedProperties.js] +var x = 1; +var y = 2; +var z = 3; +globalThis.x; // ok +globalThis.y; // should error, no property 'y' +globalThis.z; // should error, no property 'z' +globalThis['x']; // ok +globalThis['y']; // should error, no property 'y' +globalThis['z']; // should error, no property 'z' +globalThis.Float64Array; // ok +globalThis.Infinity; // ok diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.symbols b/tests/baselines/reference/globalThisBlockscopedProperties.symbols new file mode 100644 index 0000000000000..54256c1186163 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.symbols @@ -0,0 +1,57 @@ +=== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts === +var x = 1 +>x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +const y = 2 +>y : Symbol(y, Decl(globalThisBlockscopedProperties.ts, 1, 5)) + +let z = 3 +>z : Symbol(z, Decl(globalThisBlockscopedProperties.ts, 2, 3)) + +globalThis.x // ok +>globalThis.x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) +>globalThis : Symbol(globalThis) +>x : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +globalThis.y // should error, no property 'y' +>globalThis : Symbol(globalThis) + +globalThis.z // should error, no property 'z' +>globalThis : Symbol(globalThis) + +globalThis['x'] // ok +>globalThis : Symbol(globalThis) +>'x' : Symbol(x, Decl(globalThisBlockscopedProperties.ts, 0, 3)) + +globalThis['y'] // should error, no property 'y' +>globalThis : Symbol(globalThis) + +globalThis['z'] // should error, no property 'z' +>globalThis : Symbol(globalThis) + +globalThis.Float64Array // ok +>globalThis.Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>globalThis : Symbol(globalThis) +>Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +globalThis.Infinity // ok +>globalThis.Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) +>globalThis : Symbol(globalThis) +>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --)) + +declare let test1: (typeof globalThis)['x'] // ok +>test1 : Symbol(test1, Decl(globalThisBlockscopedProperties.ts, 12, 11)) +>globalThis : Symbol(globalThis) + +declare let test2: (typeof globalThis)['y'] // error +>test2 : Symbol(test2, Decl(globalThisBlockscopedProperties.ts, 13, 11)) +>globalThis : Symbol(globalThis) + +declare let test3: (typeof globalThis)['z'] // error +>test3 : Symbol(test3, Decl(globalThisBlockscopedProperties.ts, 14, 11)) +>globalThis : Symbol(globalThis) + +declare let themAll: keyof typeof globalThis +>themAll : Symbol(themAll, Decl(globalThisBlockscopedProperties.ts, 15, 11)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisBlockscopedProperties.types b/tests/baselines/reference/globalThisBlockscopedProperties.types new file mode 100644 index 0000000000000..564fa3f00d327 --- /dev/null +++ b/tests/baselines/reference/globalThisBlockscopedProperties.types @@ -0,0 +1,69 @@ +=== tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts === +var x = 1 +>x : number +>1 : 1 + +const y = 2 +>y : 2 +>2 : 2 + +let z = 3 +>z : number +>3 : 3 + +globalThis.x // ok +>globalThis.x : number +>globalThis : typeof globalThis +>x : number + +globalThis.y // should error, no property 'y' +>globalThis.y : any +>globalThis : typeof globalThis +>y : any + +globalThis.z // should error, no property 'z' +>globalThis.z : any +>globalThis : typeof globalThis +>z : any + +globalThis['x'] // ok +>globalThis['x'] : number +>globalThis : typeof globalThis +>'x' : "x" + +globalThis['y'] // should error, no property 'y' +>globalThis['y'] : any +>globalThis : typeof globalThis +>'y' : "y" + +globalThis['z'] // should error, no property 'z' +>globalThis['z'] : any +>globalThis : typeof globalThis +>'z' : "z" + +globalThis.Float64Array // ok +>globalThis.Float64Array : Float64ArrayConstructor +>globalThis : typeof globalThis +>Float64Array : Float64ArrayConstructor + +globalThis.Infinity // ok +>globalThis.Infinity : number +>globalThis : typeof globalThis +>Infinity : number + +declare let test1: (typeof globalThis)['x'] // ok +>test1 : number +>globalThis : typeof globalThis + +declare let test2: (typeof globalThis)['y'] // error +>test2 : any +>globalThis : typeof globalThis + +declare let test3: (typeof globalThis)['z'] // error +>test3 : any +>globalThis : typeof globalThis + +declare let themAll: keyof typeof globalThis +>themAll : "undefined" | "x" | "globalThis" | "eval" | "parseInt" | "parseFloat" | "isNaN" | "isFinite" | "decodeURI" | "decodeURIComponent" | "encodeURI" | "encodeURIComponent" | "escape" | "unescape" | "NaN" | "Infinity" | "Object" | "Function" | "String" | "Boolean" | "Number" | "Math" | "Date" | "RegExp" | "Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError" | "JSON" | "Array" | "ArrayBuffer" | "DataView" | "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "Intl" | "alert" | "blur" | "cancelAnimationFrame" | "captureEvents" | "close" | "confirm" | "departFocus" | "focus" | "getComputedStyle" | "getMatchedCSSRules" | "getSelection" | "matchMedia" | "moveBy" | "moveTo" | "msWriteProfilerMark" | "open" | "postMessage" | "print" | "prompt" | "releaseEvents" | "requestAnimationFrame" | "resizeBy" | "resizeTo" | "scroll" | "scrollBy" | "scrollTo" | "stop" | "webkitCancelAnimationFrame" | "webkitConvertPointFromNodeToPage" | "webkitConvertPointFromPageToNode" | "webkitRequestAnimationFrame" | "toString" | "dispatchEvent" | "atob" | "btoa" | "fetch" | "clearInterval" | "clearTimeout" | "createImageBitmap" | "queueMicrotask" | "setInterval" | "setTimeout" | "addEventListener" | "removeEventListener" | "RTCStatsReport" | "AbortController" | "AbortSignal" | "AbstractRange" | "AnalyserNode" | "Animation" | "AnimationEffect" | "AnimationEvent" | "AnimationPlaybackEvent" | "AnimationTimeline" | "ApplicationCache" | "Attr" | "AudioBuffer" | "AudioBufferSourceNode" | "AudioContext" | "AudioDestinationNode" | "AudioListener" | "AudioNode" | "AudioParam" | "AudioParamMap" | "AudioProcessingEvent" | "AudioScheduledSourceNode" | "AudioTrack" | "AudioTrackList" | "AudioWorklet" | "AudioWorkletNode" | "BarProp" | "BaseAudioContext" | "BeforeUnloadEvent" | "BhxBrowser" | "BiquadFilterNode" | "Blob" | "BroadcastChannel" | "ByteLengthQueuingStrategy" | "CDATASection" | "CSS" | "CSSConditionRule" | "CSSFontFaceRule" | "CSSGroupingRule" | "CSSImportRule" | "CSSKeyframeRule" | "CSSKeyframesRule" | "CSSMediaRule" | "CSSNamespaceRule" | "CSSPageRule" | "CSSRule" | "CSSRuleList" | "CSSStyleDeclaration" | "CSSStyleRule" | "CSSStyleSheet" | "CSSSupportsRule" | "Cache" | "CacheStorage" | "CanvasGradient" | "CanvasPattern" | "CanvasRenderingContext2D" | "CaretPosition" | "ChannelMergerNode" | "ChannelSplitterNode" | "CharacterData" | "ClientRect" | "ClientRectList" | "Clipboard" | "ClipboardEvent" | "CloseEvent" | "Comment" | "CompositionEvent" | "Console" | "ConstantSourceNode" | "ConvolverNode" | "CountQueuingStrategy" | "Crypto" | "CryptoKey" | "CryptoKeyPair" | "CustomElementRegistry" | "CustomEvent" | "DOMError" | "DOMException" | "DOMImplementation" | "DOMMatrix" | "SVGMatrix" | "WebKitCSSMatrix" | "DOMMatrixReadOnly" | "DOMParser" | "DOMPoint" | "SVGPoint" | "DOMPointReadOnly" | "DOMQuad" | "DOMRect" | "SVGRect" | "DOMRectList" | "DOMRectReadOnly" | "DOMSettableTokenList" | "DOMStringList" | "DOMStringMap" | "DOMTokenList" | "DataCue" | "DataTransfer" | "DataTransferItem" | "DataTransferItemList" | "DeferredPermissionRequest" | "DelayNode" | "DeviceAcceleration" | "DeviceLightEvent" | "DeviceMotionEvent" | "DeviceOrientationEvent" | "DeviceRotationRate" | "Document" | "DocumentFragment" | "DocumentTimeline" | "DocumentType" | "DragEvent" | "DynamicsCompressorNode" | "Element" | "ErrorEvent" | "Event" | "EventSource" | "EventTarget" | "ExtensionScriptApis" | "File" | "FileList" | "FileReader" | "FocusEvent" | "FocusNavigationEvent" | "FormData" | "GainNode" | "Gamepad" | "GamepadButton" | "GamepadEvent" | "GamepadHapticActuator" | "GamepadPose" | "HTMLAllCollection" | "HTMLAnchorElement" | "HTMLAppletElement" | "HTMLAreaElement" | "HTMLAudioElement" | "HTMLBRElement" | "HTMLBaseElement" | "HTMLBaseFontElement" | "HTMLBodyElement" | "HTMLButtonElement" | "HTMLCanvasElement" | "HTMLCollection" | "HTMLDListElement" | "HTMLDataElement" | "HTMLDataListElement" | "HTMLDetailsElement" | "HTMLDialogElement" | "HTMLDirectoryElement" | "HTMLDivElement" | "HTMLDocument" | "HTMLElement" | "HTMLEmbedElement" | "HTMLFieldSetElement" | "HTMLFontElement" | "HTMLFormControlsCollection" | "HTMLFormElement" | "HTMLFrameElement" | "HTMLFrameSetElement" | "HTMLHRElement" | "HTMLHeadElement" | "HTMLHeadingElement" | "HTMLHtmlElement" | "HTMLIFrameElement" | "HTMLImageElement" | "HTMLInputElement" | "HTMLLIElement" | "HTMLLabelElement" | "HTMLLegendElement" | "HTMLLinkElement" | "HTMLMainElement" | "HTMLMapElement" | "HTMLMarqueeElement" | "HTMLMediaElement" | "HTMLMenuElement" | "HTMLMetaElement" | "HTMLMeterElement" | "HTMLModElement" | "HTMLOListElement" | "HTMLObjectElement" | "HTMLOptGroupElement" | "HTMLOptionElement" | "HTMLOptionsCollection" | "HTMLOutputElement" | "HTMLParagraphElement" | "HTMLParamElement" | "HTMLPictureElement" | "HTMLPreElement" | "HTMLProgressElement" | "HTMLQuoteElement" | "HTMLScriptElement" | "HTMLSelectElement" | "HTMLSlotElement" | "HTMLSourceElement" | "HTMLSpanElement" | "HTMLStyleElement" | "HTMLTableCaptionElement" | "HTMLTableCellElement" | "HTMLTableColElement" | "HTMLTableDataCellElement" | "HTMLTableElement" | "HTMLTableHeaderCellElement" | "HTMLTableRowElement" | "HTMLTableSectionElement" | "HTMLTemplateElement" | "HTMLTextAreaElement" | "HTMLTimeElement" | "HTMLTitleElement" | "HTMLTrackElement" | "HTMLUListElement" | "HTMLUnknownElement" | "HTMLVideoElement" | "HashChangeEvent" | "Headers" | "History" | "IDBCursor" | "IDBCursorWithValue" | "IDBDatabase" | "IDBFactory" | "IDBIndex" | "IDBKeyRange" | "IDBObjectStore" | "IDBOpenDBRequest" | "IDBRequest" | "IDBTransaction" | "IDBVersionChangeEvent" | "IIRFilterNode" | "ImageBitmap" | "ImageBitmapRenderingContext" | "ImageData" | "IntersectionObserver" | "IntersectionObserverEntry" | "KeyboardEvent" | "KeyframeEffect" | "ListeningStateChangedEvent" | "Location" | "MSAssertion" | "MSBlobBuilder" | "MSFIDOCredentialAssertion" | "MSFIDOSignature" | "MSFIDOSignatureAssertion" | "MSGesture" | "MSGestureEvent" | "MSGraphicsTrust" | "MSInputMethodContext" | "MSMediaKeyError" | "MSMediaKeyMessageEvent" | "MSMediaKeyNeededEvent" | "MSMediaKeySession" | "MSMediaKeys" | "MSPointerEvent" | "MSStream" | "MediaDeviceInfo" | "MediaDevices" | "MediaElementAudioSourceNode" | "MediaEncryptedEvent" | "MediaError" | "MediaKeyMessageEvent" | "MediaKeySession" | "MediaKeyStatusMap" | "MediaKeySystemAccess" | "MediaKeys" | "MediaList" | "MediaQueryList" | "MediaQueryListEvent" | "MediaSource" | "MediaStream" | "MediaStreamAudioDestinationNode" | "MediaStreamAudioSourceNode" | "MediaStreamError" | "MediaStreamErrorEvent" | "MediaStreamEvent" | "MediaStreamTrack" | "MediaStreamTrackAudioSourceNode" | "MediaStreamTrackEvent" | "MessageChannel" | "MessageEvent" | "MessagePort" | "MimeType" | "MimeTypeArray" | "MouseEvent" | "MutationEvent" | "MutationObserver" | "MutationRecord" | "NamedNodeMap" | "NavigationPreloadManager" | "Navigator" | "Node" | "NodeFilter" | "NodeIterator" | "NodeList" | "Notification" | "OfflineAudioCompletionEvent" | "OfflineAudioContext" | "OscillatorNode" | "OverflowEvent" | "PageTransitionEvent" | "PannerNode" | "Path2D" | "PaymentAddress" | "PaymentRequest" | "PaymentRequestUpdateEvent" | "PaymentResponse" | "PerfWidgetExternal" | "Performance" | "PerformanceEntry" | "PerformanceMark" | "PerformanceMeasure" | "PerformanceNavigation" | "PerformanceNavigationTiming" | "PerformanceObserver" | "PerformanceObserverEntryList" | "PerformanceResourceTiming" | "PerformanceTiming" | "PeriodicWave" | "PermissionRequest" | "PermissionRequestedEvent" | "Plugin" | "PluginArray" | "PointerEvent" | "PopStateEvent" | "ProcessingInstruction" | "ProgressEvent" | "PromiseRejectionEvent" | "PushManager" | "PushSubscription" | "PushSubscriptionOptions" | "RTCCertificate" | "RTCDTMFSender" | "RTCDTMFToneChangeEvent" | "RTCDataChannel" | "RTCDataChannelEvent" | "RTCDtlsTransport" | "RTCDtlsTransportStateChangedEvent" | "RTCDtmfSender" | "RTCError" | "RTCErrorEvent" | "RTCIceCandidate" | "RTCIceCandidatePairChangedEvent" | "RTCIceGatherer" | "RTCIceGathererEvent" | "RTCIceTransport" | "RTCIceTransportStateChangedEvent" | "RTCIdentityAssertion" | "RTCPeerConnection" | "RTCPeerConnectionIceErrorEvent" | "RTCPeerConnectionIceEvent" | "RTCRtpReceiver" | "RTCRtpSender" | "RTCRtpTransceiver" | "RTCSctpTransport" | "RTCSessionDescription" | "RTCSrtpSdesTransport" | "RTCSsrcConflictEvent" | "RTCStatsEvent" | "RTCStatsProvider" | "RTCTrackEvent" | "RadioNodeList" | "RandomSource" | "Range" | "ReadableStream" | "ReadableStreamBYOBReader" | "ReadableStreamReader" | "Request" | "Response" | "SVGAElement" | "SVGAngle" | "SVGAnimateElement" | "SVGAnimateMotionElement" | "SVGAnimateTransformElement" | "SVGAnimatedAngle" | "SVGAnimatedBoolean" | "SVGAnimatedEnumeration" | "SVGAnimatedInteger" | "SVGAnimatedLength" | "SVGAnimatedLengthList" | "SVGAnimatedNumber" | "SVGAnimatedNumberList" | "SVGAnimatedPreserveAspectRatio" | "SVGAnimatedRect" | "SVGAnimatedString" | "SVGAnimatedTransformList" | "SVGAnimationElement" | "SVGCircleElement" | "SVGClipPathElement" | "SVGComponentTransferFunctionElement" | "SVGCursorElement" | "SVGDefsElement" | "SVGDescElement" | "SVGElement" | "SVGElementInstance" | "SVGElementInstanceList" | "SVGEllipseElement" | "SVGFEBlendElement" | "SVGFEColorMatrixElement" | "SVGFEComponentTransferElement" | "SVGFECompositeElement" | "SVGFEConvolveMatrixElement" | "SVGFEDiffuseLightingElement" | "SVGFEDisplacementMapElement" | "SVGFEDistantLightElement" | "SVGFEFloodElement" | "SVGFEFuncAElement" | "SVGFEFuncBElement" | "SVGFEFuncGElement" | "SVGFEFuncRElement" | "SVGFEGaussianBlurElement" | "SVGFEImageElement" | "SVGFEMergeElement" | "SVGFEMergeNodeElement" | "SVGFEMorphologyElement" | "SVGFEOffsetElement" | "SVGFEPointLightElement" | "SVGFESpecularLightingElement" | "SVGFESpotLightElement" | "SVGFETileElement" | "SVGFETurbulenceElement" | "SVGFilterElement" | "SVGForeignObjectElement" | "SVGGElement" | "SVGGeometryElement" | "SVGGradientElement" | "SVGGraphicsElement" | "SVGImageElement" | "SVGLength" | "SVGLengthList" | "SVGLineElement" | "SVGLinearGradientElement" | "SVGMarkerElement" | "SVGMaskElement" | "SVGMetadataElement" | "SVGNumber" | "SVGNumberList" | "SVGPathElement" | "SVGPathSeg" | "SVGPathSegArcAbs" | "SVGPathSegArcRel" | "SVGPathSegClosePath" | "SVGPathSegCurvetoCubicAbs" | "SVGPathSegCurvetoCubicRel" | "SVGPathSegCurvetoCubicSmoothAbs" | "SVGPathSegCurvetoCubicSmoothRel" | "SVGPathSegCurvetoQuadraticAbs" | "SVGPathSegCurvetoQuadraticRel" | "SVGPathSegCurvetoQuadraticSmoothAbs" | "SVGPathSegCurvetoQuadraticSmoothRel" | "SVGPathSegLinetoAbs" | "SVGPathSegLinetoHorizontalAbs" | "SVGPathSegLinetoHorizontalRel" | "SVGPathSegLinetoRel" | "SVGPathSegLinetoVerticalAbs" | "SVGPathSegLinetoVerticalRel" | "SVGPathSegList" | "SVGPathSegMovetoAbs" | "SVGPathSegMovetoRel" | "SVGPatternElement" | "SVGPointList" | "SVGPolygonElement" | "SVGPolylineElement" | "SVGPreserveAspectRatio" | "SVGRadialGradientElement" | "SVGRectElement" | "SVGSVGElement" | "SVGScriptElement" | "SVGStopElement" | "SVGStringList" | "SVGStyleElement" | "SVGSwitchElement" | "SVGSymbolElement" | "SVGTSpanElement" | "SVGTextContentElement" | "SVGTextElement" | "SVGTextPathElement" | "SVGTextPositioningElement" | "SVGTitleElement" | "SVGTransform" | "SVGTransformList" | "SVGUnitTypes" | "SVGUseElement" | "SVGViewElement" | "SVGZoomAndPan" | "SVGZoomEvent" | "ScopedCredential" | "ScopedCredentialInfo" | "Screen" | "ScreenOrientation" | "ScriptProcessorNode" | "SecurityPolicyViolationEvent" | "Selection" | "ServiceUIFrameContext" | "ServiceWorker" | "ServiceWorkerContainer" | "ServiceWorkerMessageEvent" | "ServiceWorkerRegistration" | "ShadowRoot" | "SourceBuffer" | "SourceBufferList" | "SpeechGrammar" | "SpeechGrammarList" | "SpeechRecognition" | "SpeechRecognitionAlternative" | "SpeechRecognitionError" | "SpeechRecognitionEvent" | "SpeechRecognitionResult" | "SpeechRecognitionResultList" | "SpeechSynthesis" | "SpeechSynthesisErrorEvent" | "SpeechSynthesisEvent" | "SpeechSynthesisUtterance" | "SpeechSynthesisVoice" | "StaticRange" | "StereoPannerNode" | "Storage" | "StorageEvent" | "StorageManager" | "StyleMedia" | "StyleSheet" | "StyleSheetList" | "SubtleCrypto" | "SyncManager" | "Text" | "TextDecoder" | "TextEncoder" | "TextEvent" | "TextMetrics" | "TextTrack" | "TextTrackCue" | "TextTrackCueList" | "TextTrackList" | "TimeRanges" | "Touch" | "TouchEvent" | "TouchList" | "TrackEvent" | "TransformStream" | "TransitionEvent" | "TreeWalker" | "UIEvent" | "URL" | "webkitURL" | "URLSearchParams" | "VRDisplay" | "VRDisplayCapabilities" | "VRDisplayEvent" | "VREyeParameters" | "VRFieldOfView" | "VRFrameData" | "VRPose" | "VTTCue" | "VTTRegion" | "ValidityState" | "VideoPlaybackQuality" | "VideoTrack" | "VideoTrackList" | "WaveShaperNode" | "WebAuthentication" | "WebAuthnAssertion" | "WebGLActiveInfo" | "WebGLBuffer" | "WebGLContextEvent" | "WebGLFramebuffer" | "WebGLObject" | "WebGLProgram" | "WebGLRenderbuffer" | "WebGLRenderingContext" | "WebGLShader" | "WebGLShaderPrecisionFormat" | "WebGLTexture" | "WebGLUniformLocation" | "WebKitPoint" | "WebSocket" | "WheelEvent" | "Window" | "Worker" | "Worklet" | "WritableStream" | "XMLDocument" | "XMLHttpRequest" | "XMLHttpRequestEventTarget" | "XMLHttpRequestUpload" | "XMLSerializer" | "XPathEvaluator" | "XPathExpression" | "XPathNSResolver" | "XPathResult" | "XSLTProcessor" | "webkitRTCPeerConnection" | "Audio" | "Image" | "Option" | "applicationCache" | "caches" | "clientInformation" | "closed" | "crypto" | "customElements" | "defaultStatus" | "devicePixelRatio" | "doNotTrack" | "document" | "event" | "external" | "frameElement" | "frames" | "history" | "innerHeight" | "innerWidth" | "isSecureContext" | "length" | "location" | "locationbar" | "menubar" | "msContentScript" | "navigator" | "offscreenBuffering" | "oncompassneedscalibration" | "ondevicelight" | "ondevicemotion" | "ondeviceorientation" | "onmousewheel" | "onmsgesturechange" | "onmsgesturedoubletap" | "onmsgestureend" | "onmsgesturehold" | "onmsgesturestart" | "onmsgesturetap" | "onmsinertiastart" | "onmspointercancel" | "onmspointerdown" | "onmspointerenter" | "onmspointerleave" | "onmspointermove" | "onmspointerout" | "onmspointerover" | "onmspointerup" | "onorientationchange" | "onreadystatechange" | "onvrdisplayactivate" | "onvrdisplayblur" | "onvrdisplayconnect" | "onvrdisplaydeactivate" | "onvrdisplaydisconnect" | "onvrdisplayfocus" | "onvrdisplaypointerrestricted" | "onvrdisplaypointerunrestricted" | "onvrdisplaypresentchange" | "opener" | "orientation" | "outerHeight" | "outerWidth" | "pageXOffset" | "pageYOffset" | "parent" | "performance" | "personalbar" | "screen" | "screenLeft" | "screenTop" | "screenX" | "screenY" | "scrollX" | "scrollY" | "scrollbars" | "self" | "speechSynthesis" | "status" | "statusbar" | "styleMedia" | "toolbar" | "top" | "window" | "sessionStorage" | "localStorage" | "console" | "onabort" | "onanimationcancel" | "onanimationend" | "onanimationiteration" | "onanimationstart" | "onauxclick" | "onblur" | "oncancel" | "oncanplay" | "oncanplaythrough" | "onchange" | "onclick" | "onclose" | "oncontextmenu" | "oncuechange" | "ondblclick" | "ondrag" | "ondragend" | "ondragenter" | "ondragexit" | "ondragleave" | "ondragover" | "ondragstart" | "ondrop" | "ondurationchange" | "onemptied" | "onended" | "onerror" | "onfocus" | "ongotpointercapture" | "oninput" | "oninvalid" | "onkeydown" | "onkeypress" | "onkeyup" | "onload" | "onloadeddata" | "onloadedmetadata" | "onloadend" | "onloadstart" | "onlostpointercapture" | "onmousedown" | "onmouseenter" | "onmouseleave" | "onmousemove" | "onmouseout" | "onmouseover" | "onmouseup" | "onpause" | "onplay" | "onplaying" | "onpointercancel" | "onpointerdown" | "onpointerenter" | "onpointerleave" | "onpointermove" | "onpointerout" | "onpointerover" | "onpointerup" | "onprogress" | "onratechange" | "onreset" | "onresize" | "onscroll" | "onsecuritypolicyviolation" | "onseeked" | "onseeking" | "onselect" | "onselectionchange" | "onselectstart" | "onstalled" | "onsubmit" | "onsuspend" | "ontimeupdate" | "ontoggle" | "ontouchcancel" | "ontouchend" | "ontouchmove" | "ontouchstart" | "ontransitioncancel" | "ontransitionend" | "ontransitionrun" | "ontransitionstart" | "onvolumechange" | "onwaiting" | "onwheel" | "indexedDB" | "origin" | "onafterprint" | "onbeforeprint" | "onbeforeunload" | "onhashchange" | "onlanguagechange" | "onmessage" | "onmessageerror" | "onoffline" | "ononline" | "onpagehide" | "onpageshow" | "onpopstate" | "onrejectionhandled" | "onstorage" | "onunhandledrejection" | "onunload" | "importScripts" | "ActiveXObject" | "WScript" | "WSH" | "Enumerator" | "VBArray" +>globalThis : typeof globalThis + diff --git a/tests/baselines/reference/globalThisReadonlyProperties.errors.txt b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt index 925cf90a10c77..a4b7876c485b5 100644 --- a/tests/baselines/reference/globalThisReadonlyProperties.errors.txt +++ b/tests/baselines/reference/globalThisReadonlyProperties.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(1,12): error TS2540: Cannot assign to 'globalThis' because it is a read-only property. -tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS2540: Cannot assign to 'y' because it is a read-only property. +tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS2339: Property 'y' does not exist on type 'typeof globalThis'. ==== tests/cases/conformance/es2019/globalThisReadonlyProperties.ts (2 errors) ==== @@ -11,5 +11,5 @@ tests/cases/conformance/es2019/globalThisReadonlyProperties.ts(5,12): error TS25 globalThis.x = 3 globalThis.y = 4 // should error ~ -!!! error TS2540: Cannot assign to 'y' because it is a read-only property. +!!! error TS2339: Property 'y' does not exist on type 'typeof globalThis'. \ No newline at end of file diff --git a/tests/baselines/reference/globalThisReadonlyProperties.symbols b/tests/baselines/reference/globalThisReadonlyProperties.symbols index df59ee45ca36a..b597a27584fa3 100644 --- a/tests/baselines/reference/globalThisReadonlyProperties.symbols +++ b/tests/baselines/reference/globalThisReadonlyProperties.symbols @@ -16,7 +16,5 @@ globalThis.x = 3 >x : Symbol(x, Decl(globalThisReadonlyProperties.ts, 1, 3)) globalThis.y = 4 // should error ->globalThis.y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) >globalThis : Symbol(globalThis) ->y : Symbol(y, Decl(globalThisReadonlyProperties.ts, 2, 5)) diff --git a/tests/baselines/reference/invalidTypeOfTarget.errors.txt b/tests/baselines/reference/invalidTypeOfTarget.errors.txt index b6da9a1eb7767..c57838334f944 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.errors.txt +++ b/tests/baselines/reference/invalidTypeOfTarget.errors.txt @@ -36,7 +36,7 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts var x7: typeof function f() { }; ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? -!!! related TS2728 /.ts/lib.es5.d.ts:316:15: 'Function' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:316:13: 'Function' is declared here. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt b/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt index ab9d0a34a5590..2d5b8277e9848 100644 --- a/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt +++ b/tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt @@ -11,4 +11,4 @@ tests/cases/conformance/parser/ecmascript5/Expressions/parserMemberAccessAfterPo !!! error TS1005: ';' expected. ~~~~~~~~ !!! error TS2552: Cannot find name 'toString'. Did you mean 'String'? -!!! related TS2728 /.ts/lib.es5.d.ts:527:15: 'String' is declared here. \ No newline at end of file +!!! related TS2728 /.ts/lib.es5.d.ts:527:13: 'String' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt index 5d1059f6effb8..e699649181895 100644 --- a/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt index 1f8845e808a43..72a6b13b60828 100644 --- a/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt index 4242d1faecab2..38fb5e321d2d6 100644 --- a/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/parserS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts(142,3): error T $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/parserUnicode1.errors.txt b/tests/baselines/reference/parserUnicode1.errors.txt index aa9cf50471466..4bcc26a643418 100644 --- a/tests/baselines/reference/parserUnicode1.errors.txt +++ b/tests/baselines/reference/parserUnicode1.errors.txt @@ -11,13 +11,13 @@ tests/cases/conformance/parser/ecmascript5/parserUnicode1.ts(10,5): error TS2552 $ERROR('#6.1: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } } catch (e) { $ERROR('#6.2: var \\u0078x = 1; xx === 6. Actual: ' + (xx)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index dd3727b0216ba..c632915e72fd9 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -1,7 +1,8 @@ -tests/cases/compiler/redefineArray.ts(1,1): error TS2588: Cannot assign to 'Array' because it is a constant. +tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. ==== tests/cases/compiler/redefineArray.ts (1 errors) ==== Array = function (n:number, s:string) {return n;}; ~~~~~ -!!! error TS2588: Cannot assign to 'Array' because it is a constant. \ No newline at end of file +!!! error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. +!!! related TS2728 /.ts/lib.es5.d.ts:1364:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.types b/tests/baselines/reference/redefineArray.types index 03d36c1007c54..51b1e67846b2c 100644 --- a/tests/baselines/reference/redefineArray.types +++ b/tests/baselines/reference/redefineArray.types @@ -1,7 +1,7 @@ === tests/cases/compiler/redefineArray.ts === Array = function (n:number, s:string) {return n;}; >Array = function (n:number, s:string) {return n;} : (n: number, s: string) => number ->Array : any +>Array : ArrayConstructor >function (n:number, s:string) {return n;} : (n: number, s: string) => number >n : number >s : string diff --git a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt index 473590f63e583..575b38c483288 100644 --- a/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.2_A1.5_T2.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } //CHECK#2 @@ -28,7 +28,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.2_A1.5_T2.ts(20,3): error $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } diff --git a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt index fa25b5cc170da..63c080074f099 100644 --- a/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt +++ b/tests/baselines/reference/scannerS7.3_A1.1_T2.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.3_A1.1_T2.ts(17,3): error $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt index 6dc7a99446b90..382c345b12c3f 100644 --- a/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt +++ b/tests/baselines/reference/scannerS7.6_A4.2_T1.errors.txt @@ -50,70 +50,70 @@ tests/cases/conformance/scanner/ecmascript5/scannerS7.6_A4.2_T1.ts(142,3): error $ERROR('#А'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); ~~~~~~ !!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'? -!!! related TS2728 /.ts/lib.es5.d.ts:984:15: 'Error' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:984:13: 'Error' is declared here. } var \u041A = 1; if (К !== 1) { diff --git a/tests/baselines/reference/thisTypeInFunctions.errors.txt b/tests/baselines/reference/thisTypeInFunctions.errors.txt new file mode 100644 index 0000000000000..114a5b1335d16 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions.errors.txt @@ -0,0 +1,206 @@ +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(118,29): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(119,32): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. +tests/cases/conformance/types/thisType/thisTypeInFunctions.ts(120,36): error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + + +==== tests/cases/conformance/types/thisType/thisTypeInFunctions.ts (3 errors) ==== + // body checking + class B { + n: number; + } + class C { + n: number; + explicitThis(this: this, m: number): number { + return this.n + m; + } + explicitC(this: C, m: number): number { + return this.n + m; + } + explicitProperty(this: {n: number}, m: number): number { + return this.n + m; + } + explicitVoid(this: void, m: number): number { + return m + 1; + } + } + class D extends C { } + interface I { + a: number; + explicitVoid1(this: void): number; + explicitVoid2(this: void): number; + explicitStructural(this: {a: number}): number; + explicitInterface(this: I): number; + explicitThis(this: this): number; + } + function explicitStructural(this: { y: number }, x: number): number { + return x + this.y; + } + function justThis(this: { y: number }): number { + return this.y; + } + function implicitThis(n: number): number { + return this.m + n + 12; + } + let impl: I = { + a: 12, + explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) + explicitVoid1() { return 12; }, + explicitStructural() { + return this.a; + }, + explicitInterface() { + return this.a; + }, + explicitThis() { + return this.a; + }, + } + impl.explicitVoid1 = function () { return 12; }; + impl.explicitVoid2 = () => 12; + impl.explicitStructural = function() { return this.a; }; + impl.explicitInterface = function() { return this.a; }; + impl.explicitStructural = () => 12; + impl.explicitInterface = () => 12; + impl.explicitThis = function () { return this.a; }; + // parameter checking + let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; + let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; + ok.f(13); + implicitThis(12); + implicitAnyOk.f(12); + + let c = new C(); + let d = new D(); + let ripped = c.explicitC; + c.explicitC(12); + c.explicitProperty(12); + c.explicitThis(12); + d.explicitC(12); + d.explicitProperty(12); + d.explicitThis(12); + let reconstructed: { + n: number, + explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. + explicitC(this: C, m: number): number, + explicitProperty: (this: {n : number}, m: number) => number, + explicitVoid(this: void, m: number): number, + } = { + n: 12, + explicitThis: c.explicitThis, + explicitC: c.explicitC, + explicitProperty: c.explicitProperty, + explicitVoid: c.explicitVoid + }; + reconstructed.explicitThis(10); + reconstructed.explicitProperty(11); + let explicitVoid = reconstructed.explicitVoid; + explicitVoid(12); + // assignment checking + let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any + let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; + let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; + + let unspecifiedLambda: (x: number) => number = x => x + 12; + let specifiedLambda: (this: void, x: number) => number = x => x + 12; + let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; + let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; + + + let explicitCFunction: (this: C, m: number) => number; + let explicitPropertyFunction: (this: {n: number}, m: number) => number; + c.explicitC = explicitCFunction; + c.explicitC = function(this: C, m: number) { return this.n + m }; + c.explicitProperty = explicitPropertyFunction; + c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; + c.explicitProperty = reconstructed.explicitProperty; + + // lambdas are assignable to anything + c.explicitC = m => m; + c.explicitThis = m => m; + c.explicitProperty = m => m; + + // this inside lambdas refer to outer scope + // the outer-scoped lambda at top-level is still just `any` + c.explicitC = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + c.explicitThis = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + c.explicitProperty = m => m + this.n; + ~ +!!! error TS2339: Property 'n' does not exist on type 'typeof globalThis'. + + //NOTE: this=C here, I guess? + c.explicitThis = explicitCFunction; + c.explicitThis = function(this: C, m: number) { return this.n + m }; + + // this:any compatibility + c.explicitC = function(m) { return this.n + m }; + c.explicitProperty = function(m) { return this.n + m }; + c.explicitThis = function(m) { return this.n + m }; + + // this: contextual typing + c.explicitThis = function(this, m) { return this.n + m }; + + // this: superclass compatibility + c.explicitC = function(this: B, m: number) { return this.n + m }; + + // this:void compatibility + c.explicitVoid = n => n; + + // class-based assignability + class Base1 { + x: number; + public polymorphic(this: this): number { return this.x; } + explicit(this: Base1): number { return this.x; } + static explicitStatic(this: typeof Base1): number { return this.y; } + static y: number; + } + class Derived1 extends Base1 { + y: number + } + class Base2 { + y: number + polymorphic(this: this): number { return this.y; } + explicit(this: Base1): number { return this.x; } + } + class Derived2 extends Base2 { + x: number + } + let b1 = new Base1(); + let b2 = new Base2(); + let d1 = new Derived1(); + let d2 = new Derived2(); + d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } + d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } + + // bivariance-allowed cases + d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } + d2.polymorphic = d1.explicit // ok, 'y' in { x, y } + b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } + b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } + + ////// use this-type for construction with new //// + function InterfaceThis(this: I) { + this.a = 12; + } + function LiteralTypeThis(this: {x: string}) { + this.x = "ok"; + } + function AnyThis(this: any) { + this.x = "ok"; + } + let interfaceThis = new InterfaceThis(); + let literalTypeThis = new LiteralTypeThis(); + let anyThis = new AnyThis(); + + //// type parameter inference //// + declare var f: { + (this: void, x: number): number, + call(this: (...argArray: any[]) => U, ...argArray: any[]): U; + }; + let n: number = f.call(12); + + function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index c1dcdb9829dc3..38c34bcb7a268 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -497,9 +497,7 @@ c.explicitC = m => m + this.n; >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitThis = m => m + this.n; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) @@ -507,9 +505,7 @@ c.explicitThis = m => m + this.n; >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) c.explicitProperty = m => m + this.n; >c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) @@ -517,9 +513,7 @@ c.explicitProperty = m => m + this.n; >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) >this : Symbol(globalThis) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 190, 3)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 7408a764f1a91..7082cad394100 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -580,43 +580,43 @@ c.explicitProperty = m => m; // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC = m => m + this.n : (this: C, m: number) => number +>c.explicitC = m => m + this.n : (this: C, m: number) => any >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => number +>m => m + this.n : (this: C, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any c.explicitThis = m => m + this.n; ->c.explicitThis = m => m + this.n : (this: C, m: number) => number +>c.explicitThis = m => m + this.n : (this: C, m: number) => any >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m + this.n : (this: C, m: number) => number +>m => m + this.n : (this: C, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any c.explicitProperty = m => m + this.n; ->c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => number +>c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => any >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m + this.n : (this: { n: number; }, m: number) => number +>m => m + this.n : (this: { n: number; }, m: number) => any >m : number ->m + this.n : number +>m + this.n : any >m : number ->this.n : number +>this.n : any >this : typeof globalThis ->n : number +>n : any //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; diff --git a/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts b/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts new file mode 100644 index 0000000000000..46935aabe838b --- /dev/null +++ b/tests/cases/conformance/es2019/globalThisBlockscopedProperties.ts @@ -0,0 +1,17 @@ +// @noImplicitAny: true +var x = 1 +const y = 2 +let z = 3 +globalThis.x // ok +globalThis.y // should error, no property 'y' +globalThis.z // should error, no property 'z' +globalThis['x'] // ok +globalThis['y'] // should error, no property 'y' +globalThis['z'] // should error, no property 'z' +globalThis.Float64Array // ok +globalThis.Infinity // ok + +declare let test1: (typeof globalThis)['x'] // ok +declare let test2: (typeof globalThis)['y'] // error +declare let test3: (typeof globalThis)['z'] // error +declare let themAll: keyof typeof globalThis diff --git a/tests/cases/fourslash/regexDetection.ts b/tests/cases/fourslash/regexDetection.ts index d19fc64ba79d4..0de24df9db97b 100644 --- a/tests/cases/fourslash/regexDetection.ts +++ b/tests/cases/fourslash/regexDetection.ts @@ -6,11 +6,11 @@ goTo.marker("1"); verify.not.quickInfoExists(); goTo.marker("2"); -verify.quickInfoIs("const Math: Math", +verify.quickInfoIs("var Math: Math", "An intrinsic object that provides basic mathematics functionality and constants."); goTo.marker("3"); verify.not.quickInfoExists(); goTo.marker("4"); -verify.not.quickInfoExists(); \ No newline at end of file +verify.not.quickInfoExists();