mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 20:25:48 -06:00
Forbid accessing block-scoped variables on globalThis (#30510)
* Forbid accessing const & let on globalThis It's just an error; you still get the type of the property. * Disallow access of blockscoped vars on globalThis Also change Array, Function, String, et al from `const` to `var` so that they remain accessible via `globalThis.String`. * Update baselines after lib.d.ts change Note especially the change in redefineArray, which is now allowed as long as you provide a type that is assignable to ArrayConstructor. * Remove blockscoped vars from typeof globalThis Unlike forbidding them, this removes the properties entirely. Unfortunately, this means that accessing these properties is only an error with noImplicitAny, and that error is quite confusing. Let's discuss our options. I see 3: 1. Forbid access of block-scoped vars as properties (in all flag settings), but leave them on the type. Simple to implement. 2. Remove block-scoped vars from the globalThis type. Has the bad error/flag behaviour described above, but simple to implement. 3. Remove block-scoped vars from the globalThis type. Also, forbid accessing them by executing another resolveName lookup for failed property accesses on globalThisSymbol. If the second lookup returns a blockscoped var, issue an error instead of falling back to the index signature. This seems too complex to me. * Update baselines * Better error for block-scoped usage on globalThis So that value-space references have as clear an error as type-space references. * Update fourslash tests * Fix semi-colon lint * Don't copy so much when filtering blockscoped vars
This commit is contained in:
parent
e20b87f66d
commit
32054f1c31
@ -7116,6 +7116,15 @@ namespace ts {
|
||||
let stringIndexInfo: IndexInfo | undefined;
|
||||
if (symbol.exports) {
|
||||
members = getExportsOfSymbol(symbol);
|
||||
if (symbol === globalThisSymbol) {
|
||||
const varsOnly = createMap<Symbol>() 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) {
|
||||
@ -9877,6 +9886,7 @@ namespace ts {
|
||||
getNodeLinks(accessNode!).resolvedSymbol = prop;
|
||||
}
|
||||
}
|
||||
|
||||
const propType = getTypeOfSymbol(prop);
|
||||
return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ?
|
||||
getFlowTypeOfReference(accessExpression, propType) :
|
||||
@ -9920,7 +9930,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));
|
||||
}
|
||||
@ -19515,7 +19528,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;
|
||||
|
||||
@ -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"),
|
||||
];
|
||||
|
||||
|
||||
60
src/lib/es5.d.ts
vendored
60
src/lib/es5.d.ts
vendored
@ -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<string> {
|
||||
readonly raw: ReadonlyArray<string>;
|
||||
@ -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<string> {
|
||||
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<any>;
|
||||
}
|
||||
|
||||
declare const Array: ArrayConstructor;
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
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<T>(arrayLike: ArrayLike<T>, 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<T>(arrayLike: ArrayLike<T>, 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<T>(arrayLike: ArrayLike<T>, 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<T>(arrayLike: ArrayLike<T>, 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<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array;
|
||||
|
||||
}
|
||||
declare const Float64Array: Float64ArrayConstructor;
|
||||
declare var Float64Array: Float64ArrayConstructor;
|
||||
|
||||
/////////////////////////////
|
||||
/// ECMAScript Internationalization API
|
||||
|
||||
8
src/lib/esnext.bigint.d.ts
vendored
8
src/lib/esnext.bigint.d.ts
vendored
@ -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<U>(arrayLike: ArrayLike<U>, 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<U>(arrayLike: ArrayLike<U>, 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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]]'.
|
||||
|
||||
@ -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) { }
|
||||
|
||||
@ -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))
|
||||
}
|
||||
|
||||
|
||||
@ -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){ }
|
||||
|
||||
@ -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))
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
31
tests/baselines/reference/globalThisBlockscopedProperties.js
Normal file
31
tests/baselines/reference/globalThisBlockscopedProperties.js
Normal file
@ -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
|
||||
@ -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)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -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'.
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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.
|
||||
~
|
||||
|
||||
@ -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.
|
||||
!!! related TS2728 /.ts/lib.es5.d.ts:527:13: 'String' is declared here.
|
||||
@ -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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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.
|
||||
|
||||
}
|
||||
@ -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.
|
||||
!!! 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.
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
206
tests/baselines/reference/thisTypeInFunctions.errors.txt
Normal file
206
tests/baselines/reference/thisTypeInFunctions.errors.txt
Normal file
@ -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<U>(this: (...argArray: any[]) => U, ...argArray: any[]): U;
|
||||
};
|
||||
let n: number = f.call(12);
|
||||
|
||||
function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; }
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
@ -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();
|
||||
verify.not.quickInfoExists();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user