diff --git a/Jakefile.js b/Jakefile.js index f1a714c1e26..900859f033a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -268,7 +268,6 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); * @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code * @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation * @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal - * @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option * @param {boolean} opts.inlineSourceMap: true if compiler should inline sourceMap * @param {Array} opts.types: array of types to include in compilation * @param callback: a function to execute after the compilation process ends @@ -321,9 +320,6 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts } else { options += " -sourcemap"; - if (!opts.noMapRoot) { - options += " -mapRoot file:///" + path.resolve(path.dirname(outFile)); - } } } else { @@ -527,7 +523,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () { // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); -compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false, { noMapRoot: true }); +compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js"); var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js"); @@ -582,7 +578,6 @@ compileFile( keepComments: true, noResolve: false, stripInternal: true, - noMapRoot: true, inlineSourceMap: true }); @@ -807,7 +802,8 @@ function runConsoleTests(defaultReporter, runInParallel) { var debug = process.env.debug || process.env.d; var inspect = process.env.inspect; - tests = process.env.test || process.env.tests || process.env.t; + var testTimeout = process.env.timeout || defaultTestTimeout; + var tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var stackTraceLimit = process.env.stackTraceLimit; var testConfigFile = 'test.config'; @@ -825,7 +821,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } while (fs.existsSync(taskConfigsFolder)); fs.mkdirSync(taskConfigsFolder); - workerCount = process.env.workerCount || os.cpus().length; + workerCount = process.env.workerCount || process.env.p || os.cpus().length; } if (tests || light || taskConfigsFolder) { @@ -930,7 +926,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } } -var testTimeout = 20000; +var defaultTestTimeout = 22000; desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true."); task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function () { runConsoleTests('min', /*runInParallel*/ true); diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/nextLineRule.ts index b149d09eb38..fa03746afc6 100644 --- a/scripts/tslint/nextLineRule.ts +++ b/scripts/tslint/nextLineRule.ts @@ -18,7 +18,7 @@ export class Rule extends Lint.Rules.AbstractRule { function walk(ctx: Lint.WalkContext, checkCatch: boolean, checkElse: boolean): void { const { sourceFile } = ctx; - function recur(node: ts.Node): void { + ts.forEachChild(sourceFile, function recur(node) { switch (node.kind) { case ts.SyntaxKind.IfStatement: checkIf(node as ts.IfStatement); @@ -28,7 +28,7 @@ function walk(ctx: Lint.WalkContext, checkCatch: boolean, checkElse: boole break; } ts.forEachChild(node, recur); - } + }); function checkIf(node: ts.IfStatement): void { const { thenStatement, elseStatement } = node; diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d55f3650c10..22209e2e41e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2333,7 +2333,7 @@ namespace ts { // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports' // is still pointing to 'module.exports'. // We do not want to consider this as 'export=' since a module can have only one of these. - // Similarlly we do not want to treat 'module.exports = exports' as an 'export='. + // Similarly we do not want to treat 'module.exports = exports' as an 'export='. const assignedExpression = getRightMostAssignedExpression(node.right); if (isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { // Mark it as a module in case there are no other exports in the file @@ -2741,6 +2741,10 @@ namespace ts { transformFlags |= TransformFlags.AssertES2015; } + if (expression.kind === SyntaxKind.ImportKeyword) { + transformFlags |= TransformFlags.ContainsDynamicImport; + } + node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4db00d8d84b..9f85dc1e552 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -213,6 +213,11 @@ namespace ts { getSuggestionForNonexistentProperty, getSuggestionForNonexistentSymbol, getBaseConstraintOfType, + getJsxNamespace, + resolveNameAtLocation(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined { + location = getParseTreeNode(location); + return resolveName(location, name, meaning, /*nameNotFoundMessage*/ undefined, name); + }, }; const tupleTypes: GenericType[] = []; @@ -738,6 +743,7 @@ namespace ts { if (declarationFile !== useFile) { if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || + isInTypeQuery(usage) || isInAmbientContext(declaration)) { // nodes are in different files and order cannot be determined return true; @@ -850,7 +856,7 @@ namespace ts { location: Node | undefined, name: string, meaning: SymbolFlags, - nameNotFoundMessage: DiagnosticMessage, + nameNotFoundMessage: DiagnosticMessage | undefined, nameArg: string | Identifier, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); @@ -1098,13 +1104,13 @@ namespace ts { if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestionForNonexistentSymbol(originalLocation, name, meaning); if (suggestion) { - suggestionCount++; error(errorLocation, suggestedNameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), suggestion); } } if (!suggestion) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } + suggestionCount++; } } return undefined; @@ -1367,6 +1373,9 @@ namespace ts { // An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point' // property with the type/namespace side interface 'Point'. function combineValueAndTypeSymbols(valueSymbol: Symbol, typeSymbol: Symbol): Symbol { + if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { + return unknownSymbol; + } if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) { return valueSymbol; } @@ -1467,8 +1476,15 @@ namespace ts { } } + /** + * Indicates that a symbol is an alias that does not merge with a local declaration. + */ + function isNonLocalAlias(symbol: Symbol, excludes = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace) { + return symbol && (symbol.flags & (SymbolFlags.Alias | excludes)) === SymbolFlags.Alias; + } + function resolveSymbol(symbol: Symbol, dontResolveAlias?: boolean): Symbol { - const shouldResolve = !dontResolveAlias && symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)); + const shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); return shouldResolve ? resolveAlias(symbol) : symbol; } @@ -2287,10 +2303,10 @@ namespace ts { function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName); - Debug.assert(typeNode !== undefined, "should always get typenode?"); + Debug.assert(typeNode !== undefined, "should always get typenode"); const options = { removeComments: true }; const writer = createTextWriter(""); - const printer = createPrinter(options, writer); + const printer = createPrinter(options); const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ sourceFile, writer); const result = writer.getText(); @@ -4148,7 +4164,7 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); + const elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); if (declaration.dotDotDotToken) { // Rest element has an array type with the same element type as the parent type type = createArrayType(elementType); @@ -6046,7 +6062,8 @@ namespace ts { } } return arrayFrom(props.values()); - } else { + } + else { return getPropertiesOfType(type); } } @@ -7840,11 +7857,9 @@ namespace ts { if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } - left = filterType(left, t => !(t.flags & TypeFlags.Nullable)); if (left.flags & TypeFlags.Never) { return right; } - right = filterType(right, t => !(t.flags & TypeFlags.Nullable)); if (right.flags & TypeFlags.Never) { return left; } @@ -8595,6 +8610,12 @@ namespace ts { /** * This is *not* a bi-directional relationship. * If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'. + * + * A type S is comparable to a type T if some (but not necessarily all) of the possible values of S are also possible values of T. + * It is used to check following cases: + * - the types of the left and right sides of equality/inequality operators (`===`, `!==`, `==`, `!=`). + * - the types of `case` clause expressions and their respective `switch` expressions. + * - the type of an expression in a type assertion with the type being asserted. */ function isTypeComparableTo(source: Type, target: Type): boolean { return isTypeRelatedTo(source, target, comparableRelation); @@ -8822,6 +8843,7 @@ namespace ts { function isEmptyObjectType(type: Type): boolean { return type.flags & TypeFlags.Object ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & TypeFlags.NonPrimitive ? true : type.flags & TypeFlags.Union ? forEach((type).types, isEmptyObjectType) : type.flags & TypeFlags.Intersection ? !forEach((type).types, t => !isEmptyObjectType(t)) : false; @@ -8939,6 +8961,7 @@ namespace ts { let expandingFlags: number; let depth = 0; let overflow = false; + let isIntersectionConstituent = false; Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); @@ -9021,7 +9044,6 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { - let result: Ternary; source = getRegularTypeOfLiteralOrUniqueType(source); target = getRegularTypeOfLiteralOrUniqueType(target); // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -9049,32 +9071,40 @@ namespace ts { } } + if (relation !== comparableRelation && + !(source.flags & TypeFlags.UnionOrIntersection) && + !(target.flags & TypeFlags.Union) && + !isIntersectionConstituent && + source !== globalObjectType && + getPropertiesOfType(source).length > 0 && + isWeakType(target) && + !hasCommonProperties(source, target)) { + if (reportErrors) { + reportError(Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target)); + } + return Ternary.False; + } + + let result = Ternary.False; const saveErrorInfo = errorInfo; + const saveIsIntersectionConstituent = isIntersectionConstituent; + isIntersectionConstituent = false; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & TypeFlags.Union) { - if (relation === comparableRelation) { - result = someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); - } - else { - result = eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); - } - if (result) { - return result; - } + result = relation === comparableRelation ? + someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)) : + eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); } else { if (target.flags & TypeFlags.Union) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) { - return result; - } + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive)); } else if (target.flags & TypeFlags.Intersection) { - if (result = typeRelatedToEachType(source, target as IntersectionType, reportErrors)) { - return result; - } + isIntersectionConstituent = true; + result = typeRelatedToEachType(source, target as IntersectionType, reportErrors); } else if (source.flags & TypeFlags.Intersection) { // Check to see if any constituents of the intersection are immediately related to the target. @@ -9090,20 +9120,18 @@ namespace ts { // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { - return result; - } + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - - if (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable) { + if (!result && (source.flags & TypeFlags.StructuredOrTypeVariable || target.flags & TypeFlags.StructuredOrTypeVariable)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; - return result; } } } - if (reportErrors) { + isIntersectionConstituent = saveIsIntersectionConstituent; + + if (!result && reportErrors) { if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } @@ -9112,7 +9140,7 @@ namespace ts { } reportRelationError(headMessage, source, target); } - return Ternary.False; + return result; } function isIdenticalTo(source: Type, target: Type): Ternary { @@ -9211,7 +9239,7 @@ namespace ts { } } - function typeRelatedToEachType(source: Type, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { + function typeRelatedToEachType(source: Type, target: IntersectionType, reportErrors: boolean): Ternary { let result = Ternary.True; const targetTypes = target.types; for (const targetType of targetTypes) { @@ -9513,7 +9541,6 @@ namespace ts { const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral); for (const targetProp of properties) { const sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { @@ -9592,6 +9619,34 @@ namespace ts { return result; } + /** + * A type is 'weak' if it is an object type with at least one optional property + * and no required properties, call/construct signatures or index signatures + */ + function isWeakType(type: Type): boolean { + if (type.flags & TypeFlags.Object) { + const resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && + !resolved.stringIndexInfo && !resolved.numberIndexInfo && + resolved.properties.length > 0 && + every(resolved.properties, p => !!(p.flags & SymbolFlags.Optional)); + } + if (type.flags & TypeFlags.Intersection) { + return every((type).types, isWeakType); + } + return false; + } + + function hasCommonProperties(source: Type, target: Type) { + const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); + for (const prop of getPropertiesOfType(source)) { + if (isKnownProperty(target, prop.name, isComparingJsxAttributes)) { + return true; + } + } + return false; + } + function propertiesIdenticalTo(source: Type, target: Type): Ternary { if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) { return Ternary.False; @@ -10440,7 +10495,7 @@ namespace ts { const objectFlags = getObjectFlags(type); return !!(type.flags & TypeFlags.TypeVariable || objectFlags & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeVariables) || - objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || + objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || objectFlags & ObjectFlags.Mapped || type.flags & TypeFlags.UnionOrIntersection && couldUnionOrIntersectionContainTypeVariables(type)); } @@ -11122,12 +11177,12 @@ namespace ts { function getTypeOfDestructuredArrayElement(type: Type, index: number) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || + checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type: Type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node: BinaryExpression): Type { @@ -12206,7 +12261,9 @@ namespace ts { return getTypeOfSymbol(symbol); } - if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + // We should only mark aliases as referenced if there isn't a local value declaration + // for the symbol. + if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); } @@ -13101,7 +13158,7 @@ namespace ts { const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); + || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); } return undefined; } @@ -13243,13 +13300,13 @@ namespace ts { return node ? node.contextualMapper : identityMapper; } - // If the given type is an object or union type, if that type has a single signature, and if - // that signature is non-generic, return the signature. Otherwise return undefined. - function getNonGenericSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature { + // If the given type is an object or union type with a single signature, and if that signature has at + // least as many parameters as the given function, return the signature. Otherwise return undefined. + function getContextualCallSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature { const signatures = getSignaturesOfStructuredType(type, SignatureKind.Call); if (signatures.length === 1) { const signature = signatures[0]; - if (!signature.typeParameters && !isAritySmaller(signature, node)) { + if (!isAritySmaller(signature, node)) { return signature; } } @@ -13300,12 +13357,12 @@ namespace ts { return undefined; } if (!(type.flags & TypeFlags.Union)) { - return getNonGenericSignature(type, node); + return getContextualCallSignature(type, node); } let signatureList: Signature[]; const types = (type).types; for (const current of types) { - const signature = getNonGenericSignature(current, node); + const signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature @@ -13339,7 +13396,7 @@ namespace ts { } const arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node: BindingElement | Expression): boolean { @@ -13368,7 +13425,7 @@ namespace ts { // if there is no index type / iterated type. const restArrayType = checkExpression((e).expression, checkMode); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); + getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); if (restElementType) { elementTypes.push(restElementType); } @@ -14364,7 +14421,7 @@ namespace ts { checkJsxPreconditions(node); // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined; + const reactRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined; const reactNamespace = getJsxNamespace(); const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace); if (reactSym) { @@ -14393,8 +14450,10 @@ namespace ts { function isKnownProperty(targetType: Type, name: string, isComparingJsxAttributes: boolean): boolean { if (targetType.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(targetType); - if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || - getPropertyOfType(targetType, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { + if (resolved.stringIndexInfo || + resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(targetType, name) || + isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } @@ -14733,6 +14792,7 @@ namespace ts { const maximumLengthDifference = Math.min(3, name.length * 0.34); let bestDistance = Number.MAX_VALUE; let bestCandidate = undefined; + let justCheckExactMatches = false; if (name.length > 30) { return undefined; } @@ -14745,6 +14805,9 @@ namespace ts { if (candidateName === name) { return candidate; } + if (justCheckExactMatches) { + continue; + } if (candidateName.length < 3 || name.length < 3 || candidateName === "eval" || @@ -14760,7 +14823,8 @@ namespace ts { continue; } if (distance < 3) { - return candidate; + justCheckExactMatches = true; + bestCandidate = candidate; } else if (distance < bestDistance) { bestDistance = distance; @@ -15170,11 +15234,21 @@ namespace ts { // We clone the contextual mapper to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - const mapper = cloneTypeMapper(getContextualMapper(node)); - const instantiatedType = instantiateType(contextualType, mapper); - const returnType = getReturnTypeOfSignature(signature); - // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, instantiatedType, returnType, InferencePriority.ReturnType); + const instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); + // If the contextual type is a generic pure function type, we instantiate the type with + // its own type parameters and type arguments. This ensures that the type parameters are + // not erased to type any during type inference such that they can be inferred as actual + // types from the contextual type. For example: + // declare function arrayMap(f: (x: T) => U): (a: T[]) => U[]; + // const boxElements: (a: A[]) => { value: A }[] = arrayMap(value => ({ value })); + // Above, the type of the 'value' parameter is inferred to be 'A'. + const contextualSignature = getSingleCallSignature(instantiatedType); + const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + instantiatedType; + const inferenceTargetType = getReturnTypeOfSignature(signature); + // Inferences made from return types have lower priority than all other inferences. + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, InferencePriority.ReturnType); } } @@ -16081,7 +16155,7 @@ namespace ts { const callSignatures = getSignaturesOfType(expressionType, SignatureKind.Call); if (callSignatures.length) { const signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { + if (!isJavaScriptConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } if (getThisTypeOfSignature(signature) === voidType) { @@ -16308,10 +16382,30 @@ namespace ts { return getNodeLinks(node).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(node); } + /** + * Indicates whether a declaration can be treated as a constructor in a JavaScript + * file. + */ + function isJavaScriptConstructor(node: Declaration): boolean { + if (isInJavaScriptFile(node)) { + // If the node has a @class tag, treat it like a constructor. + if (getJSDocClassTag(node)) return true; + + // If the symbol of the node has members, treat it like a constructor. + const symbol = isFunctionDeclaration(node) || isFunctionExpression(node) ? getSymbolOfNode(node) : + isVariableDeclaration(node) && isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + undefined; + + return symbol && symbol.members !== undefined; + } + + return false; + } + function getInferredClassType(symbol: Symbol) { const links = getSymbolLinks(symbol); if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol), emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); + links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); } return links.inferredClassType; } @@ -16351,7 +16445,7 @@ namespace ts { if (funcSymbol && isDeclarationOfFunctionOrClassExpression(funcSymbol)) { funcSymbol = getSymbolOfNode((funcSymbol.valueDeclaration).initializer); } - if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) { + if (funcSymbol && funcSymbol.flags & SymbolFlags.Function && (funcSymbol.members || getJSDocClassTag(funcSymbol.valueDeclaration))) { return getInferredClassType(funcSymbol); } else if (noImplicitAny) { @@ -16428,6 +16522,35 @@ namespace ts { return false; } + function checkImportCallExpression(node: ImportCall): Type { + // Check grammar of dynamic import + checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node); + + if (node.arguments.length === 0) { + return createPromiseReturnType(node, anyType); + } + const specifier = node.arguments[0]; + const specifierType = checkExpressionCached(specifier); + // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + for (let i = 1; i < node.arguments.length; ++i) { + checkExpressionCached(node.arguments[i]); + } + + if (specifierType.flags & TypeFlags.Undefined || specifierType.flags & TypeFlags.Null || !isTypeAssignableTo(specifierType, stringType)) { + error(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); + } + + // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal + const moduleSymbol = resolveExternalModuleName(node, specifier); + if (moduleSymbol) { + const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + if (esModuleSymbol) { + return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol)); + } + } + return createPromiseReturnType(node, anyType); + } + function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { return getReturnTypeOfSignature(getResolvedSignature(node)); } @@ -16606,14 +16729,18 @@ namespace ts { return emptyObjectType; } - function createPromiseReturnType(func: FunctionLikeDeclaration, promisedType: Type) { + function createPromiseReturnType(func: FunctionLikeDeclaration | ImportCall, promisedType: Type) { const promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); + error(func, isImportCall(func) ? + Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : + Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { - error(func, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); + error(func, isImportCall(func) ? + Diagnostics.A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option : + Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; @@ -17265,7 +17392,7 @@ namespace ts { // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; const elements = node.elements; for (let i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); @@ -17973,6 +18100,10 @@ namespace ts { case SyntaxKind.ElementAccessExpression: return checkIndexedAccess(node); case SyntaxKind.CallExpression: + if ((node).expression.kind === SyntaxKind.ImportKeyword) { + return checkImportCallExpression(node); + } + /* falls through */ case SyntaxKind.NewExpression: return checkCallExpression(node); case SyntaxKind.TaggedTemplateExpression: @@ -20416,12 +20547,12 @@ namespace ts { return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean): Type { + function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterables: boolean): Type { if (isTypeAny(inputType)) { return inputType; } - return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, /*checkAssignability*/ true) || anyType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterables, /*checkAssignability*/ true) || anyType; } /** @@ -20429,16 +20560,16 @@ namespace ts { * we want to get the iterated type of an iterable for ES2015 or later, or the iterated type * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ - function getIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterable: boolean, checkAssignability: boolean): Type { + function getIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean, allowAsyncIterables: boolean, checkAssignability: boolean): Type { const uplevelIteration = languageVersion >= ScriptTarget.ES2015; const downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. - if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + if (uplevelIteration || downlevelIteration || allowAsyncIterables) { // We only report errors for an invalid iterable type in ES2015 or higher. - const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); if (iteratedType || uplevelIteration) { return iteratedType; } @@ -20552,79 +20683,75 @@ namespace ts { * For a **for-await-of** statement or a `yield*` in an async generator we will look for * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, isAsyncIterable: boolean, allowNonAsyncIterables: boolean, checkAssignability: boolean): Type | undefined { + function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: boolean): Type | undefined { if (isTypeAny(type)) { return undefined; } - const typeAsIterable = type; - if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { - return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; - } + return mapType(type, getIteratedType); - if (isAsyncIterable) { - // As an optimization, if the type is an instantiation of the global `AsyncIterable` - // or the global `AsyncIterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { - return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0]; + function getIteratedType(type: Type) { + const typeAsIterable = type; + if (allowAsyncIterables) { + if (typeAsIterable.iteratedTypeOfAsyncIterable) { + return typeAsIterable.iteratedTypeOfAsyncIterable; + } + + // As an optimization, if the type is an instantiation of the global `AsyncIterable` + // or the global `AsyncIterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0]; + } } - } - if (!isAsyncIterable || allowNonAsyncIterables) { - // As an optimization, if the type is an instantiation of the global `Iterable` or - // `IterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { - return isAsyncIterable - ? typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments[0] - : typeAsIterable.iteratedTypeOfIterable = (type).typeArguments[0]; + if (allowSyncIterables) { + if (typeAsIterable.iteratedTypeOfIterable) { + return typeAsIterable.iteratedTypeOfIterable; + } + + // As an optimization, if the type is an instantiation of the global `Iterable` or + // `IterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfIterable = (type).typeArguments[0]; + } } - } - let iteratorMethodSignatures: Signature[]; - let isNonAsyncIterable = false; - if (isAsyncIterable) { - const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("asyncIterator")); - if (isTypeAny(iteratorMethod)) { + const asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("asyncIterator")); + const methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator"))); + if (isTypeAny(methodType)) { return undefined; } - iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); - } - if (!isAsyncIterable || (allowNonAsyncIterables && !some(iteratorMethodSignatures))) { - const iteratorMethod = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorMethod)) { + const signatures = methodType && getSignaturesOfType(methodType, SignatureKind.Call); + if (!some(signatures)) { + if (errorNode) { + error(errorNode, + allowAsyncIterables + ? Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + // only report on the first error + errorNode = undefined; + } return undefined; } - iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, SignatureKind.Call); - isNonAsyncIterable = true; - } - if (some(iteratorMethodSignatures)) { - const iteratorMethodReturnType = getUnionType(map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - const iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); + const returnType = getUnionType(map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + const iteratedType = getIteratedTypeOfIterator(returnType, errorNode, /*isAsyncIterator*/ !!asyncMethodType); if (checkAssignability && errorNode && iteratedType) { // If `checkAssignability` was specified, we were called from // `checkIteratedTypeOrElementType`. As such, we need to validate that // the type passed in is actually an Iterable. - checkTypeAssignableTo(type, isNonAsyncIterable - ? createIterableType(iteratedType) - : createAsyncIterableType(iteratedType), errorNode); + checkTypeAssignableTo(type, asyncMethodType + ? createAsyncIterableType(iteratedType) + : createIterableType(iteratedType), errorNode); } - return isAsyncIterable + + return asyncMethodType ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType : typeAsIterable.iteratedTypeOfIterable = iteratedType; } - - if (errorNode) { - error(errorNode, - isAsyncIterable - ? Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator - : Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - - return undefined; } /** @@ -20724,7 +20851,7 @@ namespace ts { return undefined; } - return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, isAsyncGenerator, /*allowNonAsyncIterables*/ false, /*checkAssignability*/ false) + return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, /*allowAsyncIterables*/ isAsyncGenerator, /*allowSyncIterables*/ !isAsyncGenerator, /*checkAssignability*/ false) || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); } @@ -21372,10 +21499,6 @@ namespace ts { } } - function isAccessor(kind: SyntaxKind): boolean { - return kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor; - } - function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { @@ -22937,7 +23060,7 @@ namespace ts { Debug.assert(expr.parent.kind === SyntaxKind.ArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; const typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; + const elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, indexOf((expr.parent).elements, expr), elementType || unknownType); } @@ -23000,12 +23123,12 @@ namespace ts { return symbols; } else if (symbol.flags & SymbolFlags.Transient) { - if ((symbol as SymbolLinks).leftSpread) { - const links = symbol as SymbolLinks; - return [...getRootSymbols(links.leftSpread), ...getRootSymbols(links.rightSpread)]; + const transient = symbol as TransientSymbol; + if (transient.leftSpread) { + return [...getRootSymbols(transient.leftSpread), ...getRootSymbols(transient.rightSpread)]; } - if ((symbol as SymbolLinks).syntheticOrigin) { - return getRootSymbols((symbol as SymbolLinks).syntheticOrigin); + if (transient.syntheticOrigin) { + return getRootSymbols(transient.syntheticOrigin); } let target: Symbol; @@ -23110,7 +23233,9 @@ namespace ts { node = getParseTreeNode(node, isIdentifier); if (node) { const symbol = getReferencedValueSymbol(node); - if (symbol && symbol.flags & SymbolFlags.Alias) { + // We should only get the declaration of an alias if there isn't a local value + // declaration for the symbol + if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -24880,7 +25005,7 @@ namespace ts { function checkGrammarStatementInAmbientContext(node: Node): boolean { if (isInAmbientContext(node)) { // An accessors is already reported about the ambient context - if (isAccessor(node.parent.kind)) { + if (isAccessor(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = true; } @@ -24949,6 +25074,27 @@ namespace ts { }); return result; } + + function checkGrammarImportCallExpression(node: ImportCall): boolean { + if (modulekind === ModuleKind.ES2015) { + return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules); + } + + if (node.typeArguments) { + return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_have_type_arguments); + } + + const arguments = node.arguments; + if (arguments.length !== 1) { + return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument); + } + + // see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import. + // parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import. + if (isSpreadElement(arguments[0])) { + return grammarErrorOnNode(arguments[0], Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); + } + } } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e612378671d..23efd047e46 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -100,11 +100,12 @@ namespace ts { "umd": ModuleKind.UMD, "es6": ModuleKind.ES2015, "es2015": ModuleKind.ES2015, + "esnext": ModuleKind.ESNext }), paramType: Diagnostics.KIND, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_es2015_or_ESNext, }, { name: "lib", @@ -1042,7 +1043,7 @@ namespace ts { for (let i = 0; i < nameColumn.length; i++) { const optionName = nameColumn[i]; const description = descriptionColumn[i]; - result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + result.push(optionName && `${tab}${tab}${optionName}${ description && (makePadding(marginLength - optionName.length + 2) + description)}`); } if (configurations.files && configurations.files.length) { result.push(`${tab}},`); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d1d21e94694..747801f83bd 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -473,7 +473,7 @@ namespace ts { * @param array The array to map. * @param mapfn The callback used to map the result into one or more values. */ - export function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[] { + export function flatMap(array: T[] | undefined, mapfn: (x: T, i: number) => U | U[] | undefined): U[] | undefined { let result: U[]; if (array) { result = []; @@ -752,6 +752,14 @@ namespace ts { return to; } + /** + * Gets the actual offset into an array for a relative offset. Negative offsets indicate a + * position offset from the end of the array. + */ + function toOffset(array: any[], offset: number) { + return offset < 0 ? array.length + offset : offset; + } + /** * Appends a range of value to an array, returning the array. * @@ -759,11 +767,19 @@ namespace ts { * is created if `value` was appended. * @param from The values to append to the array. If `from` is `undefined`, nothing is * appended. If an element of `from` is `undefined`, that element is not appended. + * @param start The offset in `from` at which to start copying values. + * @param end The offset in `from` at which to stop copying values (non-inclusive). */ - export function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined { + export function addRange(to: T[] | undefined, from: T[] | undefined, start?: number, end?: number): T[] | undefined { if (from === undefined) return to; - for (const v of from) { - to = append(to, v); + if (to === undefined) return from.slice(start, end); + start = start === undefined ? 0 : toOffset(from, start); + end = end === undefined ? from.length : toOffset(from, end); + for (let i = start; i < end && i < from.length; i++) { + const v = from[i]; + if (v !== undefined) { + to.push(from[i]); + } } return to; } @@ -788,28 +804,38 @@ namespace ts { return true; } + /** + * Returns the element at a specific offset in an array if non-empty, `undefined` otherwise. + * A negative offset indicates the element should be retrieved from the end of the array. + */ + export function elementAt(array: T[] | undefined, offset: number): T | undefined { + if (array) { + offset = toOffset(array, offset); + if (offset < array.length) { + return array[offset]; + } + } + return undefined; + } + /** * Returns the first element of an array if non-empty, `undefined` otherwise. */ - export function firstOrUndefined(array: T[]): T { - return array && array.length > 0 - ? array[0] - : undefined; + export function firstOrUndefined(array: T[]): T | undefined { + return elementAt(array, 0); } /** * Returns the last element of an array if non-empty, `undefined` otherwise. */ - export function lastOrUndefined(array: T[]): T { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; + export function lastOrUndefined(array: T[]): T | undefined { + return elementAt(array, -1); } /** * Returns the only element of an array if it contains only one element, `undefined` otherwise. */ - export function singleOrUndefined(array: T[]): T { + export function singleOrUndefined(array: T[]): T | undefined { return array && array.length === 1 ? array[0] : undefined; @@ -1137,6 +1163,15 @@ namespace ts { return Array.isArray ? Array.isArray(value) : value instanceof Array; } + export function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined { + return value !== undefined && test(value) ? value : undefined; + } + + export function cast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut { + if (value !== undefined && test(value)) return value; + Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`); + } + /** Does nothing. */ export function noop(): void {} @@ -2214,6 +2249,7 @@ namespace ts { getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; getSignatureConstructor(): new (checker: TypeChecker) => Signature; + getSourceMapSourceConstructor(): new (fileName: string, text: string, skipTrivia?: (pos: number) => number) => SourceMapSource; } function Symbol(this: Symbol, flags: SymbolFlags, name: string) { @@ -2222,8 +2258,11 @@ namespace ts { this.declarations = undefined; } - function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) { + function Type(this: Type, checker: TypeChecker, flags: TypeFlags) { this.flags = flags; + if (Debug.isDebugging) { + this.checker = checker; + } } function Signature() { @@ -2241,6 +2280,12 @@ namespace ts { this.original = undefined; } + function SourceMapSource(this: SourceMapSource, fileName: string, text: string, skipTrivia?: (pos: number) => number) { + this.fileName = fileName; + this.text = text; + this.skipTrivia = skipTrivia || (pos => pos); + } + export let objectAllocator: ObjectAllocator = { getNodeConstructor: () => Node, getTokenConstructor: () => Node, @@ -2248,7 +2293,8 @@ namespace ts { getSourceFileConstructor: () => Node, getSymbolConstructor: () => Symbol, getTypeConstructor: () => Type, - getSignatureConstructor: () => Signature + getSignatureConstructor: () => Signature, + getSourceMapSourceConstructor: () => SourceMapSource, }; export const enum AssertionLevel { @@ -2260,24 +2306,42 @@ namespace ts { export namespace Debug { export let currentAssertionLevel = AssertionLevel.None; + export let isDebugging = false; export function shouldAssert(level: AssertionLevel): boolean { return currentAssertionLevel >= level; } - export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void { + export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string, stackCrawlMark?: Function): void { if (!expression) { - let verboseDebugString = ""; if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); + message += "\r\nVerbose Debug Information: " + verboseDebugInfo(); } - debugger; - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); + fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); } } - export function fail(message?: string): void { - Debug.assert(/*expression*/ false, message); + export function fail(message?: string, stackCrawlMark?: Function): void { + debugger; + const e = new Error(message ? `Debug Failure. ` : "Debug Failure."); + if ((Error).captureStackTrace) { + (Error).captureStackTrace(e, stackCrawlMark || fail); + } + throw e; + } + + export function getFunctionName(func: Function) { + if (typeof func !== "function") { + return ""; + } + else if (func.hasOwnProperty("name")) { + return (func).name; + } + else { + const text = Function.prototype.toString.call(func); + const match = /^function\s+([\w\$]+)\s*\(/.exec(text); + return match ? match[1] : ""; + } } } @@ -2443,4 +2507,4 @@ namespace ts { export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } -} +} \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3832e865a04..42f2ed51614 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -883,14 +883,30 @@ "category": "Error", "code": 1322 }, - "Unique 'symbol()' types are only allowed on variables and properties.": { + "Dynamic import cannot be used when targeting ECMAScript 2015 modules.": { "category": "Error", "code": 1323 }, - "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "Dynamic import must have one specifier as an argument.": { "category": "Error", "code": 1324 }, + "Specifier of dynamic import cannot be spread element.": { + "category": "Error", + "code": 1325 + }, + "Dynamic import cannot have type arguments": { + "category": "Error", + "code": 1326 + }, + "Unique 'symbol()' types are only allowed on variables and properties.": { + "category": "Error", + "code": 1327 + }, + "Unique 'symbol()' types may not be used on a variable declaration with a binding name.": { + "category": "Error", + "code": 1328 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -1888,6 +1904,10 @@ "category": "Error", "code": 2558 }, + "Type '{0}' has no properties in common with type '{1}'.": { + "category": "Error", + "code": 2559 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 @@ -1932,10 +1952,6 @@ "category": "Error", "code": 2649 }, - "Cannot emit namespaced JSX elements in React.": { - "category": "Error", - "code": 2650 - }, "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { "category": "Error", "code": 2651 @@ -2168,14 +2184,22 @@ "category": "Error", "code": 2710 }, - "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.": { + "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": { "category": "Error", "code": 2711 }, - "Duplicate declaration '{0}'.": { + "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.": { "category": "Error", "code": 2712 }, + "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.": { + "category": "Error", + "code": 2713 + }, + "Duplicate declaration '{0}'.": { + "category": "Error", + "code": 2714 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2642,7 +2666,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'.": { + "Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { "category": "Message", "code": 6016 }, @@ -3378,6 +3402,11 @@ "category": "Error", "code": 7035 }, + "Dynamic import's specifier must be of type 'string', but here has type '{0}'.": { + "category": "Error", + "code": 7036 + }, + "You cannot rename this element.": { "category": "Error", "code": 8000 @@ -3572,11 +3601,11 @@ "category": "Message", "code": 90015 }, - "Add declaration for missing property '{0}'.": { + "Declare property '{0}'.": { "category": "Message", "code": 90016 }, - "Add index signature for missing property '{0}'.": { + "Add index signature for property '{0}'.": { "category": "Message", "code": 90017 }, @@ -3600,7 +3629,15 @@ "category": "Message", "code": 90022 }, - + "Declare method '{0}'.": { + "category": "Message", + "code": 90023 + }, + "Declare static method '{0}'.": { + "category": "Message", + "code": 90024 + }, + "Convert function to an ES2015 class": { "category": "Message", "code": 95001 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3c04aa068f0..4a98eb19cd3 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -678,6 +678,7 @@ namespace ts { case SyntaxKind.SuperKeyword: case SyntaxKind.TrueKeyword: case SyntaxKind.ThisKeyword: + case SyntaxKind.ImportKeyword: writeTokenNode(node); return; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 943d011c350..aaf7d958072 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2134,6 +2134,24 @@ namespace ts { // Compound nodes + export function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression; + export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + export function createImmediatelyInvokedFunctionExpression(statements: Statement[], param?: ParameterDeclaration, paramValue?: Expression) { + return createCall( + createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ param ? [param] : [], + /*type*/ undefined, + createBlock(statements, /*multiLine*/ true) + ), + /*typeArguments*/ undefined, + /*argumentsArray*/ paramValue ? [paramValue] : [] + ); + } + export function createComma(left: Expression, right: Expression) { return createBinary(left, SyntaxKind.CommaToken, right); } @@ -2296,15 +2314,24 @@ namespace ts { /** * Sets a custom text range to use when emitting source maps. */ - export function setSourceMapRange(node: T, range: TextRange | undefined) { + export function setSourceMapRange(node: T, range: SourceMapRange | undefined) { getOrCreateEmitNode(node).sourceMapRange = range; return node; } + let SourceMapSource: new (fileName: string, text: string, skipTrivia?: (pos: number) => number) => SourceMapSource; + + /** + * Create an external source map source file reference + */ + export function createSourceMapSource(fileName: string, text: string, skipTrivia?: (pos: number) => number): SourceMapSource { + return new (SourceMapSource || (SourceMapSource = objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia); + } + /** * Gets the TextRange to use for source maps for a token of a node. */ - export function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange | undefined { + export function getTokenSourceMapRange(node: Node, token: SyntaxKind): SourceMapRange | undefined { const emitNode = node.emitNode; const tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; return tokenSourceMapRanges && tokenSourceMapRanges[token]; @@ -2313,7 +2340,7 @@ namespace ts { /** * Sets the TextRange to use for source maps for a token of a node. */ - export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange | undefined) { + export function setTokenSourceMapRange(node: T, token: SyntaxKind, range: SourceMapRange | undefined) { const emitNode = getOrCreateEmitNode(node); const tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []); tokenSourceMapRanges[token] = range; @@ -2485,6 +2512,7 @@ namespace ts { helpers } = sourceEmitNode; if (!destEmitNode) destEmitNode = {}; + // We are using `.slice()` here in case `destEmitNode.leadingComments` is pushed to later. if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; @@ -3216,6 +3244,26 @@ namespace ts { return isBlock(node) ? node : setTextRange(createBlock([setTextRange(createReturn(node), node)], multiLine), node); } + export function convertFunctionDeclarationToExpression(node: FunctionDeclaration) { + Debug.assert(!!node.body); + const updated = createFunctionExpression( + node.modifiers, + node.asteriskToken, + node.name, + node.typeParameters, + node.parameters, + node.type, + node.body + ); + setOriginalNode(updated, node); + setTextRange(updated, node); + if (node.startsOnNewLine) { + updated.startsOnNewLine = true; + } + aggregateTransformFlags(updated); + return updated; + } + function isUseStrictPrologue(node: ExpressionStatement): boolean { return (node.expression as StringLiteral).text === "use strict"; } @@ -3614,7 +3662,7 @@ namespace ts { if (kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction) { const mutableCall = getMutableClone(emittedExpression); mutableCall.expression = setTextRange(createParen(callee), callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); + return recreateOuterExpressions(expression, mutableCall, OuterExpressionKinds.PartiallyEmittedExpressions); } } else { @@ -3656,22 +3704,6 @@ namespace ts { } } - /** - * Clones a series of not-emitted expressions with a new inner expression. - * - * @param originalOuterExpression The original outer expression. - * @param newInnerExpression The new inner expression. - */ - function recreatePartiallyEmittedExpressions(originalOuterExpression: Expression, newInnerExpression: Expression) { - if (isPartiallyEmittedExpression(originalOuterExpression)) { - const clone = getMutableClone(originalOuterExpression); - clone.expression = recreatePartiallyEmittedExpressions(clone.expression, newInnerExpression); - return clone; - } - - return newInnerExpression; - } - function getLeftmostExpression(node: Expression): Expression { while (true) { switch (node.kind) { @@ -3718,6 +3750,22 @@ namespace ts { All = Parentheses | Assertions | PartiallyEmittedExpressions } + export type OuterExpression = ParenthesizedExpression | TypeAssertion | AsExpression | NonNullExpression | PartiallyEmittedExpression; + + export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All): node is OuterExpression { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: + return (kinds & OuterExpressionKinds.Parentheses) !== 0; + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.NonNullExpression: + return (kinds & OuterExpressionKinds.Assertions) !== 0; + case SyntaxKind.PartiallyEmittedExpression: + return (kinds & OuterExpressionKinds.PartiallyEmittedExpressions) !== 0; + } + return false; + } + export function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; export function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; export function skipOuterExpressions(node: Node, kinds = OuterExpressionKinds.All) { @@ -3754,8 +3802,8 @@ namespace ts { export function skipAssertions(node: Expression): Expression; export function skipAssertions(node: Node): Node; export function skipAssertions(node: Node): Node { - while (isAssertionExpression(node)) { - node = (node).expression; + while (isAssertionExpression(node) || node.kind === SyntaxKind.NonNullExpression) { + node = (node).expression; } return node; @@ -3771,6 +3819,26 @@ namespace ts { return node; } + function updateOuterExpression(outerExpression: OuterExpression, expression: Expression) { + switch (outerExpression.kind) { + case SyntaxKind.ParenthesizedExpression: return updateParen(outerExpression, expression); + case SyntaxKind.TypeAssertionExpression: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case SyntaxKind.AsExpression: return updateAsExpression(outerExpression, expression, outerExpression.type); + case SyntaxKind.NonNullExpression: return updateNonNullExpression(outerExpression, expression); + case SyntaxKind.PartiallyEmittedExpression: return updatePartiallyEmittedExpression(outerExpression, expression); + } + } + + export function recreateOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds = OuterExpressionKinds.All): Expression { + if (outerExpression && isOuterExpression(outerExpression, kinds)) { + return updateOuterExpression( + outerExpression, + recreateOuterExpressions(outerExpression.expression, innerExpression) + ); + } + return innerExpression; + } + export function startOnNewLine(node: T): T { node.startsOnNewLine = true; return node; @@ -3908,7 +3976,7 @@ namespace ts { return bindingElement.right; } - if (isSpreadExpression(bindingElement)) { + if (isSpreadElement(bindingElement)) { // Recovery consistent with existing emit. return getInitializerOfBindingOrAssignmentElement(bindingElement.expression); } @@ -3976,7 +4044,7 @@ namespace ts { return getTargetOfBindingOrAssignmentElement(bindingElement.left); } - if (isSpreadExpression(bindingElement)) { + if (isSpreadElement(bindingElement)) { // `a` in `[...a] = ...` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 44aa92bdd4c..0b0ca38a202 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -46,10 +46,16 @@ namespace ts { } } - // Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes - // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, - // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns - // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + /** + * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes + * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, + * embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns + * a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + * + * @param node a given node to visit its children + * @param cbNode a callback to be invoked for all child nodes + * @param cbNodeArray a callback to be invoked for embedded array + */ export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray) => T | undefined): T | undefined { if (!node) { return; @@ -2409,7 +2415,7 @@ namespace ts { if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { return parseSignatureMember(SyntaxKind.CallSignature); } - if (token() === SyntaxKind.NewKeyword && lookAhead(isStartOfConstructSignature)) { + if (token() === SyntaxKind.NewKeyword && lookAhead(nextTokenIsOpenParenOrLessThan)) { return parseSignatureMember(SyntaxKind.ConstructSignature); } const fullStart = getNodePos(); @@ -2420,7 +2426,7 @@ namespace ts { return parsePropertyOrMethodSignature(fullStart, modifiers); } - function isStartOfConstructSignature() { + function nextTokenIsOpenParenOrLessThan() { nextToken(); return token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken; } @@ -2792,6 +2798,8 @@ namespace ts { case SyntaxKind.SlashEqualsToken: case SyntaxKind.Identifier: return true; + case SyntaxKind.ImportKeyword: + return lookAhead(nextTokenIsOpenParenOrLessThan); default: return isIdentifier(); } @@ -3524,10 +3532,10 @@ namespace ts { * 5) --UnaryExpression[?Yield] */ if (isUpdateExpression()) { - const incrementExpression = parseIncrementExpression(); + const updateExpression = parseUpdateExpression(); return token() === SyntaxKind.AsteriskAsteriskToken ? - parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : - incrementExpression; + parseBinaryExpressionRest(getBinaryOperatorPrecedence(), updateExpression) : + updateExpression; } /** @@ -3593,7 +3601,7 @@ namespace ts { } // falls through default: - return parseIncrementExpression(); + return parseUpdateExpression(); } } @@ -3609,7 +3617,7 @@ namespace ts { */ function isUpdateExpression(): boolean { // This function is called inside parseUnaryExpression to decide - // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly + // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: @@ -3633,9 +3641,9 @@ namespace ts { } /** - * Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression. + * Parse ES7 UpdateExpression. UpdateExpression is used instead of ES6's PostFixExpression. * - * ES7 IncrementExpression[yield]: + * ES7 UpdateExpression[yield]: * 1) LeftHandSideExpression[?yield] * 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++ * 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]-- @@ -3643,7 +3651,7 @@ namespace ts { * 5) --LeftHandSideExpression[?yield] * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ - function parseIncrementExpression(): IncrementExpression { + function parseUpdateExpression(): UpdateExpression { if (token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) { const node = createNode(SyntaxKind.PrefixUnaryExpression); node.operator = token(); @@ -3693,17 +3701,27 @@ namespace ts { // CallExpression Arguments // CallExpression[Expression] // CallExpression.IdentifierName - // super ( ArgumentListopt ) + // import (AssignmentExpression) + // super Arguments // super.IdentifierName // - // Because of the recursion in these calls, we need to bottom out first. There are two - // bottom out states we can run into. Either we see 'super' which must start either of - // the last two CallExpression productions. Or we have a MemberExpression which either - // completes the LeftHandSideExpression, or starts the beginning of the first four - // CallExpression productions. - const expression = token() === SyntaxKind.SuperKeyword - ? parseSuperExpression() - : parseMemberExpressionOrHigher(); + // Because of the recursion in these calls, we need to bottom out first. There are three + // bottom out states we can run into: 1) We see 'super' which must start either of + // the last two CallExpression productions. 2) We see 'import' which must start import call. + // 3)we have a MemberExpression which either completes the LeftHandSideExpression, + // or starts the beginning of the first four CallExpression productions. + let expression: MemberExpression; + if (token() === SyntaxKind.ImportKeyword) { + // We don't want to eagerly consume all import keyword as import call expression so we look a head to find "(" + // For example: + // var foo3 = require("subfolder + // import * as foo1 from "module-from-node -> we want this import to be a statement rather than import call expression + sourceFile.flags |= NodeFlags.PossiblyContainDynamicImport; + expression = parseTokenNode(); + } + else { + expression = token() === SyntaxKind.SuperKeyword ? parseSuperExpression() : parseMemberExpressionOrHigher(); + } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression. As such, we need to consume the rest of it here to be complete. @@ -3711,7 +3729,7 @@ namespace ts { } function parseMemberExpressionOrHigher(): MemberExpression { - // Note: to make our lives simpler, we decompose the the NewExpression productions and + // Note: to make our lives simpler, we decompose the NewExpression productions and // place ObjectCreationExpression and FunctionExpression into PrimaryExpression. // like so: // @@ -4807,9 +4825,11 @@ namespace ts { case SyntaxKind.FinallyKeyword: return true; + case SyntaxKind.ImportKeyword: + return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThan); + case SyntaxKind.ConstKeyword: case SyntaxKind.ExportKeyword: - case SyntaxKind.ImportKeyword: return isStartOfDeclaration(); case SyntaxKind.AsyncKeyword: @@ -6337,6 +6357,12 @@ namespace ts { comment.parent = parent; } + if (isInJavaScriptFile(parent)) { + if (!sourceFile.jsDocDiagnostics) { + sourceFile.jsDocDiagnostics = []; + } + sourceFile.jsDocDiagnostics.push(...parseDiagnostics); + } currentToken = saveToken; parseDiagnostics.length = saveParseDiagnosticsLength; parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -6522,6 +6548,10 @@ namespace ts { case "augments": tag = parseAugmentsTag(atToken, tagName); break; + case "class": + case "constructor": + tag = parseClassTag(atToken, tagName); + break; case "arg": case "argument": case "param": @@ -6741,6 +6771,13 @@ namespace ts { return finishNode(result); } + function parseClassTag(atToken: AtToken, tagName: Identifier): JSDocClassTag { + const tag = createNode(SyntaxKind.JSDocClassTag, atToken.pos); + tag.atToken = atToken; + tag.tagName = tagName; + return finishNode(tag); + } + function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index dd293727b4a..92c50e6ddff 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -984,16 +984,12 @@ namespace ts { if (sourceFile) { return getDiagnostics(sourceFile, cancellationToken); } - - const allDiagnostics: Diagnostic[] = []; - forEach(program.getSourceFiles(), sourceFile => { + return sortAndDeduplicateDiagnostics(flatMap(program.getSourceFiles(), sourceFile => { if (cancellationToken) { cancellationToken.throwIfCancellationRequested(); } - addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - - return sortAndDeduplicateDiagnostics(allDiagnostics); + return getDiagnostics(sourceFile, cancellationToken); + })); } function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { @@ -1021,6 +1017,9 @@ namespace ts { if (isSourceFileJavaScript(sourceFile)) { if (!sourceFile.additionalSyntacticDiagnostics) { sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + if (isCheckJsEnabledForFile(sourceFile, options)) { + sourceFile.additionalSyntacticDiagnostics = concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.jsDocDiagnostics); + } } return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); } @@ -1066,10 +1065,10 @@ namespace ts { const typeChecker = getDiagnosticsProducingTypeChecker(); Debug.assert(!!sourceFile.bindDiagnostics); - const bindDiagnostics = sourceFile.bindDiagnostics; // For JavaScript files, we don't want to report semantic errors unless explicitly requested. - const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options); - const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; + const includeBindAndCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options); + const bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray; + const checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); @@ -1327,16 +1326,13 @@ namespace ts { } function getOptionsDiagnostics(): Diagnostic[] { - const allDiagnostics: Diagnostic[] = []; - addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return sortAndDeduplicateDiagnostics(allDiagnostics); + return sortAndDeduplicateDiagnostics(concatenate( + fileProcessingDiagnostics.getGlobalDiagnostics(), + programDiagnostics.getGlobalDiagnostics())); } function getGlobalDiagnostics(): Diagnostic[] { - const allDiagnostics: Diagnostic[] = []; - addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return sortAndDeduplicateDiagnostics(allDiagnostics); + return sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName: string, isDefaultLib: boolean) { @@ -1363,6 +1359,7 @@ namespace ts { const isJavaScriptFile = isSourceFileJavaScript(file); const isExternalModuleFile = isExternalModule(file); + // file.imports may not be undefined if there exists dynamic import let imports: LiteralExpression[]; let moduleAugmentations: LiteralExpression[]; let ambientModules: string[]; @@ -1382,8 +1379,8 @@ namespace ts { for (const node of file.statements) { collectModuleReferences(node, /*inAmbientModule*/ false); - if (isJavaScriptFile) { - collectRequireCalls(node); + if ((file.flags & NodeFlags.PossiblyContainDynamicImport) || isJavaScriptFile) { + collectDynamicImportOrRequireCalls(node); } } @@ -1446,12 +1443,16 @@ namespace ts { } } - function collectRequireCalls(node: Node): void { + function collectDynamicImportOrRequireCalls(node: Node): void { if (isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { (imports || (imports = [])).push((node).arguments[0]); } + // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. + else if (isImportCall(node) && node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) { + (imports || (imports = [])).push((node).arguments[0]); + } else { - forEachChild(node, collectRequireCalls); + forEachChild(node, collectDynamicImportOrRequireCalls); } } } @@ -1483,7 +1484,8 @@ namespace ts { } } return sourceFile; - } else { + } + else { const sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName); if (sourceFileNoExtension) return sourceFileNoExtension; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 0a072a3b8ac..dd43b3c8263 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -286,7 +286,7 @@ namespace ts { const tokenStrings = makeReverseMap(textToToken); - export function tokenToString(t: SyntaxKind): string { + export function tokenToString(t: SyntaxKind): string | undefined { return tokenStrings[t]; } @@ -363,7 +363,7 @@ namespace ts { }; } - export function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter { + export function getLineAndCharacterOfPosition(sourceFile: SourceFileLike, position: number): LineAndCharacter { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index d743f488e75..ffef485581b 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -22,7 +22,7 @@ namespace ts { * * @param sourceFile The source file. */ - setSourceFile(sourceFile: SourceFile): void; + setSourceFile(sourceFile: SourceMapSource): void; /** * Emits a mapping. @@ -81,7 +81,7 @@ namespace ts { export function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter { const compilerOptions = host.getCompilerOptions(); const extendedDiagnostics = compilerOptions.extendedDiagnostics; - let currentSourceFile: SourceFile; + let currentSource: SourceMapSource; let currentSourceText: string; let sourceMapDir: string; // The directory in which sourcemap will be @@ -109,6 +109,13 @@ namespace ts { getSourceMappingURL, }; + /** + * Skips trivia such as comments and white-space that can optionally overriden by the source map source + */ + function skipSourceTrivia(pos: number): number { + return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : skipTrivia(currentSourceText, pos); + } + /** * Initialize the SourceMapWriter for a new output file. * @@ -125,7 +132,7 @@ namespace ts { reset(); } - currentSourceFile = undefined; + currentSource = undefined; currentSourceText = undefined; // Current source map file and its index in the sources list @@ -192,7 +199,7 @@ namespace ts { return; } - currentSourceFile = undefined; + currentSource = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; lastRecordedSourceMapSpan = undefined; @@ -263,7 +270,7 @@ namespace ts { performance.mark("beforeSourcemap"); } - const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); + const sourceLinePos = getLineAndCharacterOfPosition(currentSource, pos); // Convert the location to be one-based. sourceLinePos.line++; @@ -320,14 +327,22 @@ namespace ts { if (node) { const emitNode = node.emitNode; const emitFlags = emitNode && emitNode.flags; - const { pos, end } = emitNode && emitNode.sourceMapRange || node; + const range = emitNode && emitNode.sourceMapRange; + const { pos, end } = range || node; + let source = range && range.source; + const oldSource = currentSource; + if (source === oldSource) source = undefined; + + if (source) setSourceFile(source); if (node.kind !== SyntaxKind.NotEmittedStatement && (emitFlags & EmitFlags.NoLeadingSourceMap) === 0 && pos >= 0) { - emitPos(skipTrivia(currentSourceText, pos)); + emitPos(skipSourceTrivia(pos)); } + if (source) setSourceFile(oldSource); + if (emitFlags & EmitFlags.NoNestedSourceMaps) { disabled = true; emitCallback(hint, node); @@ -337,11 +352,15 @@ namespace ts { emitCallback(hint, node); } + if (source) setSourceFile(source); + if (node.kind !== SyntaxKind.NotEmittedStatement && (emitFlags & EmitFlags.NoTrailingSourceMap) === 0 && end >= 0) { emitPos(end); } + + if (source) setSourceFile(oldSource); } } @@ -362,7 +381,7 @@ namespace ts { const emitFlags = emitNode && emitNode.flags; const range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; - tokenPos = skipTrivia(currentSourceText, range ? range.pos : tokenPos); + tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & EmitFlags.NoTokenLeadingSourceMaps) === 0 && tokenPos >= 0) { emitPos(tokenPos); } @@ -382,13 +401,13 @@ namespace ts { * * @param sourceFile The source file. */ - function setSourceFile(sourceFile: SourceFile) { + function setSourceFile(sourceFile: SourceMapSource) { if (disabled) { return; } - currentSourceFile = sourceFile; - currentSourceText = currentSourceFile.text; + currentSource = sourceFile; + currentSourceText = currentSource.text; // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path @@ -396,7 +415,7 @@ namespace ts { const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, - currentSourceFile.fileName, + currentSource.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); @@ -407,10 +426,10 @@ namespace ts { sourceMapData.sourceMapSources.push(source); // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(currentSourceFile.fileName); + sourceMapData.inputSourceFileNames.push(currentSource.fileName); if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent.push(currentSourceFile.text); + sourceMapData.sourceMapSourcesContent.push(currentSource.text); } } } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 7074abd3436..1abebe937e6 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -41,6 +41,7 @@ namespace ts { realpath?(path: string): string; /*@internal*/ getEnvironmentVariable(name: string): string; /*@internal*/ tryEnableSourceMapsForHost?(): void; + /*@internal*/ debugMode?: boolean; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; } @@ -428,6 +429,7 @@ namespace ts { realpath(path: string): string { return _fs.realpathSync(path); }, + debugMode: some(process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)), tryEnableSourceMapsForHost() { try { require("source-map-support").install(); @@ -517,4 +519,7 @@ namespace ts { ? AssertionLevel.Normal : AssertionLevel.None; } + if (sys && sys.debugMode) { + Debug.isDebugging = true; + } } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 75f9c43c6fe..f0c827d8396 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -15,6 +15,7 @@ namespace ts { function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory { switch (moduleKind) { + case ModuleKind.ESNext: case ModuleKind.ES2015: return transformES2015Module; case ModuleKind.System: diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 63c10145165..7acbd3126b4 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -339,11 +339,64 @@ namespace ts { && !(node).expression; } + function isClassLikeVariableStatement(node: Node) { + if (!isVariableStatement(node)) return false; + const variable = singleOrUndefined((node).declarationList.declarations); + return variable + && variable.initializer + && isIdentifier(variable.name) + && (isClassLike(variable.initializer) + || (isAssignmentExpression(variable.initializer) + && isIdentifier(variable.initializer.left) + && isClassLike(variable.initializer.right))); + } + + function isTypeScriptClassWrapper(node: Node) { + const call = tryCast(node, isCallExpression); + if (!call || isParseTreeNode(call) || + some(call.typeArguments) || + some(call.arguments)) { + return false; + } + + const func = tryCast(skipOuterExpressions(call.expression), isFunctionExpression); + if (!func || isParseTreeNode(func) || + some(func.typeParameters) || + some(func.parameters) || + func.type || + !func.body) { + return false; + } + + const statements = func.body.statements; + if (statements.length < 2) { + return false; + } + + const firstStatement = statements[0]; + if (isParseTreeNode(firstStatement) || + !isClassLike(firstStatement) && + !isClassLikeVariableStatement(firstStatement)) { + return false; + } + + const lastStatement = elementAt(statements, -1); + const returnStatement = tryCast(isVariableStatement(lastStatement) ? elementAt(statements, -2) : lastStatement, isReturnStatement); + if (!returnStatement || + !returnStatement.expression || + !isIdentifier(skipOuterExpressions(returnStatement.expression))) { + return false; + } + + return true; + } + function shouldVisitNode(node: Node): boolean { return (node.transformFlags & TransformFlags.ContainsES2015) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & HierarchyFacts.ConstructorWithCapturedSuper && isStatement(node)) - || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) + || isTypeScriptClassWrapper(node); } function visitor(node: Node): VisitResult { @@ -2042,9 +2095,9 @@ namespace ts { enableSubstitutionsForBlockScopedBindings(); } - const declarations = flatten(map(node.declarations, node.flags & NodeFlags.Let + const declarations = flatMap(node.declarations, node.flags & NodeFlags.Let ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); + : visitVariableDeclaration); const declarationList = createVariableDeclarationList(declarations); setOriginalNode(declarationList, node); @@ -3251,6 +3304,10 @@ namespace ts { * @param node a CallExpression. */ function visitCallExpression(node: CallExpression) { + if (isTypeScriptClassWrapper(node)) { + return visitTypeScriptClassWrapper(node); + } + if (node.transformFlags & TransformFlags.ES2015) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); } @@ -3262,6 +3319,163 @@ namespace ts { ); } + function visitTypeScriptClassWrapper(node: CallExpression) { + // This is a call to a class wrapper function (an IIFE) created by the 'ts' transformer. + // The wrapper has a form similar to: + // + // (function() { + // class C { // 1 + // } + // C.x = 1; // 2 + // return C; + // }()) + // + // When we transform the class, we end up with something like this: + // + // (function () { + // var C = (function () { // 3 + // function C() { + // } + // return C; // 4 + // }()); + // C.x = 1; + // return C; + // }()) + // + // We want to simplify the two nested IIFEs to end up with something like this: + // + // (function () { + // function C() { + // } + // C.x = 1; + // return C; + // }()) + + // We skip any outer expressions in a number of places to get to the innermost + // expression, but we will restore them later to preserve comments and source maps. + const body = cast(skipOuterExpressions(node.expression), isFunctionExpression).body; + + // The class statements are the statements generated by visiting the first statement of the + // body (1), while all other statements are added to remainingStatements (2) + const classStatements = visitNodes(body.statements, visitor, isStatement, 0, 1); + const remainingStatements = visitNodes(body.statements, visitor, isStatement, 1, body.statements.length - 1); + const varStatement = cast(firstOrUndefined(classStatements), isVariableStatement); + + // We know there is only one variable declaration here as we verified this in an + // earlier call to isTypeScriptClassWrapper + const variable = varStatement.declarationList.declarations[0]; + const initializer = skipOuterExpressions(variable.initializer); + + // Under certain conditions, the 'ts' transformer may introduce a class alias, which + // we see as an assignment, for example: + // + // (function () { + // var C = C_1 = (function () { + // function C() { + // } + // C.x = function () { return C_1; } + // return C; + // }()); + // C = C_1 = __decorate([dec], C); + // return C; + // var C_1; + // }()) + // + const aliasAssignment = tryCast(initializer, isAssignmentExpression); + + // The underlying call (3) is another IIFE that may contain a '_super' argument. + const call = cast(aliasAssignment ? skipOuterExpressions(aliasAssignment.right) : initializer, isCallExpression); + const func = cast(skipOuterExpressions(call.expression), isFunctionExpression); + + const funcStatements = func.body.statements; + let classBodyStart = 0; + let classBodyEnd = -1; + + const statements: Statement[] = []; + if (aliasAssignment) { + // If we have a class alias assignment, we need to move it to the down-level constructor + // function we generated for the class. + const extendsCall = tryCast(funcStatements[classBodyStart], isExpressionStatement); + if (extendsCall) { + statements.push(extendsCall); + classBodyStart++; + } + + // We reuse the comment and source-map positions from the original variable statement + // and class alias, while converting the function declaration for the class constructor + // into an expression. + statements.push( + updateVariableStatement( + varStatement, + /*modifiers*/ undefined, + updateVariableDeclarationList(varStatement.declarationList, [ + updateVariableDeclaration(variable, + variable.name, + /*type*/ undefined, + updateBinary(aliasAssignment, + aliasAssignment.left, + convertFunctionDeclarationToExpression( + cast(funcStatements[classBodyStart], isFunctionDeclaration) + ) + ) + ) + ]) + ) + ); + classBodyStart++; + } + + // Find the trailing 'return' statement (4) + while (!isReturnStatement(elementAt(funcStatements, classBodyEnd))) { + classBodyEnd--; + } + + // When we extract the statements of the inner IIFE, we exclude the 'return' statement (4) + // as we already have one that has been introduced by the 'ts' transformer. + addRange(statements, funcStatements, classBodyStart, classBodyEnd); + + if (classBodyEnd < -1) { + // If there were any hoisted declarations following the return statement, we should + // append them. + addRange(statements, funcStatements, classBodyEnd + 1); + } + + // Add the remaining statements of the outer wrapper. + addRange(statements, remainingStatements); + + // The 'es2015' class transform may add an end-of-declaration marker. If so we will add it + // after the remaining statements from the 'ts' transformer. + addRange(statements, classStatements, /*start*/ 1); + + // Recreate any outer parentheses or partially-emitted expressions to preserve source map + // and comment locations. + return recreateOuterExpressions(node.expression, + recreateOuterExpressions(variable.initializer, + recreateOuterExpressions(aliasAssignment && aliasAssignment.right, + updateCall(call, + recreateOuterExpressions(call.expression, + updateFunctionExpression( + func, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + func.parameters, + /*type*/ undefined, + updateBlock( + func.body, + statements + ) + ) + ), + /*typeArguments*/ undefined, + call.arguments + ) + ) + ) + ); + } + function visitImmediateSuperCallInBody(node: CallExpression) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); } @@ -3396,7 +3610,7 @@ namespace ts { else { if (segments.length === 1) { const firstElement = elements[0]; - return needsUniqueCopy && isSpreadExpression(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression + return needsUniqueCopy && isSpreadElement(firstElement) && firstElement.expression.kind !== SyntaxKind.ArrayLiteralExpression ? createArraySlice(segments[0]) : segments[0]; } @@ -3407,7 +3621,7 @@ namespace ts { } function partitionSpread(node: Expression) { - return isSpreadExpression(node) + return isSpreadElement(node) ? visitSpanOfSpreads : visitSpanOfNonSpreads; } @@ -3806,9 +4020,7 @@ namespace ts { return false; } if (isClassElement(currentNode) && currentNode.parent === declaration) { - // we are in the class body, but we treat static fields as outside of the class body - return currentNode.kind !== SyntaxKind.PropertyDeclaration - || (getModifierFlags(currentNode) & ModifierFlags.Static) === 0; + return true; } currentNode = currentNode.parent; } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 6e2f70b5c35..a3aa0139aa4 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -351,8 +351,10 @@ namespace ts { ); } - function awaitAsYield(expression: Expression) { - return createYield(/*asteriskToken*/ undefined, enclosingFunctionFlags & FunctionFlags.Generator ? createAwaitHelper(context, expression) : expression); + function createDownlevelAwait(expression: Expression) { + return enclosingFunctionFlags & FunctionFlags.Generator + ? createYield(/*asteriskToken*/ undefined, createAwaitHelper(context, expression)) + : createAwait(expression); } function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement) { @@ -385,11 +387,11 @@ namespace ts { EmitFlags.NoHoisting ), /*condition*/ createComma( - createAssignment(result, awaitAsYield(callNext)), + createAssignment(result, createDownlevelAwait(callNext)), createLogicalNot(getDone) ), /*incrementor*/ undefined, - /*statement*/ convertForOfStatementHead(node, awaitAsYield(getValue)) + /*statement*/ convertForOfStatementHead(node, createDownlevelAwait(getValue)) ), /*location*/ node ), @@ -434,7 +436,7 @@ namespace ts { createPropertyAccess(iterator, "return") ) ), - createStatement(awaitAsYield(callReturn)) + createStatement(createDownlevelAwait(callReturn)) ), EmitFlags.SingleLine ) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index b3e544a3f8b..b2e1c1c70a9 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -46,6 +46,7 @@ namespace ts { let currentSourceFile: SourceFile; // The current file. let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file. let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored. + let needUMDDynamicImportHelper: boolean; return transformSourceFile; @@ -55,7 +56,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) { + if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) { return node; } @@ -66,9 +67,9 @@ namespace ts { // Perform the transformation. const transformModule = getTransformModuleDelegate(moduleKind); const updated = transformModule(node); - currentSourceFile = undefined; currentModuleInfo = undefined; + needUMDDynamicImportHelper = false; return aggregateTransformFlags(updated); } @@ -107,6 +108,7 @@ namespace ts { // we need to inform the emitter to add the __export helper. addEmitHelper(updated, exportStarHelper); } + addEmitHelpers(updated, context.readEmitHelpers()); return updated; } @@ -411,6 +413,9 @@ namespace ts { // we need to inform the emitter to add the __export helper. addEmitHelper(body, exportStarHelper); } + if (needUMDDynamicImportHelper) { + addEmitHelper(body, dynamicImportUMDHelper); + } return body; } @@ -488,12 +493,110 @@ namespace ts { return visitEndOfDeclarationMarker(node); default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; + return visitEachChild(node, importCallExpressionVisitor, context); } } + function importCallExpressionVisitor(node: Node): VisitResult { + // This visitor does not need to descend into the tree if there is no dynamic import, + // as export/import statements are only transformed at the top level of a file. + if (!(node.transformFlags & TransformFlags.ContainsDynamicImport)) { + return node; + } + + if (isImportCall(node)) { + return visitImportCallExpression(node); + } + else { + return visitEachChild(node, importCallExpressionVisitor, context); + } + } + + function visitImportCallExpression(node: ImportCall): Expression { + switch (compilerOptions.module) { + case ModuleKind.CommonJS: + return transformImportCallExpressionCommonJS(node); + case ModuleKind.AMD: + return transformImportCallExpressionAMD(node); + case ModuleKind.UMD: + return transformImportCallExpressionUMD(node); + } + Debug.fail("All supported module kind in this transformation step should have been handled"); + } + + function transformImportCallExpressionUMD(node: ImportCall): Expression { + // (function (factory) { + // ... (regular UMD) + // } + // })(function (require, exports, useSyncRequire) { + // "use strict"; + // Object.defineProperty(exports, "__esModule", { value: true }); + // var __syncRequire = typeof module === "object" && typeof module.exports === "object"; + // var __resolved = new Promise(function (resolve) { resolve(); }); + // ..... + // __syncRequire + // ? __resolved.then(function () { return require(x); }) /*CommonJs Require*/ + // : new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ + // }); + needUMDDynamicImportHelper = true; + return createConditional( + /*condition*/ createIdentifier("__syncRequire"), + /*whenTrue*/ transformImportCallExpressionCommonJS(node), + /*whenFalse*/ transformImportCallExpressionAMD(node) + ); + } + + function transformImportCallExpressionAMD(node: ImportCall): Expression { + // improt("./blah") + // emit as + // define(["require", "exports", "blah"], function (require, exports) { + // ... + // new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/ + // }); + const resolve = createUniqueName("resolve"); + const reject = createUniqueName("reject"); + return createNew( + createIdentifier("Promise"), + /*typeArguments*/ undefined, + [createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + [createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ resolve), + createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject)], + /*type*/ undefined, + createBlock([createStatement( + createCall( + createIdentifier("require"), + /*typeArguments*/ undefined, + [createArrayLiteral([firstOrUndefined(node.arguments) || createOmittedExpression()]), resolve, reject] + ))]) + )]); + } + + function transformImportCallExpressionCommonJS(node: ImportCall): Expression { + // import("./blah") + // emit as + // Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/ + // We have to wrap require in then callback so that require is done in asynchronously + // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately + return createCall( + createPropertyAccess( + createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []), + "then"), + /*typeArguments*/ undefined, + [createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ undefined, + /*type*/ undefined, + createBlock([createReturn(createCall(createIdentifier("require"), /*typeArguments*/ undefined, node.arguments))]) + )]); + } + /** * Visits an ImportDeclaration node. * @@ -786,9 +889,9 @@ namespace ts { node.asteriskToken, getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, - node.parameters, + visitNodes(node.parameters, importCallExpressionVisitor), /*type*/ undefined, - node.body + visitEachChild(node.body, importCallExpressionVisitor, context) ), /*location*/ node ), @@ -797,7 +900,7 @@ namespace ts { ); } else { - statements = append(statements, node); + statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -828,7 +931,7 @@ namespace ts { visitNodes(node.modifiers, modifierVisitor, isModifier), getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, - node.heritageClauses, + visitNodes(node.heritageClauses, importCallExpressionVisitor), node.members ), node @@ -838,7 +941,7 @@ namespace ts { ); } else { - statements = append(statements, node); + statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -890,7 +993,7 @@ namespace ts { } } else { - statements = append(statements, node); + statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -913,7 +1016,7 @@ namespace ts { function transformInitializedVariable(node: VariableDeclaration): Expression { if (isBindingPattern(node.name)) { return flattenDestructuringAssignment( - node, + visitNode(node, importCallExpressionVisitor), /*visitor*/ undefined, context, FlattenLevel.All, @@ -930,7 +1033,7 @@ namespace ts { ), /*location*/ node.name ), - node.initializer + visitNode(node.initializer, importCallExpressionVisitor) ); } } @@ -1497,4 +1600,12 @@ namespace ts { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; }` }; + + // emit helper for dynamic import + const dynamicImportUMDHelper: EmitHelper = { + name: "typescript:dynamicimport-sync-require", + scoped: true, + text: ` + var __syncRequire = typeof module === "object" && typeof module.exports === "object";` + }; } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 3355ad35633..fa126d1faa7 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -50,7 +50,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) { + if (node.isDeclarationFile || !(isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & TransformFlags.ContainsDynamicImport)) { return node; } @@ -646,7 +646,7 @@ namespace ts { return undefined; } - const expression = visitNode(node.expression, destructuringVisitor, isExpression); + const expression = visitNode(node.expression, destructuringAndImportCallVisitor, isExpression); const original = node.original; if (original && hasAssociatedEndOfDeclarationMarker(original)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -673,12 +673,12 @@ namespace ts { node.asteriskToken, getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, - visitNodes(node.parameters, destructuringVisitor, isParameterDeclaration), + visitNodes(node.parameters, destructuringAndImportCallVisitor, isParameterDeclaration), /*type*/ undefined, - visitNode(node.body, destructuringVisitor, isBlock))); + visitNode(node.body, destructuringAndImportCallVisitor, isBlock))); } else { - hoistedStatements = append(hoistedStatements, node); + hoistedStatements = append(hoistedStatements, visitEachChild(node, destructuringAndImportCallVisitor, context)); } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -716,8 +716,8 @@ namespace ts { /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, - visitNodes(node.heritageClauses, destructuringVisitor, isHeritageClause), - visitNodes(node.members, destructuringVisitor, isClassElement) + visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, isHeritageClause), + visitNodes(node.members, destructuringAndImportCallVisitor, isClassElement) ), node ) @@ -747,7 +747,7 @@ namespace ts { */ function visitVariableStatement(node: VariableStatement): VisitResult { if (!shouldHoistVariableDeclarationList(node.declarationList)) { - return visitNode(node, destructuringVisitor, isStatement); + return visitNode(node, destructuringAndImportCallVisitor, isStatement); } let expressions: Expression[]; @@ -820,13 +820,13 @@ namespace ts { return isBindingPattern(node.name) ? flattenDestructuringAssignment( node, - destructuringVisitor, + destructuringAndImportCallVisitor, context, FlattenLevel.All, /*needsValue*/ false, createAssignment ) - : createAssignment(node.name, visitNode(node.initializer, destructuringVisitor, isExpression)); + : createAssignment(node.name, visitNode(node.initializer, destructuringAndImportCallVisitor, isExpression)); } /** @@ -1204,7 +1204,7 @@ namespace ts { return visitEndOfDeclarationMarker(node); default: - return destructuringVisitor(node); + return destructuringAndImportCallVisitor(node); } } @@ -1220,8 +1220,8 @@ namespace ts { node = updateFor( node, visitForInitializer(node.initializer), - visitNode(node.condition, destructuringVisitor, isExpression), - visitNode(node.incrementor, destructuringVisitor, isExpression), + visitNode(node.condition, destructuringAndImportCallVisitor, isExpression), + visitNode(node.incrementor, destructuringAndImportCallVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement) ); @@ -1241,7 +1241,7 @@ namespace ts { node = updateForIn( node, visitForInitializer(node.initializer), - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); @@ -1262,7 +1262,7 @@ namespace ts { node, node.awaitModifier, visitForInitializer(node.initializer), - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); @@ -1313,7 +1313,7 @@ namespace ts { return updateDo( node, visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock), - visitNode(node.expression, destructuringVisitor, isExpression) + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression) ); } @@ -1325,7 +1325,7 @@ namespace ts { function visitWhileStatement(node: WhileStatement): VisitResult { return updateWhile( node, - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); } @@ -1351,7 +1351,7 @@ namespace ts { function visitWithStatement(node: WithStatement): VisitResult { return updateWith( node, - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock) ); } @@ -1364,7 +1364,7 @@ namespace ts { function visitSwitchStatement(node: SwitchStatement): VisitResult { return updateSwitch( node, - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNode(node.caseBlock, nestedElementVisitor, isCaseBlock) ); } @@ -1395,7 +1395,7 @@ namespace ts { function visitCaseClause(node: CaseClause): VisitResult { return updateCaseClause( node, - visitNode(node.expression, destructuringVisitor, isExpression), + visitNode(node.expression, destructuringAndImportCallVisitor, isExpression), visitNodes(node.statements, nestedElementVisitor, isStatement) ); } @@ -1461,19 +1461,43 @@ namespace ts { * * @param node The node to visit. */ - function destructuringVisitor(node: Node): VisitResult { + function destructuringAndImportCallVisitor(node: Node): VisitResult { if (node.transformFlags & TransformFlags.DestructuringAssignment && node.kind === SyntaxKind.BinaryExpression) { return visitDestructuringAssignment(node); } - else if (node.transformFlags & TransformFlags.ContainsDestructuringAssignment) { - return visitEachChild(node, destructuringVisitor, context); + else if (isImportCall(node)) { + return visitImportCallExpression(node); + } + else if ((node.transformFlags & TransformFlags.ContainsDestructuringAssignment) || (node.transformFlags & TransformFlags.ContainsDynamicImport)) { + return visitEachChild(node, destructuringAndImportCallVisitor, context); } else { return node; } } + function visitImportCallExpression(node: ImportCall): Expression { + // import("./blah") + // emit as + // System.register([], function (_export, _context) { + // return { + // setters: [], + // execute: () => { + // _context.import('./blah'); + // } + // }; + // }); + return createCall( + createPropertyAccess( + contextObject, + createIdentifier("import") + ), + /*typeArguments*/ undefined, + node.arguments + ); + } + /** * Visits a DestructuringAssignment to flatten destructuring to exported symbols. * @@ -1483,14 +1507,14 @@ namespace ts { if (hasExportedReferenceInDestructuringTarget(node.left)) { return flattenDestructuringAssignment( node, - destructuringVisitor, + destructuringAndImportCallVisitor, context, FlattenLevel.All, /*needsValue*/ true ); } - return visitEachChild(node, destructuringVisitor, context); + return visitEachChild(node, destructuringAndImportCallVisitor, context); } /** @@ -1502,7 +1526,7 @@ namespace ts { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { return hasExportedReferenceInDestructuringTarget(node.left); } - else if (isSpreadExpression(node)) { + else if (isSpreadElement(node)) { return hasExportedReferenceInDestructuringTarget(node.expression); } else if (isObjectLiteralExpression(node)) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d02aaecf333..bcfa5985b57 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -18,6 +18,23 @@ namespace ts { NonQualifiedEnumMembers = 1 << 3 } + const enum ClassFacts { + None = 0, + HasStaticInitializedProperties = 1 << 0, + HasConstructorDecorators = 1 << 1, + HasMemberDecorators = 1 << 2, + IsExportOfNamespace = 1 << 3, + IsNamedExternalExport = 1 << 4, + IsDefaultExternalExport = 1 << 5, + HasExtendsClause = 1 << 6, + UseImmediatelyInvokedFunctionExpression = 1 << 7, + + HasAnyDecorators = HasConstructorDecorators | HasMemberDecorators, + NeedsName = HasStaticInitializedProperties | HasMemberDecorators, + MayNeedImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties, + IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport, + } + export function transformTypeScript(context: TransformationContext) { const { startLexicalEnvironment, @@ -505,6 +522,19 @@ namespace ts { return parameter.decorators !== undefined && parameter.decorators.length > 0; } + function getClassFacts(node: ClassDeclaration, staticProperties: PropertyDeclaration[]) { + let facts = ClassFacts.None; + if (some(staticProperties)) facts |= ClassFacts.HasStaticInitializedProperties; + if (getClassExtendsHeritageClauseElement(node)) facts |= ClassFacts.HasExtendsClause; + if (shouldEmitDecorateCallForClass(node)) facts |= ClassFacts.HasConstructorDecorators; + if (childIsDecorated(node)) facts |= ClassFacts.HasMemberDecorators; + if (isExportOfNamespace(node)) facts |= ClassFacts.IsExportOfNamespace; + else if (isDefaultExternalModuleExport(node)) facts |= ClassFacts.IsDefaultExternalExport; + else if (isNamedExternalModuleExport(node)) facts |= ClassFacts.IsNamedExternalExport; + if (languageVersion <= ScriptTarget.ES5 && (facts & ClassFacts.MayNeedImmediatelyInvokedFunctionExpression)) facts |= ClassFacts.UseImmediatelyInvokedFunctionExpression; + return facts; + } + /** * Transforms a class declaration with TypeScript syntax into compatible ES6. * @@ -518,32 +548,26 @@ namespace ts { */ function visitClassDeclaration(node: ClassDeclaration): VisitResult { const staticProperties = getInitializedProperties(node, /*isStatic*/ true); - const hasExtendsClause = getClassExtendsHeritageClauseElement(node) !== undefined; - const isDecoratedClass = shouldEmitDecorateCallForClass(node); + const facts = getClassFacts(node, staticProperties); - // emit name if - // - node has a name - // - node has static initializers - // - node has a member that is decorated - // - let name = node.name; - if (!name && (staticProperties.length > 0 || childIsDecorated(node))) { - name = getGeneratedNameForNode(node); + if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) { + context.startLexicalEnvironment(); } - const classStatement = isDecoratedClass - ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) - : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + const name = node.name || (facts & ClassFacts.NeedsName ? getGeneratedNameForNode(node) : undefined); + const classStatement = facts & ClassFacts.HasConstructorDecorators + ? createClassDeclarationHeadWithDecorators(node, name, facts) + : createClassDeclarationHeadWithoutDecorators(node, name, facts); - const statements: Statement[] = [classStatement]; + let statements: Statement[] = [classStatement]; // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node)); + if (facts & ClassFacts.HasStaticInitializedProperties) { + addInitializedPropertyStatements(statements, staticProperties, facts & ClassFacts.UseImmediatelyInvokedFunctionExpression ? getInternalName(node) : getLocalName(node)); } // Write any decorators of the node. @@ -551,17 +575,63 @@ namespace ts { addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); + if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) { + // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the + // 'es2015' transformer can properly nest static initializers and decorators. The result + // looks something like: + // + // var C = function () { + // class C { + // } + // C.static_prop = 1; + // return C; + // }(); + // + const closingBraceLocation = createTokenRange(skipTrivia(currentSourceFile.text, node.members.end), SyntaxKind.CloseBraceToken); + const localName = getInternalName(node); + + // The following partially-emitted expression exists purely to align our sourcemap + // emit with the original emitter. + const outer = createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + setEmitFlags(outer, EmitFlags.NoComments); + + const statement = createReturn(outer); + statement.pos = closingBraceLocation.pos; + setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); + statements.push(statement); + + addRange(statements, context.endLexicalEnvironment()); + + const varStatement = createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), + /*type*/ undefined, + createImmediatelyInvokedFunctionExpression(statements) + ) + ]) + ); + + setOriginalNode(varStatement, node); + setCommentRange(varStatement, node); + setSourceMapRange(varStatement, moveRangePastDecorators(node)); + startOnNewLine(varStatement); + statements = [varStatement]; + } + // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (isNamespaceExport(node)) { + if (facts & ClassFacts.IsExportOfNamespace) { addExportMemberAssignment(statements, node); } - else if (isDecoratedClass) { - if (isDefaultExternalModuleExport(node)) { + else if (facts & ClassFacts.UseImmediatelyInvokedFunctionExpression || facts & ClassFacts.HasConstructorDecorators) { + if (facts & ClassFacts.IsDefaultExternalExport) { statements.push(createExportDefault(getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (isNamedExternalModuleExport(node)) { + else if (facts & ClassFacts.IsNamedExternalExport) { statements.push(createExternalModuleExport(getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } @@ -580,26 +650,31 @@ namespace ts { * * @param node A ClassDeclaration node. * @param name The name of the class. - * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param hasStaticProperties A value indicating whether the class has static properties. + * @param facts Precomputed facts about the class. */ - function createClassDeclarationHeadWithoutDecorators(node: ClassDeclaration, name: Identifier, hasExtendsClause: boolean, hasStaticProperties: boolean) { + function createClassDeclarationHeadWithoutDecorators(node: ClassDeclaration, name: Identifier, facts: ClassFacts) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } + + // we do not emit modifiers on the declaration if we are emitting an IIFE + const modifiers = !(facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) + ? visitNodes(node.modifiers, modifierVisitor, isModifier) + : undefined; + const classDeclaration = createClassDeclaration( /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), + modifiers, name, /*typeParameters*/ undefined, visitNodes(node.heritageClauses, visitor, isHeritageClause), - transformClassMembers(node, hasExtendsClause) + transformClassMembers(node, (facts & ClassFacts.HasExtendsClause) !== 0) ); // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. let emitFlags = getEmitFlags(node); - if (hasStaticProperties) { + if (facts & ClassFacts.HasStaticInitializedProperties) { emitFlags |= EmitFlags.NoTrailingSourceMap; } @@ -612,13 +687,8 @@ namespace ts { /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. - * - * @param statements A statement list to which to add the declaration. - * @param node A ClassDeclaration node. - * @param name The name of the class. - * @param hasExtendsClause A value indicating whether the class has an extends clause. */ - function createClassDeclarationHeadWithDecorators(node: ClassDeclaration, name: Identifier, hasExtendsClause: boolean) { + function createClassDeclarationHeadWithDecorators(node: ClassDeclaration, name: Identifier, facts: ClassFacts) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -713,7 +783,7 @@ namespace ts { // ${members} // } const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); - const members = transformClassMembers(node, hasExtendsClause); + const members = transformClassMembers(node, (facts & ClassFacts.HasExtendsClause) !== 0); const classExpression = createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); setOriginalNode(classExpression, node); setTextRange(classExpression, location); @@ -2163,7 +2233,7 @@ namespace ts { /*type*/ undefined, visitFunctionBody(node.body, visitor, context) || createBlock([]) ); - if (isNamespaceExport(node)) { + if (isExportOfNamespace(node)) { const statements: Statement[] = [updated]; addExportMemberAssignment(statements, node); return statements; @@ -2256,7 +2326,7 @@ namespace ts { * - The node is exported from a TypeScript namespace. */ function visitVariableStatement(node: VariableStatement): Statement { - if (isNamespaceExport(node)) { + if (isExportOfNamespace(node)) { const variables = getInitializedVariables(node.declarationList); if (variables.length === 0) { // elide statement if there are no initialized variables. @@ -2560,7 +2630,7 @@ namespace ts { * or `exports.x`). */ function hasNamespaceQualifiedExportName(node: Node) { - return isNamespaceExport(node) + return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ModuleKind.ES2015 && moduleKind !== ModuleKind.System); @@ -3002,7 +3072,7 @@ namespace ts { const moduleReference = createExpressionFromEntityName(node.moduleReference); setEmitFlags(moduleReference, EmitFlags.NoComments | EmitFlags.NoNestedComments); - if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { + if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; return setOriginalNode( @@ -3043,7 +3113,7 @@ namespace ts { * * @param node The node to test. */ - function isNamespaceExport(node: Node) { + function isExportOfNamespace(node: Node) { return currentNamespace !== undefined && hasModifier(node, ModifierFlags.Export); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ca943530ad2..a3957c66d6a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -375,6 +375,7 @@ namespace ts { JSDocComment, JSDocTag, JSDocAugmentsTag, + JSDocClassTag, JSDocParameterTag, JSDocReturnTag, JSDocTypeTag, @@ -396,6 +397,7 @@ namespace ts { // Enum value count Count, + // Markers FirstAssignment = EqualsToken, LastAssignment = CaretEqualsToken, @@ -450,6 +452,14 @@ namespace ts { ThisNodeOrAnySubNodesHasError = 1 << 17, // If this node or any of its children had an error HasAggregatedChildData = 1 << 18, // If we've computed data from children and cached it in this node + // This flag will be set to true when the parse encounter dynamic import so that post-parsing process of module resolution + // will not walk the tree if the flag is not set. However, this flag is just a approximation because once it is set, the flag never get reset. + // (hence it is named "possiblyContainDynamicImport"). + // During editing, if dynamic import is remove, incremental parsing will *NOT* update this flag. This will then causes walking of the tree during module resolution. + // However, the removal operation should not occur often and in the case of the removal, it is likely that users will add back the import anyway. + // The advantage of this approach is its simplicity. For the case of batch compilation, we garuntee that users won't have to pay the price of walking the tree if dynamic import isn't used. + PossiblyContainDynamicImport = 1 << 19, + BlockScoped = Let | Const, ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn, @@ -1006,8 +1016,10 @@ namespace ts { _unaryExpressionBrand: any; } - export interface IncrementExpression extends UnaryExpression { - _incrementExpressionBrand: any; + /** Deprecated, please use UpdateExpression */ + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { + _updateExpressionBrand: any; } // see: https://tc39.github.io/ecma262/#prod-UpdateExpression @@ -1018,10 +1030,9 @@ namespace ts { | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken - | SyntaxKind.ExclamationToken - ; + | SyntaxKind.ExclamationToken; - export interface PrefixUnaryExpression extends IncrementExpression { + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; @@ -1033,13 +1044,13 @@ namespace ts { | SyntaxKind.MinusMinusToken ; - export interface PostfixUnaryExpression extends IncrementExpression { + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - export interface LeftHandSideExpression extends IncrementExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } @@ -1067,6 +1078,10 @@ namespace ts { kind: SyntaxKind.SuperKeyword; } + export interface ImportExpression extends PrimaryExpression { + kind: SyntaxKind.ImportKeyword; + } + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; @@ -1459,10 +1474,7 @@ namespace ts { } // see: https://tc39.github.io/ecma262/#prod-SuperProperty - export type SuperProperty - = SuperPropertyAccessExpression - | SuperElementAccessExpression - ; + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; @@ -1476,6 +1488,10 @@ namespace ts { expression: SuperExpression; } + export interface ImportCall extends CallExpression { + expression: ImportExpression; + } + export interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; parent?: HeritageClause; @@ -2122,6 +2138,10 @@ namespace ts { typeExpression: JSDocTypeExpression; } + export interface JSDocClassTag extends JSDocTag { + kind: SyntaxKind.JSDocClassTag; + } + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; @@ -2321,16 +2341,19 @@ namespace ts { /* @internal */ identifierCount: number; /* @internal */ symbolCount: number; - // File level diagnostics reported by the parser (includes diagnostics about /// references + // File-level diagnostics reported by the parser (includes diagnostics about /// references // as well as code diagnostics). /* @internal */ parseDiagnostics: Diagnostic[]; - // Stores additional file level diagnostics reported by the program - /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; - - // File level diagnostics reported by the binder. + // File-level diagnostics reported by the binder. /* @internal */ bindDiagnostics: Diagnostic[]; + // File-level JSDoc diagnostics reported by the JSDoc parser + /* @internal */ jsDocDiagnostics?: Diagnostic[]; + + // Stores additional file-level diagnostics reported by the program + /* @internal */ additionalSyntacticDiagnostics?: Diagnostic[]; + // Stores a line map for the file. // This field should never be used directly to obtain line map, use getLineMap function instead. /* @internal */ lineMap: number[]; @@ -2537,7 +2560,6 @@ namespace ts { getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; @@ -2607,6 +2629,9 @@ namespace ts { * Does not include properties of primitive types. */ /* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[]; + + /* @internal */ getJsxNamespace(): string; + /* @internal */ resolveNameAtLocation(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined; } export enum NodeBuilderFlags { @@ -3101,6 +3126,7 @@ namespace ts { export interface Type { flags: TypeFlags; // Flags /* @internal */ id: number; // Unique ID + /* @internal */ checker: TypeChecker; symbol?: Symbol; // Symbol associated with type (if any) pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any) aliasSymbol?: Symbol; // Alias associated with type @@ -3581,6 +3607,7 @@ namespace ts { UMD = 3, System = 4, ES2015 = 5, + ESNext = 6 } export const enum JsxEmit { @@ -3965,6 +3992,11 @@ namespace ts { ContainsYield = 1 << 24, ContainsHoistedDeclarationOrCompletion = 1 << 25, + ContainsDynamicImport = 1 << 26, + + // Please leave this as 1 << 29. + // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. + // It is a good reminder of how much room we have left HasComputedFlags = 1 << 29, // Transform flags have been computed. // Assertions @@ -4002,49 +4034,60 @@ namespace ts { ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, } + export interface SourceMapRange extends TextRange { + source?: SourceMapSource; + } + + export interface SourceMapSource { + fileName: string; + text: string; + /* @internal */ lineMap: number[]; + skipTrivia?: (pos: number) => number; + } + /* @internal */ export interface EmitNode { - annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. - flags?: EmitFlags; // Flags that customize emit - leadingComments?: SynthesizedComment[]; // Synthesized leading comments + annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. + flags?: EmitFlags; // Flags that customize emit + leadingComments?: SynthesizedComment[]; // Synthesized leading comments trailingComments?: SynthesizedComment[]; // Synthesized trailing comments - commentRange?: TextRange; // The text range to use when emitting leading or trailing comments - sourceMapRange?: TextRange; // The text range to use when emitting leading or trailing source mappings - tokenSourceMapRanges?: TextRange[]; // The text range to use when emitting source mappings for tokens - constantValue?: string | number; // The constant value of an expression - externalHelpersModuleName?: Identifier; // The local name for an imported helpers module - helpers?: EmitHelper[]; // Emit helpers for the node + commentRange?: TextRange; // The text range to use when emitting leading or trailing comments + sourceMapRange?: SourceMapRange; // The text range to use when emitting leading or trailing source mappings + tokenSourceMapRanges?: SourceMapRange[]; // The text range to use when emitting source mappings for tokens + constantValue?: string | number; // The constant value of an expression + externalHelpersModuleName?: Identifier; // The local name for an imported helpers module + helpers?: EmitHelper[]; // Emit helpers for the node } export const enum EmitFlags { - SingleLine = 1 << 0, // The contents of this node should be emitted on a single line. - AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node. - NoSubstitution = 1 << 2, // Disables further substitution of an expression. - CapturesThis = 1 << 3, // The function captures a lexical `this` - NoLeadingSourceMap = 1 << 4, // Do not emit a leading source map location for this node. - NoTrailingSourceMap = 1 << 5, // Do not emit a trailing source map location for this node. + SingleLine = 1 << 0, // The contents of this node should be emitted on a single line. + AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node. + NoSubstitution = 1 << 2, // Disables further substitution of an expression. + CapturesThis = 1 << 3, // The function captures a lexical `this` + NoLeadingSourceMap = 1 << 4, // Do not emit a leading source map location for this node. + NoTrailingSourceMap = 1 << 5, // Do not emit a trailing source map location for this node. NoSourceMap = NoLeadingSourceMap | NoTrailingSourceMap, // Do not emit a source map location for this node. - NoNestedSourceMaps = 1 << 6, // Do not emit source map locations for children of this node. - NoTokenLeadingSourceMaps = 1 << 7, // Do not emit leading source map location for token nodes. - NoTokenTrailingSourceMaps = 1 << 8, // Do not emit trailing source map location for token nodes. + NoNestedSourceMaps = 1 << 6, // Do not emit source map locations for children of this node. + NoTokenLeadingSourceMaps = 1 << 7, // Do not emit leading source map location for token nodes. + NoTokenTrailingSourceMaps = 1 << 8, // Do not emit trailing source map location for token nodes. NoTokenSourceMaps = NoTokenLeadingSourceMaps | NoTokenTrailingSourceMaps, // Do not emit source map locations for tokens of this node. - NoLeadingComments = 1 << 9, // Do not emit leading comments for this node. - NoTrailingComments = 1 << 10, // Do not emit trailing comments for this node. + NoLeadingComments = 1 << 9, // Do not emit leading comments for this node. + NoTrailingComments = 1 << 10, // Do not emit trailing comments for this node. NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node. NoNestedComments = 1 << 11, HelperName = 1 << 12, - ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). - LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration. - InternalName = 1 << 15, // The name is internal to an ES5 class body function. - Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). - NoIndentation = 1 << 17, // Do not indent the node. + ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). + LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration. + InternalName = 1 << 15, // The name is internal to an ES5 class body function. + Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + NoIndentation = 1 << 17, // Do not indent the node. AsyncFunctionBody = 1 << 18, - ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit. - CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed). - NoHoisting = 1 << 21, // Do not hoist this declaration in --module system - HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration - Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. - NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. + ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit. + CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed). + NoHoisting = 1 << 21, // Do not hoist this declaration in --module system + HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration + Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. + NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. } export interface EmitHelper { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bec984d6f1c..8fb72694669 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -254,10 +254,6 @@ namespace ts { return !nodeIsMissing(node); } - export function isToken(n: Node): boolean { - return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; - } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -284,22 +280,6 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } - export function isJSDocNode(node: Node) { - return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; - } - - export function isJSDoc(node: Node): node is JSDoc { - return node.kind === SyntaxKind.JSDocComment; - } - - export function isJSDocTypedefTag(node: Node): node is JSDocTypedefTag { - return node.kind === SyntaxKind.JSDocTypedefTag; - } - - export function isJSDocTag(node: Node) { - return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; - } - export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); @@ -616,6 +596,10 @@ namespace ts { return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; } + export function isImportCall(n: Node): n is ImportCall { + return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.ImportKeyword; + } + export function isPrologueDirective(node: Node): node is PrologueDirective { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; @@ -743,10 +727,6 @@ namespace ts { return false; } - export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { - return node.kind === SyntaxKind.PrefixUnaryExpression; - } - // Warning: This has the same semantics as the forEach family of functions, // in that traversal terminates in the event that 'visitor' supplies a truthy value. export function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T { @@ -866,49 +846,6 @@ namespace ts { return false; } - export function isAccessor(node: Node): node is AccessorDeclaration { - return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); - } - - export function isClassLike(node: Node): node is ClassLikeDeclaration { - return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); - } - - export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { - return node && isFunctionLikeKind(node.kind); - } - - export function isFunctionLikeKind(kind: SyntaxKind): boolean { - switch (kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return true; - } - - return false; - } - - export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode { - switch (node.kind) { - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return true; - } - - return false; - } - export function introducesArgumentsExoticObject(node: Node) { switch (node.kind) { case SyntaxKind.MethodDeclaration: @@ -923,21 +860,6 @@ namespace ts { return false; } - export function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement { - switch (node.kind) { - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - return true; - case SyntaxKind.LabeledStatement: - return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); - } - - return false; - } - export function unwrapInnermostStatementOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void) { while (true) { if (beforeUnwrapLabelCallback) { @@ -1156,24 +1078,6 @@ namespace ts { return undefined; } - export function isCallLikeExpression(node: Node): node is CallLikeExpression { - switch (node.kind) { - case SyntaxKind.JsxOpeningElement: - case SyntaxKind.JsxSelfClosingElement: - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.Decorator: - return true; - default: - return false; - } - } - - export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression { - return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression; - } - export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; @@ -1546,24 +1450,10 @@ namespace ts { } function getJSDocTags(node: Node, kind: SyntaxKind): JSDocTag[] { - const docs = getJSDocs(node); - if (docs) { - const result: JSDocTag[] = []; - for (const doc of docs) { - if (doc.kind === SyntaxKind.JSDocParameterTag) { - if (doc.kind === kind) { - result.push(doc as JSDocTag); - } - } - else { - const tags = (doc as JSDoc).tags; - if (tags) { - result.push(...filter(tags, tag => tag.kind === kind)); - } - } - } - return result; - } + return flatMap(getJSDocs(node), doc => + doc.kind === SyntaxKind.JSDocComment + ? filter((doc as JSDoc).tags, tag => tag.kind === kind) + : doc.kind === kind && doc); } function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag { @@ -1684,6 +1574,10 @@ namespace ts { return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; } + export function getJSDocClassTag(node: Node): JSDocClassTag { + return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; + } + export function getJSDocReturnTag(node: Node): JSDocReturnTag { return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; } @@ -2024,10 +1918,6 @@ namespace ts { return false; } - export function isNumericLiteral(node: Node): node is NumericLiteral { - return node.kind === SyntaxKind.NumericLiteral; - } - export function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { const kind = node.kind; return kind === SyntaxKind.StringLiteral @@ -2094,24 +1984,6 @@ namespace ts { return node.text === "push" || node.text === "unshift"; } - export function isModifierKind(token: SyntaxKind): boolean { - switch (token) { - case SyntaxKind.AbstractKeyword: - case SyntaxKind.AsyncKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.DefaultKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.ReadonlyKeyword: - case SyntaxKind.StaticKeyword: - return true; - } - return false; - } - export function isParameterDeclaration(node: VariableLikeDeclaration) { const root = getRootDeclaration(node); return root.kind === SyntaxKind.Parameter; @@ -3069,6 +2941,14 @@ namespace ts { return node.modifierFlagsCache & ~ModifierFlags.HasComputedFlags; } + const flags = getModifierFlagsNoCache(node); + node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags; + return flags; + } + + /* @internal */ + export function getModifierFlagsNoCache(node: Node): ModifierFlags { + let flags = ModifierFlags.None; if (node.modifiers) { for (const modifier of node.modifiers) { @@ -3080,7 +2960,6 @@ namespace ts { flags |= ModifierFlags.Export; } - node.modifierFlagsCache = flags | ModifierFlags.HasComputedFlags; return flags; } @@ -3369,27 +3248,76 @@ namespace ts { return false; } - const syntaxKindCache: string[] = []; - - export function formatSyntaxKind(kind: SyntaxKind): string { - const syntaxKindEnum = (ts).SyntaxKind; - if (syntaxKindEnum) { - const cached = syntaxKindCache[kind]; - if (cached !== undefined) { - return cached; - } - - for (const name in syntaxKindEnum) { - if (syntaxKindEnum[name] === kind) { - const result = `${kind} (${name})`; - syntaxKindCache[kind] = result; - return result; + /** + * Formats an enum value as a string for debugging and debug assertions. + */ + function formatEnum(value = 0, enumObject: any, isFlags?: boolean) { + const members = getEnumMembers(enumObject); + if (value === 0) { + return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; + } + if (isFlags) { + let result = ""; + let remainingFlags = value; + for (let i = members.length - 1; i >= 0 && remainingFlags !== 0; i--) { + const [enumValue, enumName] = members[i]; + if (enumValue !== 0 && (remainingFlags & enumValue) === enumValue) { + remainingFlags &= ~enumValue; + result = `${enumName}${result ? ", " : ""}${result}`; } } + if (remainingFlags === 0) { + return result; + } } else { - return kind.toString(); + for (const [enumValue, enumName] of members) { + if (enumValue === value) { + return enumName; + } + } } + return value.toString(); + } + + function getEnumMembers(enumObject: any) { + const result: [number, string][] = []; + for (const name in enumObject) { + const value = enumObject[name]; + if (typeof value === "number") { + result.push([value, name]); + } + } + + return stableSort(result, (x, y) => compareValues(x[0], y[0])); + } + + export function formatSyntaxKind(kind: SyntaxKind): string { + return formatEnum(kind, (ts).SyntaxKind, /*isFlags*/ false); + } + + export function formatModifierFlags(flags: ModifierFlags): string { + return formatEnum(flags, (ts).ModifierFlags, /*isFlags*/ true); + } + + export function formatTransformFlags(flags: TransformFlags): string { + return formatEnum(flags, (ts).TransformFlags, /*isFlags*/ true); + } + + export function formatEmitFlags(flags: EmitFlags): string { + return formatEnum(flags, (ts).EmitFlags, /*isFlags*/ true); + } + + export function formatSymbolFlags(flags: SymbolFlags): string { + return formatEnum(flags, (ts).SymbolFlags, /*isFlags*/ true); + } + + export function formatTypeFlags(flags: TypeFlags): string { + return formatEnum(flags, (ts).TypeFlags, /*isFlags*/ true); + } + + export function formatObjectFlags(flags: ObjectFlags): string { + return formatEnum(flags, (ts).ObjectFlags, /*isFlags*/ true); } export function getRangePos(range: TextRange | undefined) { @@ -3575,700 +3503,6 @@ namespace ts { return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; } - // Node tests - // - // All node tests in the following list should *not* reference parent pointers so that - // they may be used with transformations. - - // Node Arrays - - export function isNodeArray(array: T[]): array is NodeArray { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - - // Literals - - export function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression { - return node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isLiteralKind(kind: SyntaxKind): boolean { - return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken; - } - - export function isTextualLiteralKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isLiteralExpression(node: Node): node is LiteralExpression { - return isLiteralKind(node.kind); - } - - // Pseudo-literals - - export function isTemplateLiteralKind(kind: SyntaxKind): boolean { - return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; - } - - export function isTemplateHead(node: Node): node is TemplateHead { - return node.kind === SyntaxKind.TemplateHead; - } - - export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail { - const kind = node.kind; - return kind === SyntaxKind.TemplateMiddle - || kind === SyntaxKind.TemplateTail; - } - - // Identifiers - - export function isIdentifier(node: Node): node is Identifier { - return node.kind === SyntaxKind.Identifier; - } - - export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier { - // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. - return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; - } - - // Keywords - - export function isModifier(node: Node): node is Modifier { - return isModifierKind(node.kind); - } - - // Names - - export function isQualifiedName(node: Node): node is QualifiedName { - return node.kind === SyntaxKind.QualifiedName; - } - - export function isComputedPropertyName(node: Node): node is ComputedPropertyName { - return node.kind === SyntaxKind.ComputedPropertyName; - } - - export function isEntityName(node: Node): node is EntityName { - const kind = node.kind; - return kind === SyntaxKind.QualifiedName - || kind === SyntaxKind.Identifier; - } - - export function isPropertyName(node: Node): node is PropertyName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.NumericLiteral - || kind === SyntaxKind.ComputedPropertyName; - } - - export function isModuleName(node: Node): node is ModuleName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.StringLiteral; - } - - export function isBindingName(node: Node): node is BindingName { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.ObjectBindingPattern - || kind === SyntaxKind.ArrayBindingPattern; - } - - // Signature elements - - export function isTypeParameter(node: Node): node is TypeParameterDeclaration { - return node.kind === SyntaxKind.TypeParameter; - } - - export function isParameter(node: Node): node is ParameterDeclaration { - return node.kind === SyntaxKind.Parameter; - } - - export function isDecorator(node: Node): node is Decorator { - return node.kind === SyntaxKind.Decorator; - } - - // Type members - - export function isMethodDeclaration(node: Node): node is MethodDeclaration { - return node.kind === SyntaxKind.MethodDeclaration; - } - - export function isClassElement(node: Node): node is ClassElement { - const kind = node.kind; - return kind === SyntaxKind.Constructor - || kind === SyntaxKind.PropertyDeclaration - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.IndexSignature - || kind === SyntaxKind.SemicolonClassElement - || kind === SyntaxKind.MissingDeclaration; - } - - export function isTypeElement(node: Node): node is TypeElement { - const kind = node.kind; - return kind === SyntaxKind.ConstructSignature - || kind === SyntaxKind.CallSignature - || kind === SyntaxKind.PropertySignature - || kind === SyntaxKind.MethodSignature - || kind === SyntaxKind.IndexSignature - || kind === SyntaxKind.MissingDeclaration; - } - - export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike { - const kind = node.kind; - return kind === SyntaxKind.PropertyAssignment - || kind === SyntaxKind.ShorthandPropertyAssignment - || kind === SyntaxKind.SpreadAssignment - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.MissingDeclaration; - } - - // Type - - function isTypeNodeKind(kind: SyntaxKind) { - return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) - || kind === SyntaxKind.AnyKeyword - || kind === SyntaxKind.NumberKeyword - || kind === SyntaxKind.ObjectKeyword - || kind === SyntaxKind.BooleanKeyword - || kind === SyntaxKind.StringKeyword - || kind === SyntaxKind.SymbolKeyword - || kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.VoidKeyword - || kind === SyntaxKind.UndefinedKeyword - || kind === SyntaxKind.NullKeyword - || kind === SyntaxKind.NeverKeyword - || kind === SyntaxKind.ExpressionWithTypeArguments; - } - - /** - * Node test that determines whether a node is a valid type node. - * This differs from the `isPartOfTypeNode` function which determines whether a node is *part* - * of a TypeNode. - */ - export function isTypeNode(node: Node): node is TypeNode { - return isTypeNodeKind(node.kind); - } - - // Binding patterns - - export function isArrayBindingPattern(node: Node): node is ArrayBindingPattern { - return node.kind === SyntaxKind.ArrayBindingPattern; - } - - export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern { - return node.kind === SyntaxKind.ObjectBindingPattern; - } - - export function isBindingPattern(node: Node): node is BindingPattern { - if (node) { - const kind = node.kind; - return kind === SyntaxKind.ArrayBindingPattern - || kind === SyntaxKind.ObjectBindingPattern; - } - - return false; - } - - export function isAssignmentPattern(node: Node): node is AssignmentPattern { - const kind = node.kind; - return kind === SyntaxKind.ArrayLiteralExpression - || kind === SyntaxKind.ObjectLiteralExpression; - } - - export function isBindingElement(node: Node): node is BindingElement { - return node.kind === SyntaxKind.BindingElement; - } - - export function isArrayBindingElement(node: Node): node is ArrayBindingElement { - const kind = node.kind; - return kind === SyntaxKind.BindingElement - || kind === SyntaxKind.OmittedExpression; - } - - - /** - * Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration - */ - export function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement { - switch (bindingElement.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.BindingElement: - return true; - } - - return false; - } - - /** - * Determines whether a node is a BindingOrAssignmentPattern - */ - export function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern { - return isObjectBindingOrAssignmentPattern(node) - || isArrayBindingOrAssignmentPattern(node); - } - - /** - * Determines whether a node is an ObjectBindingOrAssignmentPattern - */ - export function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern { - switch (node.kind) { - case SyntaxKind.ObjectBindingPattern: - case SyntaxKind.ObjectLiteralExpression: - return true; - } - - return false; - } - - /** - * Determines whether a node is an ArrayBindingOrAssignmentPattern - */ - export function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern { - switch (node.kind) { - case SyntaxKind.ArrayBindingPattern: - case SyntaxKind.ArrayLiteralExpression: - return true; - } - - return false; - } - - // Expression - - export function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression { - return node.kind === SyntaxKind.ArrayLiteralExpression; - } - - export function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression { - return node.kind === SyntaxKind.ObjectLiteralExpression; - } - - export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { - return node.kind === SyntaxKind.PropertyAccessExpression; - } - - export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName { - const kind = node.kind; - return kind === SyntaxKind.PropertyAccessExpression - || kind === SyntaxKind.QualifiedName; - } - - export function isElementAccessExpression(node: Node): node is ElementAccessExpression { - return node.kind === SyntaxKind.ElementAccessExpression; - } - - export function isBinaryExpression(node: Node): node is BinaryExpression { - return node.kind === SyntaxKind.BinaryExpression; - } - - export function isConditionalExpression(node: Node): node is ConditionalExpression { - return node.kind === SyntaxKind.ConditionalExpression; - } - - export function isCallExpression(node: Node): node is CallExpression { - return node.kind === SyntaxKind.CallExpression; - } - - export function isTemplateLiteral(node: Node): node is TemplateLiteral { - const kind = node.kind; - return kind === SyntaxKind.TemplateExpression - || kind === SyntaxKind.NoSubstitutionTemplateLiteral; - } - - export function isSpreadExpression(node: Node): node is SpreadElement { - return node.kind === SyntaxKind.SpreadElement; - } - - export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments { - return node.kind === SyntaxKind.ExpressionWithTypeArguments; - } - - function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PropertyAccessExpression - || kind === SyntaxKind.ElementAccessExpression - || kind === SyntaxKind.NewExpression - || kind === SyntaxKind.CallExpression - || kind === SyntaxKind.JsxElement - || kind === SyntaxKind.JsxSelfClosingElement - || kind === SyntaxKind.TaggedTemplateExpression - || kind === SyntaxKind.ArrayLiteralExpression - || kind === SyntaxKind.ParenthesizedExpression - || kind === SyntaxKind.ObjectLiteralExpression - || kind === SyntaxKind.ClassExpression - || kind === SyntaxKind.FunctionExpression - || kind === SyntaxKind.Identifier - || kind === SyntaxKind.RegularExpressionLiteral - || kind === SyntaxKind.NumericLiteral - || kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.NoSubstitutionTemplateLiteral - || kind === SyntaxKind.TemplateExpression - || kind === SyntaxKind.FalseKeyword - || kind === SyntaxKind.NullKeyword - || kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.TrueKeyword - || kind === SyntaxKind.SuperKeyword - || kind === SyntaxKind.NonNullExpression - || kind === SyntaxKind.MetaProperty; - } - - export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { - return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - function isUnaryExpressionKind(kind: SyntaxKind): boolean { - return kind === SyntaxKind.PrefixUnaryExpression - || kind === SyntaxKind.PostfixUnaryExpression - || kind === SyntaxKind.DeleteExpression - || kind === SyntaxKind.TypeOfExpression - || kind === SyntaxKind.VoidExpression - || kind === SyntaxKind.AwaitExpression - || kind === SyntaxKind.TypeAssertionExpression - || isLeftHandSideExpressionKind(kind); - } - - export function isUnaryExpression(node: Node): node is UnaryExpression { - return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - function isExpressionKind(kind: SyntaxKind) { - return kind === SyntaxKind.ConditionalExpression - || kind === SyntaxKind.YieldExpression - || kind === SyntaxKind.ArrowFunction - || kind === SyntaxKind.BinaryExpression - || kind === SyntaxKind.SpreadElement - || kind === SyntaxKind.AsExpression - || kind === SyntaxKind.OmittedExpression - || kind === SyntaxKind.CommaListExpression - || isUnaryExpressionKind(kind); - } - - export function isExpression(node: Node): node is Expression { - return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); - } - - export function isAssertionExpression(node: Node): node is AssertionExpression { - const kind = node.kind; - return kind === SyntaxKind.TypeAssertionExpression - || kind === SyntaxKind.AsExpression; - } - - export function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression { - return node.kind === SyntaxKind.PartiallyEmittedExpression; - } - - export function isNotEmittedStatement(node: Node): node is NotEmittedStatement { - return node.kind === SyntaxKind.NotEmittedStatement; - } - - export function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - - export function isOmittedExpression(node: Node): node is OmittedExpression { - return node.kind === SyntaxKind.OmittedExpression; - } - - // Misc - - export function isTemplateSpan(node: Node): node is TemplateSpan { - return node.kind === SyntaxKind.TemplateSpan; - } - - // Element - - export function isBlock(node: Node): node is Block { - return node.kind === SyntaxKind.Block; - } - - export function isConciseBody(node: Node): node is ConciseBody { - return isBlock(node) - || isExpression(node); - } - - export function isFunctionBody(node: Node): node is FunctionBody { - return isBlock(node); - } - - export function isForInitializer(node: Node): node is ForInitializer { - return isVariableDeclarationList(node) - || isExpression(node); - } - - export function isVariableDeclaration(node: Node): node is VariableDeclaration { - return node.kind === SyntaxKind.VariableDeclaration; - } - - export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { - return node.kind === SyntaxKind.VariableDeclarationList; - } - - export function isCaseBlock(node: Node): node is CaseBlock { - return node.kind === SyntaxKind.CaseBlock; - } - - export function isModuleBody(node: Node): node is ModuleBody { - const kind = node.kind; - return kind === SyntaxKind.ModuleBlock - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.Identifier; - } - - export function isNamespaceBody(node: Node): node is NamespaceBody { - const kind = node.kind; - return kind === SyntaxKind.ModuleBlock - || kind === SyntaxKind.ModuleDeclaration; - } - - export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody { - const kind = node.kind; - return kind === SyntaxKind.Identifier - || kind === SyntaxKind.ModuleDeclaration; - } - - export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { - return node.kind === SyntaxKind.ImportEqualsDeclaration; - } - - export function isImportDeclaration(node: Node): node is ImportDeclaration { - return node.kind === SyntaxKind.ImportDeclaration; - } - - export function isImportClause(node: Node): node is ImportClause { - return node.kind === SyntaxKind.ImportClause; - } - - export function isNamedImportBindings(node: Node): node is NamedImportBindings { - const kind = node.kind; - return kind === SyntaxKind.NamedImports - || kind === SyntaxKind.NamespaceImport; - } - - export function isImportSpecifier(node: Node): node is ImportSpecifier { - return node.kind === SyntaxKind.ImportSpecifier; - } - - export function isNamedExports(node: Node): node is NamedExports { - return node.kind === SyntaxKind.NamedExports; - } - - export function isExportSpecifier(node: Node): node is ExportSpecifier { - return node.kind === SyntaxKind.ExportSpecifier; - } - - export function isExportAssignment(node: Node): node is ExportAssignment { - return node.kind === SyntaxKind.ExportAssignment; - } - - export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration { - return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration; - } - - function isDeclarationKind(kind: SyntaxKind) { - return kind === SyntaxKind.ArrowFunction - || kind === SyntaxKind.BindingElement - || kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.ClassExpression - || kind === SyntaxKind.Constructor - || kind === SyntaxKind.EnumDeclaration - || kind === SyntaxKind.EnumMember - || kind === SyntaxKind.ExportSpecifier - || kind === SyntaxKind.FunctionDeclaration - || kind === SyntaxKind.FunctionExpression - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.ImportClause - || kind === SyntaxKind.ImportEqualsDeclaration - || kind === SyntaxKind.ImportSpecifier - || kind === SyntaxKind.InterfaceDeclaration - || kind === SyntaxKind.JsxAttribute - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.MethodSignature - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.NamespaceExportDeclaration - || kind === SyntaxKind.NamespaceImport - || kind === SyntaxKind.Parameter - || kind === SyntaxKind.PropertyAssignment - || kind === SyntaxKind.PropertyDeclaration - || kind === SyntaxKind.PropertySignature - || kind === SyntaxKind.SetAccessor - || kind === SyntaxKind.ShorthandPropertyAssignment - || kind === SyntaxKind.TypeAliasDeclaration - || kind === SyntaxKind.TypeParameter - || kind === SyntaxKind.VariableDeclaration - || kind === SyntaxKind.JSDocTypedefTag; - } - - function isDeclarationStatementKind(kind: SyntaxKind) { - return kind === SyntaxKind.FunctionDeclaration - || kind === SyntaxKind.MissingDeclaration - || kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.InterfaceDeclaration - || kind === SyntaxKind.TypeAliasDeclaration - || kind === SyntaxKind.EnumDeclaration - || kind === SyntaxKind.ModuleDeclaration - || kind === SyntaxKind.ImportDeclaration - || kind === SyntaxKind.ImportEqualsDeclaration - || kind === SyntaxKind.ExportDeclaration - || kind === SyntaxKind.ExportAssignment - || kind === SyntaxKind.NamespaceExportDeclaration; - } - - function isStatementKindButNotDeclarationKind(kind: SyntaxKind) { - return kind === SyntaxKind.BreakStatement - || kind === SyntaxKind.ContinueStatement - || kind === SyntaxKind.DebuggerStatement - || kind === SyntaxKind.DoStatement - || kind === SyntaxKind.ExpressionStatement - || kind === SyntaxKind.EmptyStatement - || kind === SyntaxKind.ForInStatement - || kind === SyntaxKind.ForOfStatement - || kind === SyntaxKind.ForStatement - || kind === SyntaxKind.IfStatement - || kind === SyntaxKind.LabeledStatement - || kind === SyntaxKind.ReturnStatement - || kind === SyntaxKind.SwitchStatement - || kind === SyntaxKind.ThrowStatement - || kind === SyntaxKind.TryStatement - || kind === SyntaxKind.VariableStatement - || kind === SyntaxKind.WhileStatement - || kind === SyntaxKind.WithStatement - || kind === SyntaxKind.NotEmittedStatement - || kind === SyntaxKind.EndOfDeclarationMarker - || kind === SyntaxKind.MergeDeclarationMarker; - } - - export function isDeclaration(node: Node): node is NamedDeclaration { - return isDeclarationKind(node.kind); - } - - export function isDeclarationStatement(node: Node): node is DeclarationStatement { - return isDeclarationStatementKind(node.kind); - } - - /** - * Determines whether the node is a statement that is not also a declaration - */ - export function isStatementButNotDeclaration(node: Node): node is Statement { - return isStatementKindButNotDeclarationKind(node.kind); - } - - export function isStatement(node: Node): node is Statement { - const kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === SyntaxKind.Block; - } - - // Module references - - export function isModuleReference(node: Node): node is ModuleReference { - const kind = node.kind; - return kind === SyntaxKind.ExternalModuleReference - || kind === SyntaxKind.QualifiedName - || kind === SyntaxKind.Identifier; - } - - // JSX - - export function isJsxOpeningElement(node: Node): node is JsxOpeningElement { - return node.kind === SyntaxKind.JsxOpeningElement; - } - - export function isJsxClosingElement(node: Node): node is JsxClosingElement { - return node.kind === SyntaxKind.JsxClosingElement; - } - - export function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression { - const kind = node.kind; - return kind === SyntaxKind.ThisKeyword - || kind === SyntaxKind.Identifier - || kind === SyntaxKind.PropertyAccessExpression; - } - - export function isJsxChild(node: Node): node is JsxChild { - const kind = node.kind; - return kind === SyntaxKind.JsxElement - || kind === SyntaxKind.JsxExpression - || kind === SyntaxKind.JsxSelfClosingElement - || kind === SyntaxKind.JsxText; - } - - export function isJsxAttributes(node: Node): node is JsxAttributes { - const kind = node.kind; - return kind === SyntaxKind.JsxAttributes; - } - - export function isJsxAttributeLike(node: Node): node is JsxAttributeLike { - const kind = node.kind; - return kind === SyntaxKind.JsxAttribute - || kind === SyntaxKind.JsxSpreadAttribute; - } - - export function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute { - return node.kind === SyntaxKind.JsxSpreadAttribute; - } - - export function isJsxAttribute(node: Node): node is JsxAttribute { - return node.kind === SyntaxKind.JsxAttribute; - } - - export function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression { - const kind = node.kind; - return kind === SyntaxKind.StringLiteral - || kind === SyntaxKind.JsxExpression; - } - - export function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement { - const kind = node.kind; - return kind === SyntaxKind.JsxOpeningElement - || kind === SyntaxKind.JsxSelfClosingElement; - } - - // Clauses - - export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { - const kind = node.kind; - return kind === SyntaxKind.CaseClause - || kind === SyntaxKind.DefaultClause; - } - - export function isHeritageClause(node: Node): node is HeritageClause { - return node.kind === SyntaxKind.HeritageClause; - } - - export function isCatchClause(node: Node): node is CatchClause { - return node.kind === SyntaxKind.CatchClause; - } - - - // Property assignments - - export function isPropertyAssignment(node: Node): node is PropertyAssignment { - return node.kind === SyntaxKind.PropertyAssignment; - } - - export function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment { - return node.kind === SyntaxKind.ShorthandPropertyAssignment; - } - - // Enum - - export function isEnumMember(node: Node): node is EnumMember { - return node.kind === SyntaxKind.EnumMember; - } - - // Top-level nodes - export function isSourceFile(node: Node): node is SourceFile { - return node.kind === SyntaxKind.SourceFile; - } - export function isWatchSet(options: CompilerOptions) { // Firefox has Object.prototype.watch return options.watch && options.hasOwnProperty("watch"); @@ -4771,3 +4005,1324 @@ namespace ts { } } } + +// Simple node tests of the form `node.kind === SyntaxKind.Foo`. +namespace ts { + // Literals + export function isNumericLiteral(node: Node): node is NumericLiteral { + return node.kind === SyntaxKind.NumericLiteral; + } + + export function isStringLiteral(node: Node): node is StringLiteral { + return node.kind === SyntaxKind.StringLiteral; + } + + export function isJsxText(node: Node): node is JsxText { + return node.kind === SyntaxKind.JsxText; + } + + export function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral { + return node.kind === SyntaxKind.RegularExpressionLiteral; + } + + export function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression { + return node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } + + // Pseudo-literals + + export function isTemplateHead(node: Node): node is TemplateHead { + return node.kind === SyntaxKind.TemplateHead; + } + + export function isTemplateMiddle(node: Node): node is TemplateMiddle { + return node.kind === SyntaxKind.TemplateMiddle; + } + + export function isTemplateTail(node: Node): node is TemplateTail { + return node.kind === SyntaxKind.TemplateTail; + } + + export function isIdentifier(node: Node): node is Identifier { + return node.kind === SyntaxKind.Identifier; + } + + // Names + + export function isQualifiedName(node: Node): node is QualifiedName { + return node.kind === SyntaxKind.QualifiedName; + } + + export function isComputedPropertyName(node: Node): node is ComputedPropertyName { + return node.kind === SyntaxKind.ComputedPropertyName; + } + + // Signature elements + + export function isTypeParameter(node: Node): node is TypeParameterDeclaration { + return node.kind === SyntaxKind.TypeParameter; + } + + export function isParameter(node: Node): node is ParameterDeclaration { + return node.kind === SyntaxKind.Parameter; + } + + export function isDecorator(node: Node): node is Decorator { + return node.kind === SyntaxKind.Decorator; + } + + // TypeMember + + export function isPropertySignature(node: Node): node is PropertySignature { + return node.kind === SyntaxKind.PropertySignature; + } + + export function isPropertyDeclaration(node: Node): node is PropertyDeclaration { + return node.kind === SyntaxKind.PropertyDeclaration; + } + + export function isMethodSignature(node: Node): node is MethodSignature { + return node.kind === SyntaxKind.MethodSignature; + } + + export function isMethodDeclaration(node: Node): node is MethodDeclaration { + return node.kind === SyntaxKind.MethodDeclaration; + } + + export function isConstructorDeclaration(node: Node): node is ConstructorDeclaration { + return node.kind === SyntaxKind.Constructor; + } + + export function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration { + return node.kind === SyntaxKind.GetAccessor; + } + + export function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration { + return node.kind === SyntaxKind.SetAccessor; + } + + export function isCallSignatureDeclaration(node: Node): node is CallSignatureDeclaration { + return node.kind === SyntaxKind.CallSignature; + } + + export function isConstructSignatureDeclaration(node: Node): node is ConstructSignatureDeclaration { + return node.kind === SyntaxKind.ConstructSignature; + } + + export function isIndexSignatureDeclaration(node: Node): node is IndexSignatureDeclaration { + return node.kind === SyntaxKind.IndexSignature; + } + + // Type + + export function isTypePredicateNode(node: Node): node is TypePredicateNode { + return node.kind === SyntaxKind.TypePredicate; + } + + export function isTypeReferenceNode(node: Node): node is TypeReferenceNode { + return node.kind === SyntaxKind.TypeReference; + } + + export function isFunctionTypeNode(node: Node): node is FunctionTypeNode { + return node.kind === SyntaxKind.FunctionType; + } + + export function isConstructorTypeNode(node: Node): node is ConstructorTypeNode { + return node.kind === SyntaxKind.ConstructorType; + } + + export function isTypeQueryNode(node: Node): node is TypeQueryNode { + return node.kind === SyntaxKind.TypeQuery; + } + + export function isTypeLiteralNode(node: Node): node is TypeLiteralNode { + return node.kind === SyntaxKind.TypeLiteral; + } + + export function isArrayTypeNode(node: Node): node is ArrayTypeNode { + return node.kind === SyntaxKind.ArrayType; + } + + export function isTupleTypeNode(node: Node): node is TupleTypeNode { + return node.kind === SyntaxKind.TupleType; + } + + export function isUnionTypeNode(node: Node): node is UnionTypeNode { + return node.kind === SyntaxKind.UnionType; + } + + export function isIntersectionTypeNode(node: Node): node is IntersectionTypeNode { + return node.kind === SyntaxKind.IntersectionType; + } + + export function isParenthesizedTypeNode(node: Node): node is ParenthesizedTypeNode { + return node.kind === SyntaxKind.ParenthesizedType; + } + + export function isThisTypeNode(node: Node): node is ThisTypeNode { + return node.kind === SyntaxKind.ThisType; + } + + export function isTypeOperatorNode(node: Node): node is TypeOperatorNode { + return node.kind === SyntaxKind.TypeOperator; + } + + export function isIndexedAccessTypeNode(node: Node): node is IndexedAccessTypeNode { + return node.kind === SyntaxKind.IndexedAccessType; + } + + export function isMappedTypeNode(node: Node): node is MappedTypeNode { + return node.kind === SyntaxKind.MappedType; + } + + export function isLiteralTypeNode(node: Node): node is LiteralTypeNode { + return node.kind === SyntaxKind.LiteralType; + } + + // Binding patterns + + export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern { + return node.kind === SyntaxKind.ObjectBindingPattern; + } + + export function isArrayBindingPattern(node: Node): node is ArrayBindingPattern { + return node.kind === SyntaxKind.ArrayBindingPattern; + } + + export function isBindingElement(node: Node): node is BindingElement { + return node.kind === SyntaxKind.BindingElement; + } + + // Expression + + export function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression { + return node.kind === SyntaxKind.ArrayLiteralExpression; + } + + export function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression { + return node.kind === SyntaxKind.ObjectLiteralExpression; + } + + export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { + return node.kind === SyntaxKind.PropertyAccessExpression; + } + + export function isElementAccessExpression(node: Node): node is ElementAccessExpression { + return node.kind === SyntaxKind.ElementAccessExpression; + } + + export function isCallExpression(node: Node): node is CallExpression { + return node.kind === SyntaxKind.CallExpression; + } + + export function isNewExpression(node: Node): node is NewExpression { + return node.kind === SyntaxKind.NewExpression; + } + + export function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression { + return node.kind === SyntaxKind.TaggedTemplateExpression; + } + + export function isTypeAssertion(node: Node): node is TypeAssertion { + return node.kind === SyntaxKind.TypeAssertionExpression; + } + + export function isParenthesizedExpression(node: Node): node is ParenthesizedExpression { + return node.kind === SyntaxKind.ParenthesizedExpression; + } + + export function isFunctionExpression(node: Node): node is FunctionExpression { + return node.kind === SyntaxKind.FunctionExpression; + } + + export function isArrowFunction(node: Node): node is ArrowFunction { + return node.kind === SyntaxKind.ArrowFunction; + } + + export function isDeleteExpression(node: Node): node is DeleteExpression { + return node.kind === SyntaxKind.DeleteExpression; + } + + export function isTypeOfExpression(node: Node): node is TypeOfExpression { + return node.kind === SyntaxKind.AwaitExpression; + } + + export function isVoidExpression(node: Node): node is VoidExpression { + return node.kind === SyntaxKind.VoidExpression; + } + + export function isAwaitExpression(node: Node): node is AwaitExpression { + return node.kind === SyntaxKind.AwaitExpression; + } + + export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { + return node.kind === SyntaxKind.PrefixUnaryExpression; + } + + export function isPostfixUnaryExpression(node: Node): node is PostfixUnaryExpression { + return node.kind === SyntaxKind.PostfixUnaryExpression; + } + + export function isBinaryExpression(node: Node): node is BinaryExpression { + return node.kind === SyntaxKind.BinaryExpression; + } + + export function isConditionalExpression(node: Node): node is ConditionalExpression { + return node.kind === SyntaxKind.ConditionalExpression; + } + + export function isTemplateExpression(node: Node): node is TemplateExpression { + return node.kind === SyntaxKind.TemplateExpression; + } + + export function isYieldExpression(node: Node): node is YieldExpression { + return node.kind === SyntaxKind.YieldExpression; + } + + export function isSpreadElement(node: Node): node is SpreadElement { + return node.kind === SyntaxKind.SpreadElement; + } + + export function isClassExpression(node: Node): node is ClassExpression { + return node.kind === SyntaxKind.ClassExpression; + } + + export function isOmittedExpression(node: Node): node is OmittedExpression { + return node.kind === SyntaxKind.OmittedExpression; + } + + export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments { + return node.kind === SyntaxKind.ExpressionWithTypeArguments; + } + + export function isAsExpression(node: Node): node is AsExpression { + return node.kind === SyntaxKind.AsExpression; + } + + export function isNonNullExpression(node: Node): node is NonNullExpression { + return node.kind === SyntaxKind.NonNullExpression; + } + + export function isMetaProperty(node: Node): node is MetaProperty { + return node.kind === SyntaxKind.MetaProperty; + } + + // Misc + + export function isTemplateSpan(node: Node): node is TemplateSpan { + return node.kind === SyntaxKind.TemplateSpan; + } + + export function isSemicolonClassElement(node: Node): node is SemicolonClassElement { + return node.kind === SyntaxKind.SemicolonClassElement; + } + + // Block + + export function isBlock(node: Node): node is Block { + return node.kind === SyntaxKind.Block; + } + + export function isVariableStatement(node: Node): node is VariableStatement { + return node.kind === SyntaxKind.VariableStatement; + } + + export function isEmptyStatement(node: Node): node is EmptyStatement { + return node.kind === SyntaxKind.EmptyStatement; + } + + export function isExpressionStatement(node: Node): node is ExpressionStatement { + return node.kind === SyntaxKind.ExpressionStatement; + } + + export function isIfStatement(node: Node): node is IfStatement { + return node.kind === SyntaxKind.IfStatement; + } + + export function isDoStatement(node: Node): node is DoStatement { + return node.kind === SyntaxKind.DoStatement; + } + + export function isWhileStatement(node: Node): node is WhileStatement { + return node.kind === SyntaxKind.WhileStatement; + } + + export function isForStatement(node: Node): node is ForStatement { + return node.kind === SyntaxKind.ForStatement; + } + + export function isForInStatement(node: Node): node is ForInStatement { + return node.kind === SyntaxKind.ForInStatement; + } + + export function isForOfStatement(node: Node): node is ForOfStatement { + return node.kind === SyntaxKind.ForOfStatement; + } + + export function isContinueStatement(node: Node): node is ContinueStatement { + return node.kind === SyntaxKind.ContinueStatement; + } + + export function isBreakStatement(node: Node): node is BreakStatement { + return node.kind === SyntaxKind.BreakStatement; + } + + export function isReturnStatement(node: Node): node is ReturnStatement { + return node.kind === SyntaxKind.ReturnStatement; + } + + export function isWithStatement(node: Node): node is WithStatement { + return node.kind === SyntaxKind.WithStatement; + } + + export function isSwitchStatement(node: Node): node is SwitchStatement { + return node.kind === SyntaxKind.SwitchStatement; + } + + export function isLabeledStatement(node: Node): node is LabeledStatement { + return node.kind === SyntaxKind.LabeledStatement; + } + + export function isThrowStatement(node: Node): node is ThrowStatement { + return node.kind === SyntaxKind.ThrowStatement; + } + + export function isTryStatement(node: Node): node is TryStatement { + return node.kind === SyntaxKind.TryStatement; + } + + export function isDebuggerStatement(node: Node): node is DebuggerStatement { + return node.kind === SyntaxKind.DebuggerStatement; + } + + export function isVariableDeclaration(node: Node): node is VariableDeclaration { + return node.kind === SyntaxKind.VariableDeclaration; + } + + export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { + return node.kind === SyntaxKind.VariableDeclarationList; + } + + export function isFunctionDeclaration(node: Node): node is FunctionDeclaration { + return node.kind === SyntaxKind.FunctionDeclaration; + } + + export function isClassDeclaration(node: Node): node is ClassDeclaration { + return node.kind === SyntaxKind.ClassDeclaration; + } + + export function isInterfaceDeclaration(node: Node): node is InterfaceDeclaration { + return node.kind === SyntaxKind.InterfaceDeclaration; + } + + export function isTypeAliasDeclaration(node: Node): node is TypeAliasDeclaration { + return node.kind === SyntaxKind.TypeAliasDeclaration; + } + + export function isEnumDeclaration(node: Node): node is EnumDeclaration { + return node.kind === SyntaxKind.EnumDeclaration; + } + + export function isModuleDeclaration(node: Node): node is ModuleDeclaration { + return node.kind === SyntaxKind.ModuleDeclaration; + } + + export function isModuleBlock(node: Node): node is ModuleBlock { + return node.kind === SyntaxKind.ModuleBlock; + } + + export function isCaseBlock(node: Node): node is CaseBlock { + return node.kind === SyntaxKind.CaseBlock; + } + + export function isNamespaceExportDeclaration(node: Node): node is NamespaceExportDeclaration { + return node.kind === SyntaxKind.NamespaceExportDeclaration; + } + + export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { + return node.kind === SyntaxKind.ImportEqualsDeclaration; + } + + export function isImportDeclaration(node: Node): node is ImportDeclaration { + return node.kind === SyntaxKind.ImportDeclaration; + } + + export function isImportClause(node: Node): node is ImportClause { + return node.kind === SyntaxKind.ImportClause; + } + + export function isNamespaceImport(node: Node): node is NamespaceImport { + return node.kind === SyntaxKind.NamespaceImport; + } + + export function isNamedImports(node: Node): node is NamedImports { + return node.kind === SyntaxKind.NamedImports; + } + + export function isImportSpecifier(node: Node): node is ImportSpecifier { + return node.kind === SyntaxKind.ImportSpecifier; + } + + export function isExportAssignment(node: Node): node is ExportAssignment { + return node.kind === SyntaxKind.ExportAssignment; + } + + export function isExportDeclaration(node: Node): node is ExportDeclaration { + return node.kind === SyntaxKind.ExportDeclaration; + } + + export function isNamedExports(node: Node): node is NamedExports { + return node.kind === SyntaxKind.NamedExports; + } + + export function isExportSpecifier(node: Node): node is ExportSpecifier { + return node.kind === SyntaxKind.ExportSpecifier; + } + + export function isMissingDeclaration(node: Node): node is MissingDeclaration { + return node.kind === SyntaxKind.MissingDeclaration; + } + + // Module References + + export function isExternalModuleReference(node: Node): node is ExternalModuleReference { + return node.kind === SyntaxKind.ExternalModuleReference; + } + + // JSX + + export function isJsxElement(node: Node): node is JsxElement { + return node.kind === SyntaxKind.JsxElement; + } + + export function isJsxSelfClosingElement(node: Node): node is JsxSelfClosingElement { + return node.kind === SyntaxKind.JsxSelfClosingElement; + } + + export function isJsxOpeningElement(node: Node): node is JsxOpeningElement { + return node.kind === SyntaxKind.JsxOpeningElement; + } + + export function isJsxClosingElement(node: Node): node is JsxClosingElement { + return node.kind === SyntaxKind.JsxClosingElement; + } + + export function isJsxAttribute(node: Node): node is JsxAttribute { + return node.kind === SyntaxKind.JsxAttribute; + } + + export function isJsxAttributes(node: Node): node is JsxAttributes { + return node.kind === SyntaxKind.JsxAttributes; + } + + export function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute { + return node.kind === SyntaxKind.JsxSpreadAttribute; + } + + export function isJsxExpression(node: Node): node is JsxExpression { + return node.kind === SyntaxKind.JsxExpression; + } + + // Clauses + + export function isCaseClause(node: Node): node is CaseClause { + return node.kind === SyntaxKind.CaseClause; + } + + export function isDefaultClause(node: Node): node is DefaultClause { + return node.kind === SyntaxKind.DefaultClause; + } + + export function isHeritageClause(node: Node): node is HeritageClause { + return node.kind === SyntaxKind.HeritageClause; + } + + export function isCatchClause(node: Node): node is CatchClause { + return node.kind === SyntaxKind.CatchClause; + } + + // Property assignments + + export function isPropertyAssignment(node: Node): node is PropertyAssignment { + return node.kind === SyntaxKind.PropertyAssignment; + } + + export function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment { + return node.kind === SyntaxKind.ShorthandPropertyAssignment; + } + + export function isSpreadAssignment(node: Node): node is SpreadAssignment { + return node.kind === SyntaxKind.SpreadAssignment; + } + + // Enum + + export function isEnumMember(node: Node): node is EnumMember { + return node.kind === SyntaxKind.EnumMember; + } + + // Top-level nodes + export function isSourceFile(node: Node): node is SourceFile { + return node.kind === SyntaxKind.SourceFile; + } + + export function isBundle(node: Node): node is Bundle { + return node.kind === SyntaxKind.Bundle; + } + + // JSDoc + + export function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression { + return node.kind === SyntaxKind.JSDocTypeExpression; + } + + export function isJSDocAllType(node: JSDocAllType): node is JSDocAllType { + return node.kind === SyntaxKind.JSDocAllType; + } + + export function isJSDocUnknownType(node: Node): node is JSDocUnknownType { + return node.kind === SyntaxKind.JSDocUnknownType; + } + + export function isJSDocArrayType(node: Node): node is JSDocArrayType { + return node.kind === SyntaxKind.JSDocArrayType; + } + + export function isJSDocUnionType(node: Node): node is JSDocUnionType { + return node.kind === SyntaxKind.JSDocUnionType; + } + + export function isJSDocTupleType(node: Node): node is JSDocTupleType { + return node.kind === SyntaxKind.JSDocTupleType; + } + + export function isJSDocNullableType(node: Node): node is JSDocNullableType { + return node.kind === SyntaxKind.JSDocNullableType; + } + + export function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType { + return node.kind === SyntaxKind.JSDocNonNullableType; + } + + export function isJSDocRecordType(node: Node): node is JSDocRecordType { + return node.kind === SyntaxKind.JSDocRecordType; + } + + export function isJSDocRecordMember(node: Node): node is JSDocRecordMember { + return node.kind === SyntaxKind.JSDocRecordMember; + } + + export function isJSDocTypeReference(node: Node): node is JSDocTypeReference { + return node.kind === SyntaxKind.JSDocTypeReference; + } + + export function isJSDocOptionalType(node: Node): node is JSDocOptionalType { + return node.kind === SyntaxKind.JSDocOptionalType; + } + + export function isJSDocFunctionType(node: Node): node is JSDocFunctionType { + return node.kind === SyntaxKind.JSDocFunctionType; + } + + export function isJSDocVariadicType(node: Node): node is JSDocVariadicType { + return node.kind === SyntaxKind.JSDocVariadicType; + } + + export function isJSDocConstructorType(node: Node): node is JSDocConstructorType { + return node.kind === SyntaxKind.JSDocConstructorType; + } + + export function isJSDocThisType(node: Node): node is JSDocThisType { + return node.kind === SyntaxKind.JSDocThisType; + } + + export function isJSDoc(node: Node): node is JSDoc { + return node.kind === SyntaxKind.JSDocComment; + } + + export function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag { + return node.kind === SyntaxKind.JSDocAugmentsTag; + } + + export function isJSDocParameterTag(node: Node): node is JSDocParameterTag { + return node.kind === SyntaxKind.JSDocParameterTag; + } + + export function isJSDocReturnTag(node: Node): node is JSDocReturnTag { + return node.kind === SyntaxKind.JSDocReturnTag; + } + + export function isJSDocTypeTag(node: Node): node is JSDocTypeTag { + return node.kind === SyntaxKind.JSDocTypeTag; + } + + export function isJSDocTemplateTag(node: Node): node is JSDocTemplateTag { + return node.kind === SyntaxKind.JSDocTemplateTag; + } + + export function isJSDocTypedefTag(node: Node): node is JSDocTypedefTag { + return node.kind === SyntaxKind.JSDocTypedefTag; + } + + export function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag { + return node.kind === SyntaxKind.JSDocPropertyTag; + } + + export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral { + return node.kind === SyntaxKind.JSDocTypeLiteral; + } + + export function isJSDocLiteralType(node: Node): node is JSDocLiteralType { + return node.kind === SyntaxKind.JSDocLiteralType; + } +} + +// Node tests +// +// All node tests in the following list should *not* reference parent pointers so that +// they may be used with transformations. +namespace ts { + /** + * True if node is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + */ + export function isToken(n: Node): boolean { + return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; + } + + // Node Arrays + + /* @internal */ + export function isNodeArray(array: T[]): array is NodeArray { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); + } + + // Literals + + /* @internal */ + export function isLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken; + } + + export function isLiteralExpression(node: Node): node is LiteralExpression { + return isLiteralKind(node.kind); + } + + // Pseudo-literals + + /* @internal */ + export function isTemplateLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; + } + + export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail { + const kind = node.kind; + return kind === SyntaxKind.TemplateMiddle + || kind === SyntaxKind.TemplateTail; + } + + // Identifiers + + /* @internal */ + export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier { + // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. + return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; + } + + // Keywords + + /* @internal */ + export function isModifierKind(token: SyntaxKind): boolean { + switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsyncKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: + case SyntaxKind.PublicKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.StaticKeyword: + return true; + } + return false; + } + + export function isModifier(node: Node): node is Modifier { + return isModifierKind(node.kind); + } + + export function isEntityName(node: Node): node is EntityName { + const kind = node.kind; + return kind === SyntaxKind.QualifiedName + || kind === SyntaxKind.Identifier; + } + + export function isPropertyName(node: Node): node is PropertyName { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.NumericLiteral + || kind === SyntaxKind.ComputedPropertyName; + } + + export function isBindingName(node: Node): node is BindingName { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.ObjectBindingPattern + || kind === SyntaxKind.ArrayBindingPattern; + } + + // Functions + + export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { + return node && isFunctionLikeKind(node.kind); + } + + /* @internal */ + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.Constructor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ArrowFunction: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return true; + } + + return false; + } + + // Classes + export function isClassElement(node: Node): node is ClassElement { + const kind = node.kind; + return kind === SyntaxKind.Constructor + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.SemicolonClassElement + || kind === SyntaxKind.MissingDeclaration; + } + + export function isClassLike(node: Node): node is ClassLikeDeclaration { + return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); + } + + export function isAccessor(node: Node): node is AccessorDeclaration { + return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); + } + + // Type members + + export function isTypeElement(node: Node): node is TypeElement { + const kind = node.kind; + return kind === SyntaxKind.ConstructSignature + || kind === SyntaxKind.CallSignature + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.MissingDeclaration; + } + + export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike { + const kind = node.kind; + return kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.SpreadAssignment + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.MissingDeclaration; + } + + // Type + + function isTypeNodeKind(kind: SyntaxKind) { + return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) + || kind === SyntaxKind.AnyKeyword + || kind === SyntaxKind.NumberKeyword + || kind === SyntaxKind.ObjectKeyword + || kind === SyntaxKind.BooleanKeyword + || kind === SyntaxKind.StringKeyword + || kind === SyntaxKind.SymbolKeyword + || kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.VoidKeyword + || kind === SyntaxKind.UndefinedKeyword + || kind === SyntaxKind.NullKeyword + || kind === SyntaxKind.NeverKeyword + || kind === SyntaxKind.ExpressionWithTypeArguments; + } + + /** + * Node test that determines whether a node is a valid type node. + * This differs from the `isPartOfTypeNode` function which determines whether a node is *part* + * of a TypeNode. + */ + export function isTypeNode(node: Node): node is TypeNode { + return isTypeNodeKind(node.kind); + } + + export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode { + switch (node.kind) { + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return true; + } + + return false; + } + + // Binding patterns + + /* @internal */ + export function isBindingPattern(node: Node): node is BindingPattern { + if (node) { + const kind = node.kind; + return kind === SyntaxKind.ArrayBindingPattern + || kind === SyntaxKind.ObjectBindingPattern; + } + + return false; + } + + /* @internal */ + export function isAssignmentPattern(node: Node): node is AssignmentPattern { + const kind = node.kind; + return kind === SyntaxKind.ArrayLiteralExpression + || kind === SyntaxKind.ObjectLiteralExpression; + } + + + /* @internal */ + export function isArrayBindingElement(node: Node): node is ArrayBindingElement { + const kind = node.kind; + return kind === SyntaxKind.BindingElement + || kind === SyntaxKind.OmittedExpression; + } + + + /** + * Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration + */ + /* @internal */ + export function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement { + switch (bindingElement.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.BindingElement: + return true; + } + + return false; + } + + /** + * Determines whether a node is a BindingOrAssignmentPattern + */ + /* @internal */ + export function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern { + return isObjectBindingOrAssignmentPattern(node) + || isArrayBindingOrAssignmentPattern(node); + } + + /** + * Determines whether a node is an ObjectBindingOrAssignmentPattern + */ + /* @internal */ + export function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern { + switch (node.kind) { + case SyntaxKind.ObjectBindingPattern: + case SyntaxKind.ObjectLiteralExpression: + return true; + } + + return false; + } + + /** + * Determines whether a node is an ArrayBindingOrAssignmentPattern + */ + /* @internal */ + export function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern { + switch (node.kind) { + case SyntaxKind.ArrayBindingPattern: + case SyntaxKind.ArrayLiteralExpression: + return true; + } + + return false; + } + + // Expression + + export function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName { + const kind = node.kind; + return kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.QualifiedName; + } + + export function isCallLikeExpression(node: Node): node is CallLikeExpression { + switch (node.kind) { + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.Decorator: + return true; + default: + return false; + } + } + + export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression { + return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression; + } + + export function isTemplateLiteral(node: Node): node is TemplateLiteral { + const kind = node.kind; + return kind === SyntaxKind.TemplateExpression + || kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } + + function isLeftHandSideExpressionKind(kind: SyntaxKind): boolean { + return kind === SyntaxKind.PropertyAccessExpression + || kind === SyntaxKind.ElementAccessExpression + || kind === SyntaxKind.NewExpression + || kind === SyntaxKind.CallExpression + || kind === SyntaxKind.JsxElement + || kind === SyntaxKind.JsxSelfClosingElement + || kind === SyntaxKind.TaggedTemplateExpression + || kind === SyntaxKind.ArrayLiteralExpression + || kind === SyntaxKind.ParenthesizedExpression + || kind === SyntaxKind.ObjectLiteralExpression + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.FunctionExpression + || kind === SyntaxKind.Identifier + || kind === SyntaxKind.RegularExpressionLiteral + || kind === SyntaxKind.NumericLiteral + || kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.NoSubstitutionTemplateLiteral + || kind === SyntaxKind.TemplateExpression + || kind === SyntaxKind.FalseKeyword + || kind === SyntaxKind.NullKeyword + || kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.TrueKeyword + || kind === SyntaxKind.SuperKeyword + || kind === SyntaxKind.NonNullExpression + || kind === SyntaxKind.MetaProperty; + } + + /* @internal */ + export function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression { + return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isUnaryExpressionKind(kind: SyntaxKind): boolean { + return kind === SyntaxKind.PrefixUnaryExpression + || kind === SyntaxKind.PostfixUnaryExpression + || kind === SyntaxKind.DeleteExpression + || kind === SyntaxKind.TypeOfExpression + || kind === SyntaxKind.VoidExpression + || kind === SyntaxKind.AwaitExpression + || kind === SyntaxKind.TypeAssertionExpression + || isLeftHandSideExpressionKind(kind); + } + + /* @internal */ + export function isUnaryExpression(node: Node): node is UnaryExpression { + return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + function isExpressionKind(kind: SyntaxKind) { + return kind === SyntaxKind.ConditionalExpression + || kind === SyntaxKind.YieldExpression + || kind === SyntaxKind.ArrowFunction + || kind === SyntaxKind.BinaryExpression + || kind === SyntaxKind.SpreadElement + || kind === SyntaxKind.AsExpression + || kind === SyntaxKind.OmittedExpression + || kind === SyntaxKind.CommaListExpression + || isUnaryExpressionKind(kind); + } + + /* @internal */ + export function isExpression(node: Node): node is Expression { + return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); + } + + export function isAssertionExpression(node: Node): node is AssertionExpression { + const kind = node.kind; + return kind === SyntaxKind.TypeAssertionExpression + || kind === SyntaxKind.AsExpression; + } + + /* @internal */ + export function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression { + return node.kind === SyntaxKind.PartiallyEmittedExpression; + } + + /* @internal */ + export function isNotEmittedStatement(node: Node): node is NotEmittedStatement { + return node.kind === SyntaxKind.NotEmittedStatement; + } + + /* @internal */ + export function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); + } + + // Statement + + export function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement { + switch (node.kind) { + case SyntaxKind.ForStatement: + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + return true; + case SyntaxKind.LabeledStatement: + return lookInLabeledStatements && isIterationStatement((node).statement, lookInLabeledStatements); + } + + return false; + } + + // Element + + /* @internal */ + export function isConciseBody(node: Node): node is ConciseBody { + return isBlock(node) + || isExpression(node); + } + + /* @internal */ + export function isFunctionBody(node: Node): node is FunctionBody { + return isBlock(node); + } + + /* @internal */ + export function isForInitializer(node: Node): node is ForInitializer { + return isVariableDeclarationList(node) + || isExpression(node); + } + + /* @internal */ + export function isModuleBody(node: Node): node is ModuleBody { + const kind = node.kind; + return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.Identifier; + } + + /* @internal */ + export function isNamespaceBody(node: Node): node is NamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.ModuleBlock + || kind === SyntaxKind.ModuleDeclaration; + } + + /* @internal */ + export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody { + const kind = node.kind; + return kind === SyntaxKind.Identifier + || kind === SyntaxKind.ModuleDeclaration; + } + + /* @internal */ + export function isNamedImportBindings(node: Node): node is NamedImportBindings { + const kind = node.kind; + return kind === SyntaxKind.NamedImports + || kind === SyntaxKind.NamespaceImport; + } + + /* @internal */ + export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration { + return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration; + } + + function isDeclarationKind(kind: SyntaxKind) { + return kind === SyntaxKind.ArrowFunction + || kind === SyntaxKind.BindingElement + || kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.EnumMember + || kind === SyntaxKind.ExportSpecifier + || kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.FunctionExpression + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.ImportClause + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ImportSpecifier + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.JsxAttribute + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration + || kind === SyntaxKind.NamespaceImport + || kind === SyntaxKind.Parameter + || kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.TypeParameter + || kind === SyntaxKind.VariableDeclaration + || kind === SyntaxKind.JSDocTypedefTag; + } + + function isDeclarationStatementKind(kind: SyntaxKind) { + return kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.MissingDeclaration + || kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.ImportDeclaration + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ExportDeclaration + || kind === SyntaxKind.ExportAssignment + || kind === SyntaxKind.NamespaceExportDeclaration; + } + + function isStatementKindButNotDeclarationKind(kind: SyntaxKind) { + return kind === SyntaxKind.BreakStatement + || kind === SyntaxKind.ContinueStatement + || kind === SyntaxKind.DebuggerStatement + || kind === SyntaxKind.DoStatement + || kind === SyntaxKind.ExpressionStatement + || kind === SyntaxKind.EmptyStatement + || kind === SyntaxKind.ForInStatement + || kind === SyntaxKind.ForOfStatement + || kind === SyntaxKind.ForStatement + || kind === SyntaxKind.IfStatement + || kind === SyntaxKind.LabeledStatement + || kind === SyntaxKind.ReturnStatement + || kind === SyntaxKind.SwitchStatement + || kind === SyntaxKind.ThrowStatement + || kind === SyntaxKind.TryStatement + || kind === SyntaxKind.VariableStatement + || kind === SyntaxKind.WhileStatement + || kind === SyntaxKind.WithStatement + || kind === SyntaxKind.NotEmittedStatement + || kind === SyntaxKind.EndOfDeclarationMarker + || kind === SyntaxKind.MergeDeclarationMarker; + } + + /* @internal */ + export function isDeclaration(node: Node): node is NamedDeclaration { + return isDeclarationKind(node.kind); + } + + /* @internal */ + export function isDeclarationStatement(node: Node): node is DeclarationStatement { + return isDeclarationStatementKind(node.kind); + } + + /** + * Determines whether the node is a statement that is not also a declaration + */ + /* @internal */ + export function isStatementButNotDeclaration(node: Node): node is Statement { + return isStatementKindButNotDeclarationKind(node.kind); + } + + /* @internal */ + export function isStatement(node: Node): node is Statement { + const kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === SyntaxKind.Block; + } + + // Module references + + /* @internal */ + export function isModuleReference(node: Node): node is ModuleReference { + const kind = node.kind; + return kind === SyntaxKind.ExternalModuleReference + || kind === SyntaxKind.QualifiedName + || kind === SyntaxKind.Identifier; + } + + // JSX + + /* @internal */ + export function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression { + const kind = node.kind; + return kind === SyntaxKind.ThisKeyword + || kind === SyntaxKind.Identifier + || kind === SyntaxKind.PropertyAccessExpression; + } + + /* @internal */ + export function isJsxChild(node: Node): node is JsxChild { + const kind = node.kind; + return kind === SyntaxKind.JsxElement + || kind === SyntaxKind.JsxExpression + || kind === SyntaxKind.JsxSelfClosingElement + || kind === SyntaxKind.JsxText; + } + + /* @internal */ + export function isJsxAttributeLike(node: Node): node is JsxAttributeLike { + const kind = node.kind; + return kind === SyntaxKind.JsxAttribute + || kind === SyntaxKind.JsxSpreadAttribute; + } + + /* @internal */ + export function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression { + const kind = node.kind; + return kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.JsxExpression; + } + + export function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement { + const kind = node.kind; + return kind === SyntaxKind.JsxOpeningElement + || kind === SyntaxKind.JsxSelfClosingElement; + } + + // Clauses + + export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { + const kind = node.kind; + return kind === SyntaxKind.CaseClause + || kind === SyntaxKind.DefaultClause; + } + + // JSDoc + + /** True if node is of some JSDoc syntax kind. */ + /* @internal */ + export function isJSDocNode(node: Node): boolean { + return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; + } + + // TODO: determine what this does before making it public. + /* @internal */ + export function isJSDocTag(node: Node): boolean { + return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; + } +} diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index fa642b7a3c4..fc3b9c784cc 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1517,57 +1517,80 @@ namespace ts { } export namespace Debug { + if (isDebugging) { + // Add additional properties in debug mode to assist with debugging. + Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, { + "__debugFlags": { get(this: Symbol) { return formatSymbolFlags(this.flags); } } + }); + + Object.defineProperties(objectAllocator.getTypeConstructor().prototype, { + "__debugFlags": { get(this: Type) { return formatTypeFlags(this.flags); } }, + "__debugObjectFlags": { get(this: Type) { return this.flags & TypeFlags.Object ? formatObjectFlags((this).objectFlags) : ""; } }, + "__debugTypeToString": { value(this: Type) { return this.checker.typeToString(this); } }, + }); + + for (const ctor of [objectAllocator.getNodeConstructor(), objectAllocator.getIdentifierConstructor(), objectAllocator.getTokenConstructor(), objectAllocator.getSourceFileConstructor()]) { + if (!ctor.prototype.hasOwnProperty("__debugKind")) { + Object.defineProperties(ctor.prototype, { + "__debugKind": { get(this: Node) { return formatSyntaxKind(this.kind); } }, + "__debugModifierFlags": { get(this: Node) { return formatModifierFlags(getModifierFlagsNoCache(this)); } }, + "__debugTransformFlags": { get(this: Node) { return formatTransformFlags(this.transformFlags); } }, + "__debugEmitFlags": { get(this: Node) { return formatEmitFlags(getEmitFlags(this)); } }, + "__debugGetText": { value(this: Node, includeTrivia?: boolean) { + if (nodeIsSynthesized(this)) return ""; + const parseNode = getParseTreeNode(this); + const sourceFile = parseNode && getSourceFileOfNode(parseNode); + return sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : ""; + } } + }); + } + } + } + export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal) - ? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`) + ? (node: Node, message?: string): void => fail( + `${message || "Unexpected node."}\r\nNode ${formatSyntaxKind(node.kind)} was unexpected.`, + failBadSyntaxKind) : noop; export const assertEachNode = shouldAssert(AssertionLevel.Normal) - ? (nodes: Node[], test: (node: Node) => boolean, message?: string) => assert( - test === undefined || every(nodes, test), - message || "Unexpected node.", - () => `Node array did not pass test '${getFunctionName(test)}'.`) + ? (nodes: Node[], test: (node: Node) => boolean, message?: string): void => assert( + test === undefined || every(nodes, test), + message || "Unexpected node.", + () => `Node array did not pass test '${getFunctionName(test)}'.`, + assertEachNode) : noop; export const assertNode = shouldAssert(AssertionLevel.Normal) - ? (node: Node, test: (node: Node) => boolean, message?: string) => assert( - test === undefined || test(node), - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`) + ? (node: Node, test: (node: Node) => boolean, message?: string): void => assert( + test === undefined || test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`, + assertNode) : noop; export const assertOptionalNode = shouldAssert(AssertionLevel.Normal) - ? (node: Node, test: (node: Node) => boolean, message?: string) => assert( - test === undefined || node === undefined || test(node), - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`) + ? (node: Node, test: (node: Node) => boolean, message?: string): void => assert( + test === undefined || node === undefined || test(node), + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`, + assertOptionalNode) : noop; export const assertOptionalToken = shouldAssert(AssertionLevel.Normal) - ? (node: Node, kind: SyntaxKind, message?: string) => assert( - kind === undefined || node === undefined || node.kind === kind, - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node.kind)} was not a '${formatSyntaxKind(kind)}' token.`) + ? (node: Node, kind: SyntaxKind, message?: string): void => assert( + kind === undefined || node === undefined || node.kind === kind, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node.kind)} was not a '${formatSyntaxKind(kind)}' token.`, + assertOptionalToken) : noop; export const assertMissingNode = shouldAssert(AssertionLevel.Normal) - ? (node: Node, message?: string) => assert( - node === undefined, - message || "Unexpected node.", - () => `Node ${formatSyntaxKind(node.kind)} was unexpected'.`) + ? (node: Node, message?: string): void => assert( + node === undefined, + message || "Unexpected node.", + () => `Node ${formatSyntaxKind(node.kind)} was unexpected'.`, + assertMissingNode) : noop; - - function getFunctionName(func: Function) { - if (typeof func !== "function") { - return ""; - } - else if (func.hasOwnProperty("name")) { - return (func).name; - } - else { - const text = Function.prototype.toString.call(func); - const match = /^function\s+([\w\$]+)\s*\(/.exec(text); - return match ? match[1] : ""; - } - } } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8f19b83c7ad..07aacf3c8a7 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -479,24 +479,11 @@ namespace FourSlash { } private getDiagnostics(fileName: string): ts.Diagnostic[] { - const syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName); - const semanticErrors = this.languageService.getSemanticDiagnostics(fileName); - - const diagnostics: ts.Diagnostic[] = []; - diagnostics.push.apply(diagnostics, syntacticErrors); - diagnostics.push.apply(diagnostics, semanticErrors); - - return diagnostics; + return this.languageService.getSyntacticDiagnostics(fileName).concat(this.languageService.getSemanticDiagnostics(fileName)); } private getAllDiagnostics(): ts.Diagnostic[] { - const diagnostics: ts.Diagnostic[] = []; - - for (const fileName of this.languageServiceAdapterHost.getFilenames()) { - diagnostics.push.apply(this.getDiagnostics(fileName)); - } - - return diagnostics; + return ts.flatMap(this.languageServiceAdapterHost.getFilenames(), fileName => this.getDiagnostics(fileName)); } public verifyErrorExistsAfterMarker(markerName: string, negative: boolean, after: boolean) { @@ -2276,23 +2263,22 @@ namespace FourSlash { } /** - * Compares expected text to the text that would be in the sole range - * (ie: [|...|]) in the file after applying the codefix sole codefix - * in the source file. - * - * Because codefixes are only applied on the working file, it is unsafe - * to apply this more than once (consider a refactoring across files). + * Finds and applies a code action corresponding to the supplied parameters. + * If index is undefined, applies the unique code action available. + * @param errorCode The error code that generated the code action. + * @param index The nth (0-index-based) codeaction available generated by errorCode. */ - public verifyRangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number) { + public getAndApplyCodeActions(errorCode?: number, index?: number) { + const fileName = this.activeFile.fileName; + this.applyCodeActions(this.getCodeFixActions(fileName, errorCode), index); + } + + public verifyRangeIs(expectedText: string, includeWhiteSpace?: boolean) { const ranges = this.getRanges(); if (ranges.length !== 1) { this.raiseError("Exactly one range should be specified in the testfile."); } - const fileName = this.activeFile.fileName; - - this.applyCodeAction(fileName, this.getCodeFixActions(fileName, errorCode), index); - const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace @@ -2304,6 +2290,16 @@ namespace FourSlash { } } + /** + * Compares expected text to the text that would be in the sole range + * (ie: [|...|]) in the file after applying the codefix sole codefix + * in the source file. + */ + public verifyRangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number) { + this.getAndApplyCodeActions(errorCode, index); + this.verifyRangeIs(expectedText, includeWhiteSpace); + } + /** * Applies fixes for the errors in fileName and compares the results to * expectedContents after all fixes have been applied. @@ -2316,7 +2312,7 @@ namespace FourSlash { public verifyFileAfterCodeFix(expectedContents: string, fileName?: string) { fileName = fileName ? fileName : this.activeFile.fileName; - this.applyCodeAction(fileName, this.getCodeFixActions(fileName)); + this.applyCodeActions(this.getCodeFixActions(fileName)); const actualContents: string = this.getFileContent(fileName); if (this.removeWhitespace(actualContents) !== this.removeWhitespace(expectedContents)) { @@ -2354,11 +2350,10 @@ namespace FourSlash { return actions; } - private applyCodeAction(fileName: string, actions: ts.CodeAction[], index?: number): void { + private applyCodeActions(actions: ts.CodeAction[], index?: number): void { if (index === undefined) { if (!(actions && actions.length === 1)) { - const actionText = (actions && actions.length) ? JSON.stringify(actions) : "none"; - this.raiseError(`Should find exactly one codefix, but found ${actionText}`); + this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`); } index = 0; } @@ -2368,12 +2363,11 @@ namespace FourSlash { } } - const fileChanges = ts.find(actions[index].changes, change => change.fileName === fileName); - if (!fileChanges) { - this.raiseError("The CodeFix found doesn't provide any changes in this file."); - } + const changes = actions[index].changes; - this.applyEdits(fileChanges.fileName, fileChanges.textChanges, /*isFormattingEdit*/ false); + for (const change of changes) { + this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + } } public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) { @@ -2385,7 +2379,10 @@ namespace FourSlash { const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode); if (!codeFixes || codeFixes.length === 0) { - this.raiseError("No codefixes returned."); + if (expectedTextArray.length !== 0) { + this.raiseError("No codefixes returned."); + } + return; } const actualTextArray: string[] = []; @@ -2758,7 +2755,7 @@ namespace FourSlash { const codeActions = this.languageService.getRefactorCodeActions(this.activeFile.fileName, formattingOptions, markerPos, refactorNameToApply); - this.applyCodeAction(this.activeFile.fileName, codeActions); + this.applyCodeActions(codeActions); const actualContent = this.getFileContent(this.activeFile.fileName); if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) { @@ -3805,6 +3802,14 @@ namespace FourSlashInterface { this.state.verifyFileAfterApplyingRefactorAtMarker(markerName, expectedContent, refactorNameToApply, formattingOptions); } + public rangeIs(expectedText: string, includeWhiteSpace?: boolean): void { + this.state.verifyRangeIs(expectedText, includeWhiteSpace); + } + + public getAndApplyCodeFix(errorCode?: number, index?: number): void { + this.state.getAndApplyCodeActions(errorCode, index); + } + public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void { this.state.verifyImportFixAtPosition(expectedTextArray, errorCode); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 49dbdbf2102..9bf4591112d 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -857,6 +857,7 @@ namespace Harness { export function getDefaultLibFileName(options: ts.CompilerOptions): string { switch (options.target) { + case ts.ScriptTarget.ESNext: case ts.ScriptTarget.ES2017: return "lib.es2017.d.ts"; case ts.ScriptTarget.ES2016: diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index eeb47f0cfa0..76f585b623a 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -232,14 +232,11 @@ namespace Playback { // different entry). // TODO (yuisu): We can certainly remove these once we recapture the RWC using new API const normalizedPath = ts.normalizePath(path).toLowerCase(); - const result: string[] = []; - for (const directory of replayLog.directoriesRead) { + return ts.flatMap(replayLog.directoriesRead, directory => { if (ts.normalizeSlashes(directory.path).toLowerCase() === normalizedPath) { - result.push(...directory.result); + return directory.result; } - } - - return result; + }); }); wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 19ccc919d4c..01a208aa330 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -113,7 +113,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'.", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index 3aa1a4c9b8e..798f8c6a76b 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -122,7 +122,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'.", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index a9af46b2780..4bdafe04ba1 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -14,7 +14,9 @@ namespace ts { describe("printFile", () => { const printsCorrectly = makePrintsCorrectly("printsFileCorrectly"); - const sourceFile = createSourceFile("source.ts", ` + // Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run. + let sourceFile: SourceFile; + before(() => sourceFile = createSourceFile("source.ts", ` interface A { // comment1 readonly prop?: T; @@ -48,8 +50,7 @@ namespace ts { // comment10 function functionWithDefaultArgValue(argument: string = "defaultValue"): void { } - `, ScriptTarget.ES2015); - + `, ScriptTarget.ES2015)); printsCorrectly("default", {}, printer => printer.printFile(sourceFile)); printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile)); @@ -59,7 +60,8 @@ namespace ts { describe("printBundle", () => { const printsCorrectly = makePrintsCorrectly("printsBundleCorrectly"); - const bundle = createBundle([ + let bundle: Bundle; + before(() => bundle = createBundle([ createSourceFile("a.ts", ` /*! [a.ts] */ @@ -72,14 +74,15 @@ namespace ts { // comment1 const b = 2; `, ScriptTarget.ES2015) - ]); + ])); printsCorrectly("default", {}, printer => printer.printBundle(bundle)); printsCorrectly("removeComments", { removeComments: true }, printer => printer.printBundle(bundle)); }); describe("printNode", () => { const printsCorrectly = makePrintsCorrectly("printsNodeCorrectly"); - const sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015); + let sourceFile: SourceFile; + before(() => sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015)); // tslint:disable boolean-trivia const syntheticNode = createClassDeclaration( undefined, diff --git a/src/harness/unittests/telemetry.ts b/src/harness/unittests/telemetry.ts index d3811edf251..f250c732c0b 100644 --- a/src/harness/unittests/telemetry.ts +++ b/src/harness/unittests/telemetry.ts @@ -252,7 +252,8 @@ namespace ts.projectSystem { } getEvent(eventName: T["eventName"], mayBeMore = false): T["data"] { - if (mayBeMore) assert(this.events.length !== 0); else assert.equal(this.events.length, 1); + if (mayBeMore) { assert(this.events.length !== 0); } + else { assert.equal(this.events.length, 1); } const event = this.events.shift(); assert.equal(event.eventName, eventName); return event.data; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 6f898e7f4a6..7a19aa9167f 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -13,7 +13,8 @@ namespace ts.projectSystem { express: "express", jquery: "jquery", lodash: "lodash", - moment: "moment" + moment: "moment", + chroma: "chroma-js" }) }; @@ -61,7 +62,6 @@ namespace ts.projectSystem { super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log); } - safeFileList = safeList.path; protected postExecActions: PostExecAction[] = []; executePendingCommands() { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 699b1807428..c356d0941c0 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1009,6 +1009,26 @@ namespace ts.projectSystem { }); describe("discover typings", () => { + it("should use mappings from safe list", () => { + const app = { + path: "/a/b/app.js", + content: "" + }; + const jquery = { + path: "/a/b/jquery.js", + content: "" + }; + const chroma = { + path: "/a/b/chroma.min.js", + content: "" + }; + const cache = createMap(); + + const host = createServerHost([app, jquery, chroma]); + const result = JsTyping.discoverTypings(host, [app.path, jquery.path, chroma.path], getDirectoryPath(app.path), /*safeListPath*/ undefined, cache, { enable: true }, []); + assert.deepEqual(result.newTypingNames, ["jquery", "chroma-js"]); + }); + it("should return node for core modules", () => { const f = { path: "/a/b/app.js", @@ -1016,6 +1036,7 @@ namespace ts.projectSystem { }; const host = createServerHost([f]); const cache = createMap(); + for (const name of JsTyping.nodeCoreModuleList) { const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(f.path), /*safeListPath*/ undefined, cache, { enable: true }, [name, "somename"]); assert.deepEqual(result.newTypingNames.sort(), ["node", "somename"]); @@ -1040,7 +1061,7 @@ namespace ts.projectSystem { }); describe("telemetry events", () => { - it ("should be received", () => { + it("should be received", () => { const f1 = { path: "/a/app.js", content: "" @@ -1089,7 +1110,7 @@ namespace ts.projectSystem { }); describe("progress notifications", () => { - it ("should be sent for success", () => { + it("should be sent for success", () => { const f1 = { path: "/a/app.js", content: "" @@ -1140,7 +1161,7 @@ namespace ts.projectSystem { checkProjectActualFiles(projectService.inferredProjects[0], [f1.path, commander.path]); }); - it ("should be sent for error", () => { + it("should be sent for error", () => { const f1 = { path: "/a/app.js", content: "" diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 3a85f4ddad9..6decc78558a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -67,8 +67,8 @@ interface PropertyDescriptor { enumerable?: boolean; value?: any; writable?: boolean; - get? (): any; - set? (v: any): void; + get?(): any; + set?(v: any): void; } interface PropertyDescriptorMap { @@ -108,7 +108,7 @@ interface Object { } interface ObjectConstructor { - new (value?: any): Object; + new(value?: any): Object; (): any; (value: any): any; @@ -266,7 +266,7 @@ interface FunctionConstructor { * Creates a new function. * @param args A list of arguments the function accepts. */ - new (...args: string[]): Function; + new(...args: string[]): Function; (...args: string[]): Function; readonly prototype: Function; } @@ -403,7 +403,7 @@ interface String { } interface StringConstructor { - new (value?: any): String; + new(value?: any): String; (value?: any): string; readonly prototype: String; fromCharCode(...codes: number[]): string; @@ -420,7 +420,7 @@ interface Boolean { } interface BooleanConstructor { - new (value?: any): Boolean; + new(value?: any): Boolean; (value?: any): boolean; readonly prototype: Boolean; } @@ -457,7 +457,7 @@ interface Number { } interface NumberConstructor { - new (value?: any): Number; + new(value?: any): Number; (value?: any): number; readonly prototype: Number; @@ -759,10 +759,10 @@ interface Date { } interface DateConstructor { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + new(): Date; + new(value: number): Date; + new(value: string): Date; + new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; readonly prototype: Date; /** @@ -828,8 +828,8 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp | string): RegExp; - new (pattern: string, flags?: string): RegExp; + new(pattern: RegExp | string): RegExp; + new(pattern: string, flags?: string): RegExp; (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; @@ -856,7 +856,7 @@ interface Error { } interface ErrorConstructor { - new (message?: string): Error; + new(message?: string): Error; (message?: string): Error; readonly prototype: Error; } @@ -867,7 +867,7 @@ interface EvalError extends Error { } interface EvalErrorConstructor { - new (message?: string): EvalError; + new(message?: string): EvalError; (message?: string): EvalError; readonly prototype: EvalError; } @@ -878,7 +878,7 @@ interface RangeError extends Error { } interface RangeErrorConstructor { - new (message?: string): RangeError; + new(message?: string): RangeError; (message?: string): RangeError; readonly prototype: RangeError; } @@ -889,7 +889,7 @@ interface ReferenceError extends Error { } interface ReferenceErrorConstructor { - new (message?: string): ReferenceError; + new(message?: string): ReferenceError; (message?: string): ReferenceError; readonly prototype: ReferenceError; } @@ -900,7 +900,7 @@ interface SyntaxError extends Error { } interface SyntaxErrorConstructor { - new (message?: string): SyntaxError; + new(message?: string): SyntaxError; (message?: string): SyntaxError; readonly prototype: SyntaxError; } @@ -911,7 +911,7 @@ interface TypeError extends Error { } interface TypeErrorConstructor { - new (message?: string): TypeError; + new(message?: string): TypeError; (message?: string): TypeError; readonly prototype: TypeError; } @@ -922,7 +922,7 @@ interface URIError extends Error { } interface URIErrorConstructor { - new (message?: string): URIError; + new(message?: string): URIError; (message?: string): URIError; readonly prototype: URIError; } @@ -972,12 +972,10 @@ interface ReadonlyArray { * Returns a string representation of an array. */ toString(): string; - toLocaleString(): string; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. + * Returns a string representation of an array. The elements are converted to string using thier toLocalString methods. */ - concat>(...items: U[]): T[]; + toLocaleString(): string; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. @@ -1005,7 +1003,6 @@ interface ReadonlyArray { * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. */ indexOf(searchElement: T, fromIndex?: number): number; - /** * Returns the index of the last occurrence of a specified value in an array. * @param searchElement The value to locate in the array. @@ -1017,49 +1014,37 @@ interface ReadonlyArray { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; - every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; - some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void): void; - forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): void; + forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U): U[]; - map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; - map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): U[]; + map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S): S[]; - filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; - filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; + filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any): T[]; - filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; - filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): T[]; + filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => any, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1097,6 +1082,9 @@ interface Array { * Returns a string representation of an array. */ toString(): string; + /** + * Returns a string representation of an array. The elements are converted to string using thier toLocalString methods. + */ toLocaleString(): string; /** * Appends new elements to an array, and returns the new length of the array. @@ -1176,73 +1164,37 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; - every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; - some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void): void; - forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): void; + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; - map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; - map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; - map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; - map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; - map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; - map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; - map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; - map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; - map(callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; - map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any): T[]; - filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; - filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): T[]; + filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1272,7 +1224,7 @@ interface Array { } interface ArrayConstructor { - new (arrayLength?: number): any[]; + new(arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; (arrayLength?: number): any[]; @@ -1396,7 +1348,7 @@ type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes]; interface ArrayBufferConstructor { readonly prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; + new(byteLength: number): ArrayBuffer; isView(arg: any): arg is ArrayBufferView; } declare const ArrayBuffer: ArrayBufferConstructor; @@ -1547,7 +1499,7 @@ interface DataView { } interface DataViewConstructor { - new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView; + new(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView; } declare const DataView: DataViewConstructor; @@ -1595,9 +1547,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1616,9 +1566,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any): Int8Array; - filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; + filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1629,9 +1577,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1642,9 +1588,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1653,9 +1597,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1693,9 +1635,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number): Int8Array; - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; - map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1772,9 +1712,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -1805,9 +1743,9 @@ interface Int8Array { } interface Int8ArrayConstructor { readonly prototype: Int8Array; - new (length: number): Int8Array; - new (array: ArrayLike): Int8Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(length: number): Int8Array; + new(array: ArrayLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -1826,11 +1764,8 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; - from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1879,9 +1814,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1900,9 +1833,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any): Uint8Array; - filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; + filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1913,9 +1844,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1926,9 +1855,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1937,9 +1864,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1977,9 +1902,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number): Uint8Array; - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; - map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2056,9 +1979,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -2090,9 +2011,9 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: ArrayLike): Uint8Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(length: number): Uint8Array; + new(array: ArrayLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2111,11 +2032,7 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: ArrayLike): Uint8Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2164,9 +2081,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2185,9 +2100,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; - filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; - filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2198,9 +2111,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2211,9 +2122,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2222,9 +2131,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2262,9 +2169,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; - map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2341,9 +2246,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -2375,9 +2278,9 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: ArrayLike): Uint8ClampedArray; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(length: number): Uint8ClampedArray; + new(array: ArrayLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2396,11 +2299,7 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: ArrayLike): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2448,9 +2347,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2469,9 +2366,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any): Int16Array; - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2482,9 +2377,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2495,9 +2388,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2506,10 +2397,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; - + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. @@ -2546,9 +2434,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number): Int16Array; - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; - map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2625,9 +2511,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -2659,9 +2543,9 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; - new (length: number): Int16Array; - new (array: ArrayLike): Int16Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(length: number): Int16Array; + new(array: ArrayLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2680,11 +2564,8 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; - from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2733,9 +2614,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2754,9 +2633,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any): Uint16Array; - filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; + filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2767,9 +2644,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2780,9 +2655,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2791,9 +2664,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2831,9 +2702,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number): Uint16Array; - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; - map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2910,9 +2779,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -2944,9 +2811,9 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: ArrayLike): Uint16Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(length: number): Uint16Array; + new(array: ArrayLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -2965,11 +2832,8 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; - from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -3017,9 +2881,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3038,9 +2900,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any): Int32Array; - filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; + filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3051,9 +2911,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3064,9 +2922,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3075,9 +2931,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3115,9 +2969,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number): Int32Array; - map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; - map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3194,9 +3046,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -3228,9 +3078,9 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; - new (length: number): Int32Array; - new (array: ArrayLike): Int32Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(length: number): Int32Array; + new(array: ArrayLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3249,11 +3099,8 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; - from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3301,9 +3148,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3322,9 +3167,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any): Uint32Array; - filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; + filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3335,9 +3178,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3348,9 +3189,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3359,10 +3198,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; - + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. @@ -3399,9 +3235,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number): Uint32Array; - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; - map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3478,9 +3312,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -3512,9 +3344,9 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: ArrayLike): Uint32Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(length: number): Uint32Array; + new(array: ArrayLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3533,11 +3365,8 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; - from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3585,9 +3414,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3606,9 +3433,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any): Float32Array; - filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; + filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3619,9 +3444,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3632,9 +3455,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3643,9 +3464,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3683,9 +3502,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number): Float32Array; - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; - map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3762,9 +3579,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -3796,9 +3611,9 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; - new (length: number): Float32Array; - new (array: ArrayLike): Float32Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(length: number): Float32Array; + new(array: ArrayLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3817,11 +3632,8 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; - from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3870,9 +3682,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; - every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; - every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3891,9 +3701,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any): Float64Array; - filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; - filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; + filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3904,9 +3712,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; - find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; - find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3917,9 +3723,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3928,9 +3732,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void): void; - forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; - forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3968,9 +3770,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number): Float64Array; - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; - map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -4047,9 +3847,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; - some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; - some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. @@ -4081,9 +3879,9 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; - new (length: number): Float64Array; - new (array: ArrayLike): Float64Array; - new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(length: number): Float64Array; + new(array: ArrayLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. @@ -4102,11 +3900,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; - from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; @@ -4139,7 +3934,7 @@ declare namespace Intl { resolvedOptions(): ResolvedCollatorOptions; } var Collator: { - new (locales?: string | string[], options?: CollatorOptions): Collator; + new(locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; }; @@ -4176,7 +3971,7 @@ declare namespace Intl { resolvedOptions(): ResolvedNumberFormatOptions; } var NumberFormat: { - new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; + new(locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; }; @@ -4219,7 +4014,7 @@ declare namespace Intl { resolvedOptions(): ResolvedDateTimeFormatOptions; } var DateTimeFormat: { - new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; + new(locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; }; diff --git a/src/server/project.ts b/src/server/project.ts index 0646497acc5..be854f948ea 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -106,6 +106,7 @@ namespace ts.server { private rootFiles: ScriptInfo[] = []; private rootFilesMap: FileMap = createFileMap(); private program: ts.Program; + private externalFiles: SortedReadonlyArray; private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); private lastCachedUnresolvedImportsList: SortedReadonlyArray; @@ -261,8 +262,8 @@ namespace ts.server { abstract getProjectRootPath(): string | undefined; abstract getTypeAcquisition(): TypeAcquisition; - getExternalFiles(): string[] { - return []; + getExternalFiles(): SortedReadonlyArray { + return emptyArray as SortedReadonlyArray; } getSourceFile(path: Path) { @@ -561,6 +562,24 @@ namespace ts.server { } } } + + const oldExternalFiles = this.externalFiles || emptyArray as SortedReadonlyArray; + this.externalFiles = this.getExternalFiles(); + enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, + // Ensure a ScriptInfo is created for new external files. This is performed indirectly + // by the LSHost for files in the program when the program is retrieved above but + // the program doesn't contain external files so this must be done explicitly. + inserted => { + const scriptInfo = this.projectService.getOrCreateScriptInfo(inserted, /*openedByClient*/ false); + scriptInfo.attachToProject(this); + }, + removed => { + const scriptInfoToDetach = this.projectService.getScriptInfo(removed); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + }); + return hasChanges; } @@ -646,7 +665,7 @@ namespace ts.server { const added: string[] = []; const removed: string[] = []; - const updated: string[] = arrayFrom(updatedFileNames.keys()); + const updated: string[] = updatedFileNames ? arrayFrom(updatedFileNames.keys()) : []; forEachKey(currentFiles, id => { if (!lastReportedFileNames.has(id)) { @@ -956,19 +975,16 @@ namespace ts.server { return this.typeAcquisition; } - getExternalFiles(): string[] { - const items: string[] = []; - for (const plugin of this.plugins) { - if (typeof plugin.getExternalFiles === "function") { - try { - items.push(...plugin.getExternalFiles(this)); - } - catch (e) { - this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); - } + getExternalFiles(): SortedReadonlyArray { + return toSortedReadonlyArray(flatMap(this.plugins, plugin => { + if (typeof plugin.getExternalFiles !== "function") return; + try { + return plugin.getExternalFiles(this); } - } - return items; + catch (e) { + this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); + } + })); } watchConfigFile(callback: (project: ConfiguredProject) => void) { diff --git a/src/server/server.ts b/src/server/server.ts index 390a0f2f6f4..7e1ee683c8c 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -45,6 +45,8 @@ namespace ts.server { os.tmpdir(); return combinePaths(normalizeSlashes(basePath), "Microsoft/TypeScript"); } + case "openbsd": + case "freebsd": case "darwin": case "linux": case "android": { diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 093958b60c5..9e492601430 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -195,6 +195,37 @@ namespace ts.server { return arr; } + export function enumerateInsertsAndDeletes(a: SortedReadonlyArray, b: SortedReadonlyArray, inserted: (item: T) => void, deleted: (item: T) => void, compare?: (a: T, b: T) => Comparison) { + compare = compare || ts.compareValues; + let aIndex = 0; + let bIndex = 0; + const aLen = a.length; + const bLen = b.length; + while (aIndex < aLen && bIndex < bLen) { + const aItem = a[aIndex]; + const bItem = b[bIndex]; + const compareResult = compare(aItem, bItem); + if (compareResult === Comparison.LessThan) { + inserted(aItem); + aIndex++; + } + else if (compareResult === Comparison.GreaterThan) { + deleted(bItem); + bIndex++; + } + else { + aIndex++; + bIndex++; + } + } + while (aIndex < aLen) { + inserted(a[aIndex++]); + } + while (bIndex < bLen) { + deleted(b[bIndex++]); + } + } + export class ThrottledOperations { private pendingTimeouts: Map = createMap(); constructor(private readonly host: ServerHost) { diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 64e7e560094..1587b47c01b 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -8,107 +8,161 @@ namespace ts.codefix { function getActionsForAddMissingMember(context: CodeFixContext): CodeAction[] | undefined { - const sourceFile = context.sourceFile; + const tokenSourceFile = context.sourceFile; const start = context.span.start; - // This is the identifier of the missing property. eg: + // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + const token = getTokenAtPosition(tokenSourceFile, start, /*includeJsDocComment*/ false); if (token.kind !== SyntaxKind.Identifier) { return undefined; } - if (!isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== SyntaxKind.ThisKeyword) { + if (!isPropertyAccessExpression(token.parent)) { return undefined; } - const classMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false); - if (!isClassElement(classMemberDeclaration)) { - return undefined; + const tokenName = token.getText(tokenSourceFile); + + let makeStatic = false; + let classDeclaration: ClassLikeDeclaration; + + if (token.parent.expression.kind === SyntaxKind.ThisKeyword) { + const containingClassMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false); + if (!isClassElement(containingClassMemberDeclaration)) { + return undefined; + } + + classDeclaration = containingClassMemberDeclaration.parent; + + // Property accesses on `this` in a static method are accesses of a static member. + makeStatic = classDeclaration && hasModifier(containingClassMemberDeclaration, ModifierFlags.Static); + } + else { + + const checker = context.program.getTypeChecker(); + const leftExpression = token.parent.expression; + const leftExpressionType = checker.getTypeAtLocation(leftExpression); + + if (leftExpressionType.flags & TypeFlags.Object) { + const symbol = leftExpressionType.symbol; + if (symbol.flags & SymbolFlags.Class) { + classDeclaration = symbol.declarations && symbol.declarations[0]; + if (leftExpressionType !== checker.getDeclaredTypeOfSymbol(symbol)) { + // The expression is a class symbol but the type is not the instance-side. + makeStatic = true; + } + } + } } - const classDeclaration = classMemberDeclaration.parent; if (!classDeclaration || !isClassLike(classDeclaration)) { return undefined; } - const isStatic = hasModifier(classMemberDeclaration, ModifierFlags.Static); + const classDeclarationSourceFile = getSourceFileOfNode(classDeclaration); + const classOpenBrace = getOpenBraceOfClassLike(classDeclaration, classDeclarationSourceFile); - return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + return isInJavaScriptFile(classDeclarationSourceFile) ? + getActionsForAddMissingMemberInJavaScriptFile(classDeclaration, makeStatic) : + getActionsForAddMissingMemberInTypeScriptFile(classDeclaration, makeStatic); - function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined { - const memberName = token.getText(); + function getActionsForAddMissingMemberInJavaScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined { + let actions: CodeAction[]; - if (isStatic) { + const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ false); + if (methodCodeAction) { + actions = [methodCodeAction]; + } + + if (makeStatic) { if (classDeclaration.kind === SyntaxKind.ClassExpression) { - return undefined; + return actions; } const className = classDeclaration.name.getText(); - return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [memberName]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: classDeclaration.getEnd(), length: 0 }, - newText: `${context.newLineCharacter}${className}.${memberName} = undefined;${context.newLineCharacter}` - }] - }] - }]; + const staticInitialization = createStatement(createAssignment( + createPropertyAccess(createIdentifier(className), tokenName), + createIdentifier("undefined"))); + const staticInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + staticInitializationChangeTracker.insertNodeAfter( + classDeclarationSourceFile, + classDeclaration, + staticInitialization, + { suffix: context.newLineCharacter }); + const initializeStaticAction = { + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [tokenName]), + changes: staticInitializationChangeTracker.getChanges() + }; + + (actions || (actions = [])).push(initializeStaticAction); + return actions; } else { const classConstructor = getFirstConstructorWithBody(classDeclaration); if (!classConstructor) { - return undefined; + return actions; } - return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: classConstructor.body.getEnd() - 1, length: 0 }, - newText: `this.${memberName} = undefined;${context.newLineCharacter}` - }] - }] - }]; + const propertyInitialization = createStatement(createAssignment( + createPropertyAccess(createThis(), tokenName), + createIdentifier("undefined"))); + + const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + propertyInitializationChangeTracker.insertNodeAt( + classDeclarationSourceFile, + classConstructor.body.getEnd() - 1, + propertyInitialization, + { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + + const initializeAction = { + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]), + changes: propertyInitializationChangeTracker.getChanges() + }; + + (actions || (actions = [])).push(initializeAction); + return actions; } } - function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined { - let typeNode: TypeNode; + function getActionsForAddMissingMemberInTypeScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined { + let actions: CodeAction[]; - if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { - const binaryExpression = token.parent.parent as BinaryExpression; - - const checker = context.program.getTypeChecker(); - const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ true); + if (methodCodeAction) { + actions = [methodCodeAction]; } + let typeNode: TypeNode; + if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { + const binaryExpression = token.parent.parent as BinaryExpression; + const otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; + const checker = context.program.getTypeChecker(); + const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } typeNode = typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword); - const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); - const property = createProperty( /*decorators*/undefined, - /*modifiers*/ isStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, - token.getText(sourceFile), + /*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, + tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); - const actions = [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + (actions || (actions = [])).push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Declare_property_0), [tokenName]), changes: propertyChangeTracker.getChanges() - }]; + }); - if (!isStatic) { + if (!makeStatic) { + // Index signatures cannot have the static modifier. const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = createParameter( /*decorators*/ undefined, @@ -125,15 +179,32 @@ namespace ts.codefix { typeNode); const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_property_0), [tokenName]), changes: indexSignatureChangeTracker.getChanges() }); } return actions; } + + function getActionForMethodDeclaration(includeTypeScriptSyntax: boolean): CodeAction | undefined { + if (token.parent.parent.kind === SyntaxKind.CallExpression) { + const callExpression = token.parent.parent; + const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); + + const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); + return { + description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? + Diagnostics.Declare_method_0 : + Diagnostics.Declare_static_method_0), + [tokenName]), + changes: methodDeclarationChangeTracker.getChanges() + }; + } + } } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 39d8e13dde9..81aae4c0e5e 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -142,6 +142,50 @@ namespace ts.codefix { } } + export function createMethodFromCallExpression(callExpression: CallExpression, methodName: string, includeTypeScriptSyntax: boolean, makeStatic: boolean): MethodDeclaration { + const parameters = createDummyParameters(callExpression.arguments.length, /*names*/ undefined, /*minArgumentCount*/ undefined, includeTypeScriptSyntax); + + let typeParameters: TypeParameterDeclaration[]; + if (includeTypeScriptSyntax) { + const typeArgCount = length(callExpression.typeArguments); + for (let i = 0; i < typeArgCount; i++) { + const name = typeArgCount < 8 ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`; + const typeParameter = createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined); + (typeParameters ? typeParameters : typeParameters = []).push(typeParameter); + } + } + + const newMethod = createMethod( + /*decorators*/ undefined, + /*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, + /*asteriskToken*/ undefined, + methodName, + /*questionToken*/ undefined, + typeParameters, + parameters, + /*type*/ includeTypeScriptSyntax ? createKeywordTypeNode(SyntaxKind.AnyKeyword) : undefined, + createStubbedMethodBody() + ); + return newMethod; + } + + function createDummyParameters(argCount: number, names: string[] | undefined, minArgumentCount: number | undefined, addAnyType: boolean) { + const parameters: ParameterDeclaration[] = []; + for (let i = 0; i < argCount; i++) { + const newParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + /*name*/ names && names[i] || `arg${i}`, + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, + /*type*/ addAnyType ? createKeywordTypeNode(SyntaxKind.AnyKeyword) : undefined, + /*initializer*/ undefined); + parameters.push(newParameter); + } + + return parameters; + } + function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, @@ -163,19 +207,7 @@ namespace ts.codefix { const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.getName()); - const parameters: ParameterDeclaration[] = []; - for (let i = 0; i < maxNonRestArgs; i++) { - const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); - const newParameter = createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - maxArgsParameterSymbolNames[i], - /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, - anyType, - /*initializer*/ undefined); - parameters.push(newParameter); - } + const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*addAnyType*/ true); if (someSigHasRestParameter) { const anyArrayType = createArrayTypeNode(createKeywordTypeNode(SyntaxKind.AnyKeyword)); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 53ec99fac81..c2d26da4392 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -138,8 +138,23 @@ namespace ts.codefix { const currentTokenMeaning = getMeaningFromLocation(token); if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { - const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); - return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + const umdSymbol = checker.getSymbolAtLocation(token); + let symbol: ts.Symbol; + let symbolName: string; + if (umdSymbol.flags & ts.SymbolFlags.Alias) { + symbol = checker.getAliasedSymbol(umdSymbol); + symbolName = name; + } + else if (isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) { + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), SymbolFlags.Value)); + symbolName = symbol.name; + } + else { + Debug.fail("Either the symbol or the JSX namespace should be a UMD global if we got here"); + } + + return getCodeActionForImport(symbol, symbolName, /*isDefault*/ false, /*isNamespaceImport*/ true); } const candidateModules = checker.getAmbientModules(); @@ -159,7 +174,7 @@ namespace ts.codefix { if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { // check if this symbol is already used const symbolId = getUniqueSymbolId(localSymbol); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true)); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true)); } } @@ -167,7 +182,7 @@ namespace ts.codefix { const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name)); } } @@ -218,7 +233,7 @@ namespace ts.codefix { return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; } - function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] { + function getCodeActionForImport(moduleSymbol: Symbol, symbolName: string, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] { const existingDeclarations = getImportDeclarations(moduleSymbol); if (existingDeclarations.length > 0) { // With an existing import statement, there are more than one actions the user can do. @@ -375,10 +390,10 @@ namespace ts.codefix { const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); const changeTracker = createChangeTracker(); const importClause = isDefault - ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) + ? createImportClause(createIdentifier(symbolName), /*namedBindings*/ undefined) : isNamespaceImport - ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) - : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); + ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(symbolName))) + : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(symbolName))])); const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); if (!lastImportDeclaration) { changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); @@ -392,7 +407,7 @@ namespace ts.codefix { // are there are already a new line seperating code and import statements. return createCodeAction( Diagnostics.Import_0_from_1, - [name, `"${moduleSpecifierWithoutQuotes}"`], + [symbolName, `"${moduleSpecifierWithoutQuotes}"`], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes @@ -412,8 +427,9 @@ namespace ts.codefix { removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule(): string { - if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) { - return moduleSymbol.name; + const decl = moduleSymbol.valueDeclaration; + if (isModuleDeclaration(decl) && isStringLiteral(decl.name)) { + return decl.name.text; } } diff --git a/src/services/completions.ts b/src/services/completions.ts index a895be8a7da..71fe4ce1c78 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -20,6 +20,22 @@ namespace ts.Completions { const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords } = completionData; + if (sourceFile.languageVariant === LanguageVariant.JSX && + location && location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
completion list at "1" will contain "div" with type any + const tagName = (location.parent.parent).openingElement.tagName; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, + entries: [{ + name: (tagName).getFullText(), + kind: ScriptElementKind.classElement, + kindModifiers: undefined, + sortText: "0", + }]}; + } + if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagNameCompletions() }; @@ -38,21 +54,7 @@ namespace ts.Completions { } else { if (!symbols || symbols.length === 0) { - if (sourceFile.languageVariant === LanguageVariant.JSX && - location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
completion list at "1" will contain "div" with type any - const tagName = (location.parent.parent).openingElement.tagName; - entries.push({ - name: (tagName).text, - kind: undefined, - kindModifiers: undefined, - sortText: "0", - }); - } - else if (!hasFilteredClassMemberKeywords) { + if (!hasFilteredClassMemberKeywords) { return undefined; } } @@ -495,7 +497,7 @@ namespace ts.Completions { // It has a left-hand side, so we're not in an opening JSX tag. break; } - // falls through + // falls through case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxElement: @@ -1050,7 +1052,7 @@ namespace ts.Completions { default: if (isFromClassElementDeclaration(contextToken) && (isClassMemberCompletionKeyword(contextToken.kind) || - isClassMemberCompletionKeywordText(contextToken.getText()))) { + isClassMemberCompletionKeywordText(contextToken.getText()))) { return contextToken.parent.parent as ClassLikeDeclaration; } } @@ -1213,7 +1215,7 @@ namespace ts.Completions { if (isFromClassElementDeclaration(contextToken)) { return false; } - // falls through + // falls through case SyntaxKind.ClassKeyword: case SyntaxKind.EnumKeyword: case SyntaxKind.InterfaceKeyword: diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index df499cbd38a..c1a7408fae7 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -185,7 +185,8 @@ namespace ts.FindAllReferences { if (entry.type === "node") { const { node } = entry; return { textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName, ...implementationKindDisplayParts(node, checker) }; - } else { + } + else { const { textSpan, fileName } = entry; return { textSpan, fileName, kind: ScriptElementKind.unknown, displayParts: [] }; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index f20c80c14ef..585af7ebd31 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -530,7 +530,8 @@ namespace ts.FindAllReferences { if (parent.kind === SyntaxKind.VariableDeclaration) { const p = parent as ts.VariableDeclaration; return p.parent.kind === ts.SyntaxKind.CatchClause ? undefined : p.parent.parent.kind === SyntaxKind.VariableStatement ? p.parent.parent : undefined; - } else { + } + else { return parent; } } diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index f601c9604de..5e31d6a0190 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -143,7 +143,7 @@ namespace ts.JsTyping { /** * Merge a given list of typingNames to the inferredTypings map */ - function mergeTypings(typingNames: string[]) { + function mergeTypings(typingNames: ReadonlyArray) { if (!typingNames) { return; } @@ -192,7 +192,7 @@ namespace ts.JsTyping { const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, "")); if (safeList !== EmptySafeList) { - mergeTypings(filter(cleanedTypingNames, f => safeList.has(f))); + mergeTypings(ts.mapDefined(cleanedTypingNames, f => safeList.get(f))); } const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX); diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index 0b6ea3487ec..1058f9c2ca6 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -52,18 +52,8 @@ namespace ts { } export function getRefactorCodeActions(context: RefactorContext, refactorName: string): CodeAction[] | undefined { - - let result: CodeAction[]; const refactor = refactors.get(refactorName); - if (!refactor) { - return undefined; - } - - const codeActions = refactor.getCodeActions(context); - if (codeActions) { - addRange((result || (result = [])), codeActions); - } - return result; + return refactor && refactor.getCodeActions(context); } } } diff --git a/src/services/services.ts b/src/services/services.ts index 05fe59084b4..baba64586e9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -368,7 +368,7 @@ namespace ts { _primaryExpressionBrand: any; _memberExpressionBrand: any; _leftHandSideExpressionBrand: any; - _incrementExpressionBrand: any; + _updateExpressionBrand: any; _unaryExpressionBrand: any; _expressionBrand: any; /*@internal*/typeArguments: NodeArray; @@ -521,6 +521,7 @@ namespace ts { private namedDeclarations: Map; public ambientModuleNames: string[]; public checkJsDirective: CheckJsDirective | undefined; + public possiblyContainDynamicImport: boolean; constructor(kind: SyntaxKind, pos: number, end: number) { super(kind, pos, end); @@ -731,6 +732,15 @@ namespace ts { } } + class SourceMapSourceObject implements SourceMapSource { + lineMap: number[]; + constructor (public fileName: string, public text: string, public skipTrivia?: (pos: number) => number) {} + + public getLineAndCharacterOfPosition(pos: number): LineAndCharacter { + return ts.getLineAndCharacterOfPosition(this, pos); + } + } + function getServicesObjectAllocator(): ObjectAllocator { return { getNodeConstructor: () => NodeObject, @@ -741,6 +751,7 @@ namespace ts { getSymbolConstructor: () => SymbolObject, getTypeConstructor: () => TypeObject, getSignatureConstructor: () => SignatureObject, + getSourceMapSourceConstructor: () => SourceMapSourceObject, }; } diff --git a/src/services/types.ts b/src/services/types.ts index e042276e650..49fe2262605 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -71,6 +71,10 @@ namespace ts { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; } + export interface SourceMapSource { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } + /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return diff --git a/tests/baselines/reference/2dArrays.symbols b/tests/baselines/reference/2dArrays.symbols index 6f02cdcf963..8d6b6b167e6 100644 --- a/tests/baselines/reference/2dArrays.symbols +++ b/tests/baselines/reference/2dArrays.symbols @@ -25,11 +25,11 @@ class Board { >allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 18)) return this.ships.every(function (val) { return val.isSunk; }); ->this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >this.ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) >this : Symbol(Board, Decl(2dArrays.ts, 5, 1)) >ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) >val.isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index 45672187306..00805899294 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -26,12 +26,12 @@ class Board { return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every(function (val) { return val.isSunk; }) : boolean ->this.ships.every : { (callbackfn: (this: void, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: void, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } +>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean >this.ships : Ship[] >this : this >ships : Ship[] ->every : { (callbackfn: (this: void, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: void, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } ->function (val) { return val.isSunk; } : (this: void, val: Ship) => boolean +>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>function (val) { return val.isSunk; } : (val: Ship) => boolean >val : Ship >val.isSunk : boolean >val : Ship diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index b813a44f53e..f4d03f8f62f 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -11,7 +11,7 @@ declare var fs: { existsSync(path: string): boolean; readdirSync(path: string): string[]; readFileSync(filename: string, encoding?: string): string; - writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; } | string): void; watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void; }; declare var path: any; diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js index cb2f7c6cb77..05f14d26369 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js @@ -28,9 +28,9 @@ var Point = (function () { this.x = x; this.y = y; } + Point.Origin = { x: 0, y: 0 }; return Point; }()); -Point.Origin = { x: 0, y: 0 }; (function (Point) { Point.Origin = ""; //expected duplicate identifier error })(Point || (Point = {})); @@ -41,9 +41,9 @@ var A; this.x = x; this.y = y; } + Point.Origin = { x: 0, y: 0 }; return Point; }()); - Point.Origin = { x: 0, y: 0 }; A.Point = Point; (function (Point) { Point.Origin = ""; //expected duplicate identifier error diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js index ef77d6257fb..90c7523b931 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js @@ -28,9 +28,9 @@ var Point = (function () { this.x = x; this.y = y; } + Point.Origin = { x: 0, y: 0 }; return Point; }()); -Point.Origin = { x: 0, y: 0 }; (function (Point) { var Origin = ""; // not an error, since not exported })(Point || (Point = {})); @@ -41,9 +41,9 @@ var A; this.x = x; this.y = y; } + Point.Origin = { x: 0, y: 0 }; return Point; }()); - Point.Origin = { x: 0, y: 0 }; A.Point = Point; (function (Point) { var Origin = ""; // not an error since not exported diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js index 7633955b227..d5c3b3d63f4 100644 --- a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js @@ -7,6 +7,6 @@ class AtomicNumbers { var AtomicNumbers = (function () { function AtomicNumbers() { } + AtomicNumbers.H = 1; return AtomicNumbers; }()); -AtomicNumbers.H = 1; diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js index 651ae7a6d39..40bb07fa9c3 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js @@ -39,9 +39,9 @@ define(["require", "exports"], function (require, exports) { function C1() { this.m1 = 42; } + C1.s1 = true; return C1; }()); - C1.s1 = true; exports.C1 = C1; var E1; (function (E1) { diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols index 750c7ba85af..c1b5df88fb0 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols @@ -35,16 +35,16 @@ paired.reduce((b3, b4) => b3.concat({}), []); >b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15)) paired.map((c1) => c1.count); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) paired.map(function (c2) { return c2.count; }); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.types b/tests/baselines/reference/anyInferenceAnonymousFunctions.types index b015d350760..8dc7fdcb90f 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.types +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.types @@ -57,10 +57,10 @@ paired.reduce((b3, b4) => b3.concat({}), []); paired.map((c1) => c1.count); >paired.map((c1) => c1.count) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>paired.map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } ->(c1) => c1.count : (this: void, c1: any) => any +>map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] +>(c1) => c1.count : (c1: any) => any >c1 : any >c1.count : any >c1 : any @@ -68,10 +68,10 @@ paired.map((c1) => c1.count); paired.map(function (c2) { return c2.count; }); >paired.map(function (c2) { return c2.count; }) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>paired.map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } ->function (c2) { return c2.count; } : (this: void, c2: any) => any +>map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] +>function (c2) { return c2.count; } : (c2: any) => any >c2 : any >c2.count : any >c2 : any diff --git a/tests/baselines/reference/argumentsAsPropertyName.symbols b/tests/baselines/reference/argumentsAsPropertyName.symbols index a17c660374c..1e3e41abb6e 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.symbols +++ b/tests/baselines/reference/argumentsAsPropertyName.symbols @@ -34,8 +34,8 @@ function myFunction(myType: MyType) { >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) [1, 2, 3].forEach(function(j) { use(x); }) ->[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) >j : Symbol(j, Decl(argumentsAsPropertyName.ts, 12, 35)) >use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) diff --git a/tests/baselines/reference/argumentsAsPropertyName.types b/tests/baselines/reference/argumentsAsPropertyName.types index 73397199436..d0aaaa1cc72 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.types +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -42,13 +42,13 @@ function myFunction(myType: MyType) { [1, 2, 3].forEach(function(j) { use(x); }) >[1, 2, 3].forEach(function(j) { use(x); }) : void ->[1, 2, 3].forEach : { (callbackfn: (this: void, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: void, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } +>[1, 2, 3].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->forEach : { (callbackfn: (this: void, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: void, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } ->function(j) { use(x); } : (this: void, j: number) => void +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>function(j) { use(x); } : (j: number) => void >j : number >use(x) : any >use : (s: any) => any diff --git a/tests/baselines/reference/arrayConcatMap.symbols b/tests/baselines/reference/arrayConcatMap.symbols index 1b26708ae94..5ef9d811723 100644 --- a/tests/baselines/reference/arrayConcatMap.symbols +++ b/tests/baselines/reference/arrayConcatMap.symbols @@ -1,14 +1,14 @@ === tests/cases/compiler/arrayConcatMap.ts === var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3)) ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32)) .map(b => b.a); ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) diff --git a/tests/baselines/reference/arrayConcatMap.types b/tests/baselines/reference/arrayConcatMap.types index b234b7beb26..89289e58d4e 100644 --- a/tests/baselines/reference/arrayConcatMap.types +++ b/tests/baselines/reference/arrayConcatMap.types @@ -2,7 +2,7 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : any[] >[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[] ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] >[].concat([{ a: 1 }], [{ a: 2 }]) : any[] >[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; } >[] : undefined[] @@ -17,8 +17,8 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >2 : 2 .map(b => b.a); ->map : { (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: void, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } ->b => b.a : (this: void, b: any) => any +>map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] +>b => b.a : (b: any) => any >b : any >b.a : any >b : any diff --git a/tests/baselines/reference/arrayFilter.symbols b/tests/baselines/reference/arrayFilter.symbols index 81d92ba04b6..cba8f48c89f 100644 --- a/tests/baselines/reference/arrayFilter.symbols +++ b/tests/baselines/reference/arrayFilter.symbols @@ -14,9 +14,9 @@ var foo = [ ] foo.filter(x => x.name); //should accepted all possible types not only boolean! ->foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >foo : Symbol(foo, Decl(arrayFilter.ts, 0, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) >x.name : Symbol(name, Decl(arrayFilter.ts, 1, 5)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 23ab4d915bd..7d91ef4ed32 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,10 +22,10 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } +>foo.filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } >foo : { name: string; }[] ->filter : { (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: void, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } ->x => x.name : (this: void, x: { name: string; }) => string +>filter : { (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => value is S, thisArg?: any): S[]; (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any): { name: string; }[]; } +>x => x.name : (x: { name: string; }) => string >x : { name: string; } >x.name : string >x : { name: string; } diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 90dc909b11a..df24be3a020 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -1,12 +1,12 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. Types of property 'concat' are incompatible. - Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. Type 'A[]' is not assignable to type 'B[]'. Type 'A' is not assignable to type 'B'. Property 'b' is missing in type 'A'. tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. Types of property 'concat' are incompatible. - Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. Type 'A[]' is not assignable to type 'B[]'. @@ -27,7 +27,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T ~~~ !!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. !!! error TS2322: Types of property 'concat' are incompatible. -!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. !!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: Property 'b' is missing in type 'A'. @@ -39,6 +39,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T ~~~ !!! error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. !!! error TS2322: Types of property 'concat' are incompatible. -!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. !!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.errors.txt b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.errors.txt index de2751beaca..0d7fe1071e9 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.errors.txt @@ -1,3 +1,12 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(33,5): error TS2559: Type 'D' has no properties in common with type 'C'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(34,5): error TS2559: Type 'E' has no properties in common with type 'C'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(35,5): error TS2559: Type 'F' has no properties in common with type 'C'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(36,5): error TS2559: Type 'D' has no properties in common with type '{ opt?: Base; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(37,5): error TS2559: Type 'E' has no properties in common with type '{ opt?: Base; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(38,5): error TS2559: Type 'F' has no properties in common with type '{ opt?: Base; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(39,5): error TS2559: Type 'D' has no properties in common with type '{ opt?: Base; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(40,5): error TS2559: Type 'E' has no properties in common with type '{ opt?: Base; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(41,5): error TS2559: Type 'F' has no properties in common with type '{ opt?: Base; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(74,5): error TS2322: Type 'D' is not assignable to type 'C'. Property 'opt' is missing in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(75,5): error TS2322: Type 'E' is not assignable to type 'C'. @@ -18,7 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'opt' is missing in type 'F'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts (9 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts (18 errors) ==== // M is optional and S contains no property with the same name as M // N is optional and T contains no property with the same name as N @@ -50,20 +59,38 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var e: E; var f: F; - // all ok + // disallowed by weak type checking c = d; + ~ +!!! error TS2559: Type 'D' has no properties in common with type 'C'. c = e; + ~ +!!! error TS2559: Type 'E' has no properties in common with type 'C'. c = f; - c = a; - + ~ +!!! error TS2559: Type 'F' has no properties in common with type 'C'. a = d; + ~ +!!! error TS2559: Type 'D' has no properties in common with type '{ opt?: Base; }'. a = e; + ~ +!!! error TS2559: Type 'E' has no properties in common with type '{ opt?: Base; }'. a = f; - a = c; - + ~ +!!! error TS2559: Type 'F' has no properties in common with type '{ opt?: Base; }'. b = d; + ~ +!!! error TS2559: Type 'D' has no properties in common with type '{ opt?: Base; }'. b = e; + ~ +!!! error TS2559: Type 'E' has no properties in common with type '{ opt?: Base; }'. b = f; + ~ +!!! error TS2559: Type 'F' has no properties in common with type '{ opt?: Base; }'. + + // ok + c = a; + a = c; b = a; b = c; } @@ -134,4 +161,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Property 'opt' is missing in type 'F'. b = a; // ok b = c; // ok - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index e158a787878..d83f3182531 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -30,20 +30,20 @@ module TargetHasOptional { var e: E; var f: F; - // all ok + // disallowed by weak type checking c = d; c = e; c = f; - c = a; - a = d; a = e; a = f; - a = c; - b = d; b = e; b = f; + + // ok + c = a; + a = c; b = a; b = c; } @@ -87,7 +87,8 @@ module SourceHasOptional { b = f; // error b = a; // ok b = c; // ok -} +} + //// [assignmentCompatWithObjectMembersOptionality2.js] // M is optional and S contains no property with the same name as M @@ -129,18 +130,19 @@ var TargetHasOptional; var d; var e; var f; - // all ok + // disallowed by weak type checking c = d; c = e; c = f; - c = a; a = d; a = e; a = f; - a = c; b = d; b = e; b = f; + // ok + c = a; + a = c; b = a; b = c; })(TargetHasOptional || (TargetHasOptional = {})); diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 6d91c61d59d..d784798358e 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -42,9 +42,9 @@ var Point = (function () { Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; + Point.origin = new Point(0, 0); return Point; }()); -Point.origin = new Point(0, 0); var Point3D = (function (_super) { __extends(Point3D, _super); function Point3D(x, y, z, m) { diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index dc4ea663efc..c65dba1e7c2 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -2,10 +2,10 @@ // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); ->(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) >match : Symbol(String.match, Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 2, 26)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 2, 26)) @@ -27,9 +27,9 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 9, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 8, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 9, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 9, 18)) @@ -51,9 +51,9 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 15, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 14, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 15, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 15, 18)) diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 15c5ecd4858..49997d1e273 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -3,7 +3,7 @@ (''.match(/ /) || []).map(s => s.toLowerCase()); >(''.match(/ /) || []).map(s => s.toLowerCase()) : string[] ->(''.match(/ /) || []).map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>(''.match(/ /) || []).map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >(''.match(/ /) || []) : RegExpMatchArray >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null @@ -12,8 +12,8 @@ >match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp >[] : never[] ->map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } ->s => s.toLowerCase() : (this: void, s: string) => string +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>s => s.toLowerCase() : (s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -42,10 +42,10 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>y.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } ->s => s.toLowerCase() : (this: void, s: string) => string +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>s => s.toLowerCase() : (s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -74,10 +74,10 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>y.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } ->s => s.toLowerCase() : (this: void, s: string) => string +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>s => s.toLowerCase() : (s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string diff --git a/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js new file mode 100644 index 00000000000..b89943b24ff --- /dev/null +++ b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts] //// + +//// [c.ts] +let foo: typeof C; +//// [b.ts] +class C { } + + +//// [foo.js] +var foo; +var C = (function () { + function C() { + } + return C; +}()); diff --git a/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.symbols b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.symbols new file mode 100644 index 00000000000..c5c6e40da20 --- /dev/null +++ b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/c.ts === +let foo: typeof C; +>foo : Symbol(foo, Decl(c.ts, 0, 3)) +>C : Symbol(C, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +class C { } +>C : Symbol(C, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.types b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.types new file mode 100644 index 00000000000..5bc8862b2aa --- /dev/null +++ b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/c.ts === +let foo: typeof C; +>foo : typeof C +>C : typeof C + +=== tests/cases/compiler/b.ts === +class C { } +>C : C + diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js index 3eab7477c09..82d72e466e1 100644 --- a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js @@ -27,9 +27,9 @@ var C; var Name = (function () { function Name(parameters) { } + Name.funcData = A.AA.func(); + Name.someConst = A.AA.foo; return Name; }()); - Name.funcData = A.AA.func(); - Name.someConst = A.AA.foo; C.Name = Name; })(C || (C = {})); diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index 0197d919fef..619ee51ce75 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -177,9 +177,9 @@ function foo10() { var A = (function () { function A() { } + A.a = x; return A; }()); - A.a = x; var x; } function foo11() { diff --git a/tests/baselines/reference/checkJsdocParamTag1.js b/tests/baselines/reference/checkJsdocParamTag1.js new file mode 100644 index 00000000000..577460626a1 --- /dev/null +++ b/tests/baselines/reference/checkJsdocParamTag1.js @@ -0,0 +1,22 @@ +//// [0.js] +// @ts-check +/** + * @param {number=} n + * @param {string} [s] + */ +function foo(n, s) {} + +foo(); +foo(1); +foo(1, "hi"); + +//// [0.js] +// @ts-check +/** + * @param {number=} n + * @param {string} [s] + */ +function foo(n, s) { } +foo(); +foo(1); +foo(1, "hi"); diff --git a/tests/baselines/reference/checkJsdocParamTag1.symbols b/tests/baselines/reference/checkJsdocParamTag1.symbols new file mode 100644 index 00000000000..d16816f908b --- /dev/null +++ b/tests/baselines/reference/checkJsdocParamTag1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +/** + * @param {number=} n + * @param {string} [s] + */ +function foo(n, s) {} +>foo : Symbol(foo, Decl(0.js, 0, 0)) +>n : Symbol(n, Decl(0.js, 5, 13)) +>s : Symbol(s, Decl(0.js, 5, 15)) + +foo(); +>foo : Symbol(foo, Decl(0.js, 0, 0)) + +foo(1); +>foo : Symbol(foo, Decl(0.js, 0, 0)) + +foo(1, "hi"); +>foo : Symbol(foo, Decl(0.js, 0, 0)) + diff --git a/tests/baselines/reference/checkJsdocParamTag1.types b/tests/baselines/reference/checkJsdocParamTag1.types new file mode 100644 index 00000000000..5b24c3d8887 --- /dev/null +++ b/tests/baselines/reference/checkJsdocParamTag1.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +/** + * @param {number=} n + * @param {string} [s] + */ +function foo(n, s) {} +>foo : (n?: number, s?: string) => void +>n : number +>s : string + +foo(); +>foo() : void +>foo : (n?: number, s?: string) => void + +foo(1); +>foo(1) : void +>foo : (n?: number, s?: string) => void +>1 : 1 + +foo(1, "hi"); +>foo(1, "hi") : void +>foo : (n?: number, s?: string) => void +>1 : 1 +>"hi" : "hi" + diff --git a/tests/baselines/reference/checkJsdocReturnTag1.js b/tests/baselines/reference/checkJsdocReturnTag1.js new file mode 100644 index 00000000000..31c30e54dfc --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag1.js @@ -0,0 +1,43 @@ +//// [returns.js] +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return "hello"; +} + +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { + return "hello world"; +} + +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { + return 5 || "hello"; +} + +//// [dummy.js] +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return "hello"; +} +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { + return "hello world"; +} +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { + return 5 || "hello"; +} diff --git a/tests/baselines/reference/checkJsdocReturnTag1.symbols b/tests/baselines/reference/checkJsdocReturnTag1.symbols new file mode 100644 index 00000000000..ec6376d02ab --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag1.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/returns.js === +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : Symbol(f, Decl(returns.js, 0, 0)) + + return "hello"; +} + +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { +>f1 : Symbol(f1, Decl(returns.js, 6, 1)) + + return "hello world"; +} + +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { +>f2 : Symbol(f2, Decl(returns.js, 13, 1)) + + return 5 || "hello"; +} diff --git a/tests/baselines/reference/checkJsdocReturnTag1.types b/tests/baselines/reference/checkJsdocReturnTag1.types new file mode 100644 index 00000000000..04a2df87c01 --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag1.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/jsdoc/returns.js === +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : () => string + + return "hello"; +>"hello" : "hello" +} + +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { +>f1 : () => string + + return "hello world"; +>"hello world" : "hello world" +} + +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { +>f2 : () => string | number + + return 5 || "hello"; +>5 || "hello" : "hello" | 5 +>5 : 5 +>"hello" : "hello" +} diff --git a/tests/baselines/reference/checkJsdocReturnTag2.js b/tests/baselines/reference/checkJsdocReturnTag2.js new file mode 100644 index 00000000000..4a68e5d85b7 --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag2.js @@ -0,0 +1,30 @@ +//// [returns.js] +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return 5; +} + +/** + * @returns {string | number} This comment is not currently exposed + */ +function f1() { + return 5 || true; +} + +//// [dummy.js] +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return 5; +} +/** + * @returns {string | number} This comment is not currently exposed + */ +function f1() { + return 5 || true; +} diff --git a/tests/baselines/reference/checkJsdocReturnTag2.symbols b/tests/baselines/reference/checkJsdocReturnTag2.symbols new file mode 100644 index 00000000000..43fa1a800e1 --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsdoc/returns.js === +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : Symbol(f, Decl(returns.js, 0, 0)) + + return 5; +} + +/** + * @returns {string | number} This comment is not currently exposed + */ +function f1() { +>f1 : Symbol(f1, Decl(returns.js, 6, 1)) + + return 5 || true; +} diff --git a/tests/baselines/reference/checkJsdocReturnTag2.types b/tests/baselines/reference/checkJsdocReturnTag2.types new file mode 100644 index 00000000000..fe7dca7a364 --- /dev/null +++ b/tests/baselines/reference/checkJsdocReturnTag2.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/jsdoc/returns.js === +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : () => string + + return 5; +>5 : 5 +} + +/** + * @returns {string | number} This comment is not currently exposed + */ +function f1() { +>f1 : () => string | number + + return 5 || true; +>5 || true : true | 5 +>5 : 5 +>true : true +} diff --git a/tests/baselines/reference/jsDocTypes2.js b/tests/baselines/reference/checkJsdocTypeTag1.js similarity index 77% rename from tests/baselines/reference/jsDocTypes2.js rename to tests/baselines/reference/checkJsdocTypeTag1.js index ba59043978c..e4586643c22 100644 --- a/tests/baselines/reference/jsDocTypes2.js +++ b/tests/baselines/reference/checkJsdocTypeTag1.js @@ -1,7 +1,14 @@ //// [0.js] // @ts-check +/** @type {String} */ +var S = "hello world"; + +/** @type {number} */ +var n = 10; + /** @type {*} */ var anyT = 2; +anyT = "hello"; /** @type {?} */ var anyT1 = 2; @@ -25,8 +32,13 @@ x2(0); //// [0.js] // @ts-check +/** @type {String} */ +var S = "hello world"; +/** @type {number} */ +var n = 10; /** @type {*} */ var anyT = 2; +anyT = "hello"; /** @type {?} */ var anyT1 = 2; anyT1 = "hi"; diff --git a/tests/baselines/reference/checkJsdocTypeTag1.symbols b/tests/baselines/reference/checkJsdocTypeTag1.symbols new file mode 100644 index 00000000000..fff51499bc4 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag1.symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +/** @type {String} */ +var S = "hello world"; +>S : Symbol(S, Decl(0.js, 2, 3)) + +/** @type {number} */ +var n = 10; +>n : Symbol(n, Decl(0.js, 5, 3)) + +/** @type {*} */ +var anyT = 2; +>anyT : Symbol(anyT, Decl(0.js, 8, 3)) + +anyT = "hello"; +>anyT : Symbol(anyT, Decl(0.js, 8, 3)) + +/** @type {?} */ +var anyT1 = 2; +>anyT1 : Symbol(anyT1, Decl(0.js, 12, 3)) + +anyT1 = "hi"; +>anyT1 : Symbol(anyT1, Decl(0.js, 12, 3)) + +/** @type {Function} */ +const x = (a) => a + 1; +>x : Symbol(x, Decl(0.js, 16, 5)) +>a : Symbol(a, Decl(0.js, 16, 11)) +>a : Symbol(a, Decl(0.js, 16, 11)) + +x(1); +>x : Symbol(x, Decl(0.js, 16, 5)) + +/** @type {function} */ +const y = (a) => a + 1; +>y : Symbol(y, Decl(0.js, 20, 5)) +>a : Symbol(a, Decl(0.js, 20, 11)) +>a : Symbol(a, Decl(0.js, 20, 11)) + +x(1); +>x : Symbol(x, Decl(0.js, 16, 5)) + +/** @type {function (number)} */ +const x1 = (a) => a + 1; +>x1 : Symbol(x1, Decl(0.js, 24, 5)) +>a : Symbol(a, Decl(0.js, 24, 12)) +>a : Symbol(a, Decl(0.js, 24, 12)) + +x1(0); +>x1 : Symbol(x1, Decl(0.js, 24, 5)) + +/** @type {function (number): number} */ +const x2 = (a) => a + 1; +>x2 : Symbol(x2, Decl(0.js, 28, 5)) +>a : Symbol(a, Decl(0.js, 28, 12)) +>a : Symbol(a, Decl(0.js, 28, 12)) + +x2(0); +>x2 : Symbol(x2, Decl(0.js, 28, 5)) + diff --git a/tests/baselines/reference/jsDocTypes2.types b/tests/baselines/reference/checkJsdocTypeTag1.types similarity index 73% rename from tests/baselines/reference/jsDocTypes2.types rename to tests/baselines/reference/checkJsdocTypeTag1.types index 599c19c7ffc..9368640edcb 100644 --- a/tests/baselines/reference/jsDocTypes2.types +++ b/tests/baselines/reference/checkJsdocTypeTag1.types @@ -1,10 +1,25 @@ -=== tests/cases/conformance/salsa/0.js === +=== tests/cases/conformance/jsdoc/0.js === // @ts-check +/** @type {String} */ +var S = "hello world"; +>S : string +>"hello world" : "hello world" + +/** @type {number} */ +var n = 10; +>n : number +>10 : 10 + /** @type {*} */ var anyT = 2; >anyT : any >2 : 2 +anyT = "hello"; +>anyT = "hello" : "hello" +>anyT : any +>"hello" : "hello" + /** @type {?} */ var anyT1 = 2; >anyT1 : any diff --git a/tests/baselines/reference/checkJsdocTypeTag2.errors.txt b/tests/baselines/reference/checkJsdocTypeTag2.errors.txt new file mode 100644 index 00000000000..ca02c578a36 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag2.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/jsdoc/0.js(3,5): error TS2322: Type 'true' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/0.js(6,5): error TS2322: Type '"hello"' is not assignable to type 'number'. +tests/cases/conformance/jsdoc/0.js(10,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. +tests/cases/conformance/jsdoc/0.js(13,7): error TS2451: Cannot redeclare block-scoped variable 'x2'. +tests/cases/conformance/jsdoc/0.js(17,1): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/0.js(20,7): error TS2451: Cannot redeclare block-scoped variable 'x2'. + + +==== tests/cases/conformance/jsdoc/0.js (6 errors) ==== + // @ts-check + /** @type {String} */ + var S = true; + ~ +!!! error TS2322: Type 'true' is not assignable to type 'string'. + + /** @type {number} */ + var n = "hello"; + ~ +!!! error TS2322: Type '"hello"' is not assignable to type 'number'. + + /** @type {function (number)} */ + const x1 = (a) => a + 1; + x1("string"); + ~~~~~~~~ +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. + + /** @type {function (number): number} */ + const x2 = (a) => a + 1; + ~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'x2'. + + /** @type {string} */ + var a; + a = x2(0); + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + /** @type {function (number): number} */ + const x2 = (a) => a.concat("hi"); + ~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'x2'. + x2(0); \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypeTag2.js b/tests/baselines/reference/checkJsdocTypeTag2.js new file mode 100644 index 00000000000..23b436e2031 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag2.js @@ -0,0 +1,40 @@ +//// [0.js] +// @ts-check +/** @type {String} */ +var S = true; + +/** @type {number} */ +var n = "hello"; + +/** @type {function (number)} */ +const x1 = (a) => a + 1; +x1("string"); + +/** @type {function (number): number} */ +const x2 = (a) => a + 1; + +/** @type {string} */ +var a; +a = x2(0); + +/** @type {function (number): number} */ +const x2 = (a) => a.concat("hi"); +x2(0); + +//// [0.js] +// @ts-check +/** @type {String} */ +var S = true; +/** @type {number} */ +var n = "hello"; +/** @type {function (number)} */ +var x1 = function (a) { return a + 1; }; +x1("string"); +/** @type {function (number): number} */ +var x2 = function (a) { return a + 1; }; +/** @type {string} */ +var a; +a = x2(0); +/** @type {function (number): number} */ +var x2 = function (a) { return a.concat("hi"); }; +x2(0); diff --git a/tests/baselines/reference/jsDocTypes3.errors.txt b/tests/baselines/reference/checkJsdocTypeTag3.errors.txt similarity index 72% rename from tests/baselines/reference/jsDocTypes3.errors.txt rename to tests/baselines/reference/checkJsdocTypeTag3.errors.txt index 5f5feeaf0a7..d53c0972fa3 100644 --- a/tests/baselines/reference/jsDocTypes3.errors.txt +++ b/tests/baselines/reference/checkJsdocTypeTag3.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/salsa/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. -tests/cases/conformance/salsa/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. +tests/cases/conformance/jsdoc/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/salsa/0.js (2 errors) ==== +==== tests/cases/conformance/jsdoc/0.js (2 errors) ==== // @ts-check /** @type {function (number)} */ diff --git a/tests/baselines/reference/jsDocTypes3.js b/tests/baselines/reference/checkJsdocTypeTag3.js similarity index 100% rename from tests/baselines/reference/jsDocTypes3.js rename to tests/baselines/reference/checkJsdocTypeTag3.js diff --git a/tests/baselines/reference/checkJsxChildrenProperty1.symbols b/tests/baselines/reference/checkJsxChildrenProperty1.symbols index 8793d0edd49..ede60746f4b 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty1.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty1.symbols @@ -13,8 +13,8 @@ interface Prop { children: string | JSX.Element >children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) } function Comp(p: Prop) { @@ -23,11 +23,11 @@ function Comp(p: Prop) { >Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) return
{p.b}
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) >p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) >p : Symbol(p, Decl(file.tsx, 8, 14)) >b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } // OK @@ -59,8 +59,8 @@ let k2 = >b : Symbol(b, Decl(file.tsx, 19, 16))
hi hi hi!
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) ; >Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.symbols b/tests/baselines/reference/checkJsxChildrenProperty12.symbols index ccfb4b18875..09080234ea9 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty12.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty12.symbols @@ -18,9 +18,9 @@ interface ButtonProp { class Button extends React.Component { >Button : Symbol(Button, Decl(file.tsx, 6, 1)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32)) render() { @@ -34,20 +34,20 @@ class Button extends React.Component { return >InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) ->this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) >this : Symbol(Button, Decl(file.tsx, 6, 1)) ->props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) } else { return ( >InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) ->this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) >this : Symbol(Button, Decl(file.tsx, 6, 1)) ->props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37))
Hello World
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
); >InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) @@ -64,17 +64,17 @@ interface InnerButtonProp { class InnerButton extends React.Component { >InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1)) render() { >render : Symbol(InnerButton.render, Decl(file.tsx, 26, 65)) return (); ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) } } diff --git a/tests/baselines/reference/checkJsxChildrenProperty3.symbols b/tests/baselines/reference/checkJsxChildrenProperty3.symbols index 49d146f07da..ea1beff75ac 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty3.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty3.symbols @@ -16,34 +16,34 @@ interface IFetchUserProps { >children : Symbol(IFetchUserProps.children, Decl(file.tsx, 6, 27)) >user : Symbol(user, Decl(file.tsx, 7, 15)) >IUser : Symbol(IUser, Decl(file.tsx, 0, 32)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) } class FetchUser extends React.Component { >FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >IFetchUserProps : Symbol(IFetchUserProps, Decl(file.tsx, 4, 1)) render() { >render : Symbol(FetchUser.render, Decl(file.tsx, 10, 63)) return this.state ->this.state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44)) +>this.state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) >this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) ->state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44)) +>state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) ? this.props.children(this.state.result) ->this.props.children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 173, 20)) ->this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>this.props.children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 174, 20)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) >this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) ->props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) ->children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 173, 20)) ->this.state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) +>children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 174, 20)) +>this.state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) >this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) ->state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44)) +>state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) : null; } @@ -61,11 +61,11 @@ function UserName0() { >user : Symbol(user, Decl(file.tsx, 22, 13))

{ user.Name }

->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) >user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) >user : Symbol(user, Decl(file.tsx, 22, 13)) >Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) ) } @@ -85,11 +85,11 @@ function UserName1() { >user : Symbol(user, Decl(file.tsx, 33, 13))

{ user.Name }

->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) >user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) >user : Symbol(user, Decl(file.tsx, 33, 13)) >Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) ) } diff --git a/tests/baselines/reference/checkJsxChildrenProperty6.symbols b/tests/baselines/reference/checkJsxChildrenProperty6.symbols index e69b24a89ab..3fc70d41883 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty6.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty6.symbols @@ -13,24 +13,24 @@ interface Prop { children: JSX.Element | JSX.Element[]; >children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) } class Button extends React.Component { >Button : Symbol(Button, Decl(file.tsx, 6, 1)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) render() { >render : Symbol(Button.render, Decl(file.tsx, 8, 48)) return (
My Button
) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } @@ -39,8 +39,8 @@ function AnotherButton(p: any) { >p : Symbol(p, Decl(file.tsx, 14, 23)) return

Just Another Button

; ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) } function Comp(p: Prop) { @@ -49,11 +49,11 @@ function Comp(p: Prop) { >Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) return
{p.b}
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) >p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) >p : Symbol(p, Decl(file.tsx, 18, 14)) >b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } // Ok diff --git a/tests/baselines/reference/checkJsxChildrenProperty8.symbols b/tests/baselines/reference/checkJsxChildrenProperty8.symbols index b6f5f97adac..3d2e232203b 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty8.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty8.symbols @@ -13,24 +13,24 @@ interface Prop { children: string | JSX.Element | (string | JSX.Element)[]; >children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) ->JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) ->Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) } class Button extends React.Component { >Button : Symbol(Button, Decl(file.tsx, 6, 1)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) render() { >render : Symbol(Button.render, Decl(file.tsx, 8, 48)) return (
My Button
) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } } @@ -39,8 +39,8 @@ function AnotherButton(p: any) { >p : Symbol(p, Decl(file.tsx, 14, 23)) return

Just Another Button

; ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) } function Comp(p: Prop) { @@ -49,11 +49,11 @@ function Comp(p: Prop) { >Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) return
{p.b}
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) >p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) >p : Symbol(p, Decl(file.tsx, 18, 14)) >b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) } // OK diff --git a/tests/baselines/reference/checkJsxChildrenProperty9.symbols b/tests/baselines/reference/checkJsxChildrenProperty9.symbols index 25a32aae695..147fc4939f5 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty9.symbols +++ b/tests/baselines/reference/checkJsxChildrenProperty9.symbols @@ -5,26 +5,26 @@ import React = require('react'); // OK let k1 =

Hello

world

; >k1 : Symbol(k1, Decl(file.tsx, 3, 3)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) ->h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2409, 47)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) let k2 =

Hello

{(user: any) =>

{user.name}

}
; >k2 : Symbol(k2, Decl(file.tsx, 4, 3)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) >user : Symbol(user, Decl(file.tsx, 4, 34)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) >user : Symbol(user, Decl(file.tsx, 4, 34)) ->h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2410, 48)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2411, 48)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) let k3 =
{1} {"That is a number"}
; >k3 : Symbol(k3, Decl(file.tsx, 5, 3)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols index 33f8f88f9e0..2a6ba238b4b 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols @@ -12,9 +12,9 @@ class A { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) x.forEach((v) => { ->x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19)) switch(v) { diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types index 115930df20a..30f584894fc 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types @@ -13,10 +13,10 @@ class A { x.forEach((v) => { >x.forEach((v) => { switch(v) { case "test": use(this); } }) : void ->x.forEach : { (callbackfn: (this: void, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: void, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>x.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void >x : string[] ->forEach : { (callbackfn: (this: void, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: void, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } ->(v) => { switch(v) { case "test": use(this); } } : (this: void, v: string) => void +>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>(v) => { switch(v) { case "test": use(this); } } : (v: string) => void >v : string switch(v) { diff --git a/tests/baselines/reference/class2.js b/tests/baselines/reference/class2.js index 91ac89da109..6ef78ed46ee 100644 --- a/tests/baselines/reference/class2.js +++ b/tests/baselines/reference/class2.js @@ -5,6 +5,6 @@ class foo { constructor() { static f = 3; } } var foo = (function () { function foo() { } + foo.f = 3; return foo; }()); -foo.f = 3; diff --git a/tests/baselines/reference/classBlockScoping.js b/tests/baselines/reference/classBlockScoping.js index 76d0dd892de..3cae2d3cb7d 100644 --- a/tests/baselines/reference/classBlockScoping.js +++ b/tests/baselines/reference/classBlockScoping.js @@ -62,9 +62,9 @@ function f(b) { Foo.prototype.m = function () { new Foo(); }; + Foo.y = new Foo(); return Foo; }()); - Foo_1.y = new Foo_1(); new Foo_1(); } var _a; diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index 9b52891b559..e051e05251b 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -12,10 +12,10 @@ var v = ; var C = (function () { function C() { } + C.p = 1; + C = __decorate([ + decorate + ], C); return C; }()); -C.p = 1; -C = __decorate([ - decorate -], C); ; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols index cd7cbdba7bd..2cf04ac05d3 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols @@ -30,9 +30,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 1, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 8, 12)) >console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 0, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 1, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.types b/tests/baselines/reference/classExpressionWithStaticProperties3.types index 6f598e6e42e..67823ea8340 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.types @@ -41,10 +41,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : { (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void >arr : { y(): number; }[] ->forEach : { (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } ->C => console.log(C.y()) : (this: void, C: { y(): number; }) => any +>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>C => console.log(C.y()) : (C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols index 822dfaf81a0..d39463b228c 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols @@ -30,9 +30,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 8, 12)) >console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 0, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types index b5cd81e8590..5a948f54402 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types @@ -41,10 +41,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : { (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void >arr : { y(): number; }[] ->forEach : { (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: void, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } ->C => console.log(C.y()) : (this: void, C: { y(): number; }) => any +>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>C => console.log(C.y()) : (C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/classMemberInitializerScoping.js b/tests/baselines/reference/classMemberInitializerScoping.js index 52bbaee8945..8f78cfb9ac6 100644 --- a/tests/baselines/reference/classMemberInitializerScoping.js +++ b/tests/baselines/reference/classMemberInitializerScoping.js @@ -27,9 +27,9 @@ var CCC = (function () { this.y = aaa; this.y = ''; // was: error, cannot assign string to number } + CCC.staticY = aaa; // This shouldnt be error return CCC; }()); -CCC.staticY = aaa; // This shouldnt be error // above is equivalent to this: var aaaa = 1; var CCCC = (function () { diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js index c5b661831a2..752220a4cbc 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js @@ -40,12 +40,12 @@ var Test = (function () { console.log(field); // Using field here shouldnt be error }; } + Test.staticMessageHandler = function () { + var field = Test.field; + console.log(field); // Using field here shouldnt be error + }; return Test; }()); -Test.staticMessageHandler = function () { - var field = Test.field; - console.log(field); // Using field here shouldnt be error -}; var field1; var Test1 = (function () { function Test1(field1) { @@ -56,8 +56,8 @@ var Test1 = (function () { // it would resolve to private field1 and thats not what user intended here. }; } + Test1.staticMessageHandler = function () { + console.log(field1); // This shouldnt be error as its a static property + }; return Test1; }()); -Test1.staticMessageHandler = function () { - console.log(field1); // This shouldnt be error as its a static property -}; diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt index b304d197ada..65ae28303db 100644 --- a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt +++ b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplica tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'. -tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2711: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2713: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. ==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ==== @@ -26,6 +26,6 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2711: Subseq ~ !!! error TS2300: Duplicate identifier 'c'. ~ -!!! error TS2711: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. +!!! error TS2713: Subsequent property declarations must have the same type. Property 'c' must be of type 'number', but here has type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/classWithPrivateProperty.js b/tests/baselines/reference/classWithPrivateProperty.js index c94f1d8ed80..6e75797523f 100644 --- a/tests/baselines/reference/classWithPrivateProperty.js +++ b/tests/baselines/reference/classWithPrivateProperty.js @@ -32,9 +32,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; + C.g = function () { return ''; }; return C; }()); -C.g = function () { return ''; }; var c = new C(); var r1 = c.x; var r2 = c.a; diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 2b12741d38f..2bc766cd99a 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -47,9 +47,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; + C.g = function () { return ''; }; return C; }()); -C.g = function () { return ''; }; var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/classWithPublicProperty.js b/tests/baselines/reference/classWithPublicProperty.js index 47708b7aff3..054713264bd 100644 --- a/tests/baselines/reference/classWithPublicProperty.js +++ b/tests/baselines/reference/classWithPublicProperty.js @@ -30,9 +30,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; + C.g = function () { return ''; }; return C; }()); -C.g = function () { return ''; }; // all of these are valid var c = new C(); var r1 = c.x; diff --git a/tests/baselines/reference/cloduleStaticMembers.js b/tests/baselines/reference/cloduleStaticMembers.js index b696a842f3b..d17a2b2497d 100644 --- a/tests/baselines/reference/cloduleStaticMembers.js +++ b/tests/baselines/reference/cloduleStaticMembers.js @@ -16,10 +16,10 @@ module Clod { var Clod = (function () { function Clod() { } + Clod.x = 10; + Clod.y = 10; return Clod; }()); -Clod.x = 10; -Clod.y = 10; (function (Clod) { var p = Clod.x; var q = x; diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols index cb124f21f15..c5734cbbc9b 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols @@ -4,8 +4,8 @@ function f (m: string) { >m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) [1, 2, 3].map(i => { ->[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.types b/tests/baselines/reference/commaOperatorInConditionalExpression.types index 7ee2ab72c77..1d1037c1206 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.types +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.types @@ -5,13 +5,13 @@ function f (m: string) { [1, 2, 3].map(i => { >[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[] ->[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>[1, 2, 3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } ->i => { return true? { [m]: i } : { [m]: i + 1 } } : (this: void, i: number) => { [x: string]: number; } +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; } >i : number return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commentEmittingInPreserveJsx1.symbols b/tests/baselines/reference/commentEmittingInPreserveJsx1.symbols index 43d833e27b1..9accc8af0b6 100644 --- a/tests/baselines/reference/commentEmittingInPreserveJsx1.symbols +++ b/tests/baselines/reference/commentEmittingInPreserveJsx1.symbols @@ -3,14 +3,14 @@ import React = require('react'); >React : Symbol(React, Decl(file.tsx, 0, 0))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) // Not Comment
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) // Not Comment { @@ -18,10 +18,10 @@ import React = require('react'); } // Another not Comment
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) // Not Comment { @@ -30,10 +30,10 @@ import React = require('react'); } // Another not Comment
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) /* Not Comment */ { @@ -41,5 +41,5 @@ import React = require('react'); "Hi" }
; ->div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) diff --git a/tests/baselines/reference/commentInMethodCall.symbols b/tests/baselines/reference/commentInMethodCall.symbols index e082d24daf3..9db0719cf89 100644 --- a/tests/baselines/reference/commentInMethodCall.symbols +++ b/tests/baselines/reference/commentInMethodCall.symbols @@ -4,9 +4,9 @@ var s: string[]; >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) s.map(// do something ->s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>s.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) function () { }); diff --git a/tests/baselines/reference/commentInMethodCall.types b/tests/baselines/reference/commentInMethodCall.types index b74323d1477..e9543a8c6f2 100644 --- a/tests/baselines/reference/commentInMethodCall.types +++ b/tests/baselines/reference/commentInMethodCall.types @@ -5,10 +5,10 @@ var s: string[]; s.map(// do something >s.map(// do something function () { }) : void[] ->s.map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >s : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] function () { }); ->function () { } : (this: void) => void +>function () { } : () => void diff --git a/tests/baselines/reference/commentOnDecoratedClassDeclaration.js b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js index 44a7047a2ac..8e6cd7149cf 100644 --- a/tests/baselines/reference/commentOnDecoratedClassDeclaration.js +++ b/tests/baselines/reference/commentOnDecoratedClassDeclaration.js @@ -29,19 +29,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var Remote = (function () { function Remote() { } + Remote = __decorate([ + decorator("hello") + ], Remote); return Remote; }()); -Remote = __decorate([ - decorator("hello") -], Remote); /** * Floating Comment */ var AnotherRomote = (function () { function AnotherRomote() { } + AnotherRomote = __decorate([ + decorator("hi") + ], AnotherRomote); return AnotherRomote; }()); -AnotherRomote = __decorate([ - decorator("hi") -], AnotherRomote); diff --git a/tests/baselines/reference/commentsOnStaticMembers.js b/tests/baselines/reference/commentsOnStaticMembers.js index 94df4089880..896aced36e4 100644 --- a/tests/baselines/reference/commentsOnStaticMembers.js +++ b/tests/baselines/reference/commentsOnStaticMembers.js @@ -23,13 +23,13 @@ class test { var test = (function () { function test() { } + /** + * p1 comment appears in output + */ + test.p1 = ""; + /** + * p3 comment appears in output + */ + test.p3 = ""; return test; }()); -/** - * p1 comment appears in output - */ -test.p1 = ""; -/** - * p3 comment appears in output - */ -test.p3 = ""; diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index cd62c1583bc..d25c1410897 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -20,9 +20,9 @@ var C1 = (function () { function C1() { this.m1 = 42; } + C1.s1 = true; return C1; }()); -C1.s1 = true; exports.C1 = C1; //// [foo_1.js] "use strict"; diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js index 5ac0e3fcc64..7aee50e1106 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js @@ -38,9 +38,9 @@ var C1 = (function () { function C1() { this.m1 = 42; } + C1.s1 = true; return C1; }()); -C1.s1 = true; exports.C1 = C1; var E1; (function (E1) { diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.js b/tests/baselines/reference/computedPropertyNames12_ES5.js index 10427b5dc13..2aec8856286 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.js +++ b/tests/baselines/reference/computedPropertyNames12_ES5.js @@ -26,6 +26,6 @@ var C = (function () { this[s + n] = 2; this["hello bye"] = 0; } + C["hello " + a + " bye"] = 0; return C; }()); -C["hello " + a + " bye"] = 0; diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.js b/tests/baselines/reference/constructableDecoratorOnClass01.js index 858d67923af..a37f96b59d1 100644 --- a/tests/baselines/reference/constructableDecoratorOnClass01.js +++ b/tests/baselines/reference/constructableDecoratorOnClass01.js @@ -22,8 +22,8 @@ var CtorDtor = (function () { var C = (function () { function C() { } + C = __decorate([ + CtorDtor + ], C); return C; }()); -C = __decorate([ - CtorDtor -], C); diff --git a/tests/baselines/reference/constructorFunctions.symbols b/tests/baselines/reference/constructorFunctions.symbols new file mode 100644 index 00000000000..f55075794ab --- /dev/null +++ b/tests/baselines/reference/constructorFunctions.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/salsa/index.js === +function C1() { +>C1 : Symbol(C1, Decl(index.js, 0, 0)) + + if (!(this instanceof C1)) return new C1(); +>C1 : Symbol(C1, Decl(index.js, 0, 0)) +>C1 : Symbol(C1, Decl(index.js, 0, 0)) + + this.x = 1; +>x : Symbol(C1.x, Decl(index.js, 1, 47)) +} + +const c1_v1 = C1(); +>c1_v1 : Symbol(c1_v1, Decl(index.js, 5, 5)) +>C1 : Symbol(C1, Decl(index.js, 0, 0)) + +const c1_v2 = new C1(); +>c1_v2 : Symbol(c1_v2, Decl(index.js, 6, 5)) +>C1 : Symbol(C1, Decl(index.js, 0, 0)) + +var C2 = function () { +>C2 : Symbol(C2, Decl(index.js, 8, 3)) + + if (!(this instanceof C2)) return new C2(); +>C2 : Symbol(C2, Decl(index.js, 8, 3)) +>C2 : Symbol(C2, Decl(index.js, 8, 3)) + + this.x = 1; +>x : Symbol(C2.x, Decl(index.js, 9, 47)) + +}; + +const c2_v1 = C2(); +>c2_v1 : Symbol(c2_v1, Decl(index.js, 13, 5)) +>C2 : Symbol(C2, Decl(index.js, 8, 3)) + +const c2_v2 = new C2(); +>c2_v2 : Symbol(c2_v2, Decl(index.js, 14, 5)) +>C2 : Symbol(C2, Decl(index.js, 8, 3)) + +/** @class */ +function C3() { +>C3 : Symbol(C3, Decl(index.js, 14, 23)) + + if (!(this instanceof C3)) return new C3(); +>C3 : Symbol(C3, Decl(index.js, 14, 23)) +>C3 : Symbol(C3, Decl(index.js, 14, 23)) + +}; + +const c3_v1 = C3(); +>c3_v1 : Symbol(c3_v1, Decl(index.js, 21, 5)) +>C3 : Symbol(C3, Decl(index.js, 14, 23)) + +const c3_v2 = new C3(); +>c3_v2 : Symbol(c3_v2, Decl(index.js, 22, 5)) +>C3 : Symbol(C3, Decl(index.js, 14, 23)) + +/** @class */ +var C4 = function () { +>C4 : Symbol(C4, Decl(index.js, 25, 3)) + + if (!(this instanceof C4)) return new C4(); +>C4 : Symbol(C4, Decl(index.js, 25, 3)) +>C4 : Symbol(C4, Decl(index.js, 25, 3)) + +}; + +const c4_v1 = C4(); +>c4_v1 : Symbol(c4_v1, Decl(index.js, 29, 5)) +>C4 : Symbol(C4, Decl(index.js, 25, 3)) + +const c4_v2 = new C4(); +>c4_v2 : Symbol(c4_v2, Decl(index.js, 30, 5)) +>C4 : Symbol(C4, Decl(index.js, 25, 3)) + diff --git a/tests/baselines/reference/constructorFunctions.types b/tests/baselines/reference/constructorFunctions.types new file mode 100644 index 00000000000..3429758b017 --- /dev/null +++ b/tests/baselines/reference/constructorFunctions.types @@ -0,0 +1,114 @@ +=== tests/cases/conformance/salsa/index.js === +function C1() { +>C1 : () => typeof C1 + + if (!(this instanceof C1)) return new C1(); +>!(this instanceof C1) : boolean +>(this instanceof C1) : boolean +>this instanceof C1 : boolean +>this : any +>C1 : () => typeof C1 +>new C1() : { x: number; } +>C1 : () => typeof C1 + + this.x = 1; +>this.x = 1 : 1 +>this.x : any +>this : any +>x : any +>1 : 1 +} + +const c1_v1 = C1(); +>c1_v1 : { x: number; } +>C1() : { x: number; } +>C1 : () => typeof C1 + +const c1_v2 = new C1(); +>c1_v2 : { x: number; } +>new C1() : { x: number; } +>C1 : () => typeof C1 + +var C2 = function () { +>C2 : () => any +>function () { if (!(this instanceof C2)) return new C2(); this.x = 1;} : () => any + + if (!(this instanceof C2)) return new C2(); +>!(this instanceof C2) : boolean +>(this instanceof C2) : boolean +>this instanceof C2 : boolean +>this : any +>C2 : () => any +>new C2() : { x: number; } +>C2 : () => any + + this.x = 1; +>this.x = 1 : 1 +>this.x : any +>this : any +>x : any +>1 : 1 + +}; + +const c2_v1 = C2(); +>c2_v1 : { x: number; } +>C2() : { x: number; } +>C2 : () => any + +const c2_v2 = new C2(); +>c2_v2 : { x: number; } +>new C2() : { x: number; } +>C2 : () => any + +/** @class */ +function C3() { +>C3 : () => typeof C3 + + if (!(this instanceof C3)) return new C3(); +>!(this instanceof C3) : boolean +>(this instanceof C3) : boolean +>this instanceof C3 : boolean +>this : any +>C3 : () => typeof C3 +>new C3() : {} +>C3 : () => typeof C3 + +}; + +const c3_v1 = C3(); +>c3_v1 : {} +>C3() : {} +>C3 : () => typeof C3 + +const c3_v2 = new C3(); +>c3_v2 : {} +>new C3() : {} +>C3 : () => typeof C3 + +/** @class */ +var C4 = function () { +>C4 : () => any +>function () { if (!(this instanceof C4)) return new C4();} : () => any + + if (!(this instanceof C4)) return new C4(); +>!(this instanceof C4) : boolean +>(this instanceof C4) : boolean +>this instanceof C4 : boolean +>this : any +>C4 : () => any +>new C4() : {} +>C4 : () => any + +}; + +const c4_v1 = C4(); +>c4_v1 : {} +>C4() : {} +>C4 : () => any + +const c4_v2 = new C4(); +>c4_v2 : {} +>new C4() : {} +>C4 : () => any + diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.symbols b/tests/baselines/reference/contextualSignatureInstantiation3.symbols index a9653673ff2..6d480a7aef4 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation3.symbols @@ -12,9 +12,9 @@ function map(items: T[], f: (x: T) => U): U[]{ >U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15)) return items.map(f); ->items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>items.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30)) } @@ -47,9 +47,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1)) var v1 = map(xs, identity); // Error if not number[] @@ -63,9 +63,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1)) var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.types b/tests/baselines/reference/contextualSignatureInstantiation3.types index 60ad7c31bf6..945a4374ad1 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.types +++ b/tests/baselines/reference/contextualSignatureInstantiation3.types @@ -13,9 +13,9 @@ function map(items: T[], f: (x: T) => U): U[]{ return items.map(f); >items.map(f) : U[] ->items.map : { (this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } +>items.map : (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[] >items : T[] ->map : { (this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } +>map : (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[] >f : (x: T) => U } @@ -54,9 +54,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : number[] >xs.map(identity) : number[] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>xs.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >identity : (x: T) => T var v1 = map(xs, identity); // Error if not number[] @@ -72,9 +72,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : number[][] >xs.map(singleton) : number[][] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>xs.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >singleton : (x: T) => T[] var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextualTypingWithGenericSignature.types b/tests/baselines/reference/contextualTypingWithGenericSignature.types index 68c5f3c422d..e662f2c4192 100644 --- a/tests/baselines/reference/contextualTypingWithGenericSignature.types +++ b/tests/baselines/reference/contextualTypingWithGenericSignature.types @@ -16,10 +16,10 @@ var f2: { }; f2 = (x, y) => { return x } ->f2 = (x, y) => { return x } : (x: any, y: any) => any +>f2 = (x, y) => { return x } : (x: T, y: U) => T >f2 : (x: T, y: U) => T ->(x, y) => { return x } : (x: any, y: any) => any ->x : any ->y : any ->x : any +>(x, y) => { return x } : (x: T, y: U) => T +>x : T +>y : U +>x : T diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 96e57c1f62f..b6a73764352 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -47,25 +47,25 @@ // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) ((...noNumbers) => noNumbers.some(n => n > 0))(); >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) @@ -73,9 +73,9 @@ >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) ->rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 77bb40df903..7b86fe1f337 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -105,10 +105,10 @@ >(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean >numbers : number[] >numbers.every(n => n > 0) : boolean ->numbers.every : { (callbackfn: (this: void, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: void, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >numbers : number[] ->every : { (callbackfn: (this: void, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: void, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } ->n => n > 0 : (this: void, n: number) => boolean +>every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean >n : number @@ -123,10 +123,10 @@ >(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean >mixed : (string | number)[] >mixed.every(n => !!n) : boolean ->mixed.every : { (callbackfn: (this: void, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: void, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } +>mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean >mixed : (string | number)[] ->every : { (callbackfn: (this: void, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: void, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } ->n => !!n : (this: void, n: string | number) => boolean +>every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>n => !!n : (n: string | number) => boolean >n : string | number >!!n : boolean >!n : boolean @@ -141,10 +141,10 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean >noNumbers : any[] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : { (callbackfn: (this: void, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: void, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } +>noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean >noNumbers : any[] ->some : { (callbackfn: (this: void, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: void, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } ->n => n > 0 : (this: void, n: any) => boolean +>some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: any) => boolean >n : any >n > 0 : boolean >n : any @@ -160,10 +160,10 @@ >first : number >[] : undefined[] >rest.map(n => n > 0) : boolean[] ->rest.map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >rest : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } ->n => n > 0 : (this: void, n: number) => boolean +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>n => n > 0 : (n: number) => boolean >n : number >n > 0 : boolean >n : number diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.symbols b/tests/baselines/reference/controlFlowDestructuringParameters.symbols index 1874c16c3d3..668d346b929 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.symbols +++ b/tests/baselines/reference/controlFlowDestructuringParameters.symbols @@ -3,9 +3,9 @@ [{ x: 1 }].map( ->[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 3, 2)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) ({ x }) => x >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4)) diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.types b/tests/baselines/reference/controlFlowDestructuringParameters.types index 44755dca81b..9c6c96de540 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.types +++ b/tests/baselines/reference/controlFlowDestructuringParameters.types @@ -4,15 +4,15 @@ [{ x: 1 }].map( >[{ x: 1 }].map( ({ x }) => x) : number[] ->[{ x: 1 }].map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } +>[{ x: 1 }].map : (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[] >[{ x: 1 }] : { x: number; }[] >{ x: 1 } : { x: number; } >x : number >1 : 1 ->map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: void, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } +>map : (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[] ({ x }) => x ->({ x }) => x : (this: void, { x }: { x: number; }) => number +>({ x }) => x : ({ x }: { x: number; }) => number >x : number >x : number diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index 16d1ec71462..5b9ea793e7d 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -247,7 +247,7 @@ function goo(x: X) { x.y; >x.y : string ->x : Y +>x : X & Y >y : string } x; diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols index 3267a29050e..b0338f1c803 100644 --- a/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols @@ -11,17 +11,17 @@ let buttonProps; // any let k = ; ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) === tests/cases/conformance/jsx/declaration.d.ts === declare module "classnames"; diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols index 76d9b8cdfe0..7e131bde878 100644 --- a/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols @@ -12,17 +12,17 @@ let buttonProps : {[attributeName: string]: ''} let k = ; ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) === tests/cases/conformance/jsx/declaration.d.ts === declare module "classnames"; diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols index 088f553baa4..4002c29b3c6 100644 --- a/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols @@ -11,17 +11,17 @@ let buttonProps; let k = ; ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) === tests/cases/conformance/jsx/declaration.d.ts === declare module "classnames"; diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences4.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences4.symbols index 83b245072e9..0253e34533f 100644 --- a/tests/baselines/reference/correctlyMarkAliasAsReferences4.symbols +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences4.symbols @@ -12,7 +12,7 @@ let buttonProps : {[attributeName: string]: ''} let k =
}/> >MyComponent : Symbol(MyComponent, Decl(file.tsx, 4, 1)) >AnyComponent : Symbol(AnyComponent, Decl(file.tsx, 14, 12)) ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) ->button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) // Component Class as Props class MyButtonComponent extends React.Component<{},{}> { >MyButtonComponent : Symbol(MyButtonComponent, Decl(file.tsx, 14, 57)) ->React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) >React : Symbol(React, Decl(file.tsx, 0, 0)) ->Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) } diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols index d294a9c28cf..b73bd8882d2 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -15,9 +15,9 @@ var nodes: TreeNode[]; >TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types index 518bf14d010..5269bd9b518 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -16,10 +16,10 @@ var nodes: TreeNode[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } +>nodes.map : (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any) => U[] >nodes : TreeNode[] ->map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: void, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } ->n => n.name : (this: void, n: TreeNode) => string +>map : (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any) => U[] +>n => n.name : (n: TreeNode) => string >n : TreeNode >n.name : string >n : TreeNode diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols index 3761994619c..7cec46cb4b6 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -26,9 +26,9 @@ var nodes: TreeNodeMiddleman[]; >TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types index 45054ed6aa0..59244850849 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -27,10 +27,10 @@ var nodes: TreeNodeMiddleman[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } +>nodes.map : (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any) => U[] >nodes : TreeNodeMiddleman[] ->map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: void, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } ->n => n.name : (this: void, n: TreeNodeMiddleman) => string +>map : (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any) => U[] +>n => n.name : (n: TreeNodeMiddleman) => string >n : TreeNodeMiddleman >n.name : string >n : TreeNodeMiddleman diff --git a/tests/baselines/reference/typeOfPrototype.js b/tests/baselines/reference/typeOfPrototype.js index a0f076113e0..3e8b3186936 100644 --- a/tests/baselines/reference/typeOfPrototype.js +++ b/tests/baselines/reference/typeOfPrototype.js @@ -11,7 +11,7 @@ var Foo = (function () { function Foo() { this.bar = 3; } + Foo.bar = ''; return Foo; }()); -Foo.bar = ''; Foo.prototype.bar = undefined; // Should be OK diff --git a/tests/baselines/reference/typeOfThisInStaticMembers2.js b/tests/baselines/reference/typeOfThisInStaticMembers2.js index 886ea04e23d..b01770446be 100644 --- a/tests/baselines/reference/typeOfThisInStaticMembers2.js +++ b/tests/baselines/reference/typeOfThisInStaticMembers2.js @@ -11,12 +11,12 @@ class C2 { var C = (function () { function C() { } + C.foo = this; // error return C; }()); -C.foo = this; // error var C2 = (function () { function C2() { } + C2.foo = this; // error return C2; }()); -C2.foo = this; // error diff --git a/tests/baselines/reference/typeQueryOnClass.js b/tests/baselines/reference/typeQueryOnClass.js index 80623af5be8..85dff0de831 100644 --- a/tests/baselines/reference/typeQueryOnClass.js +++ b/tests/baselines/reference/typeQueryOnClass.js @@ -99,10 +99,10 @@ var C = (function () { enumerable: true, configurable: true }); + C.sa = 1; + C.sb = function () { return 1; }; return C; }()); -C.sa = 1; -C.sb = function () { return 1; }; var c; // BUG 820454 var r1; diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index a5f51ffda9c..f3f0aca48c3 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -166,65 +166,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 46, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 45, 44)) return typedArrays; @@ -241,65 +241,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 61, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 60, 47)) return typedArrays; @@ -457,73 +457,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 106, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 105, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 105, 58)) @@ -545,81 +545,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 121, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 120, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 120, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 120, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 259d601d426..99c7e433ea5 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -273,9 +273,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -284,9 +284,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -295,9 +295,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -306,9 +306,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -317,9 +317,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -328,9 +328,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -339,9 +339,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -350,9 +350,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -361,9 +361,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -385,9 +385,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -396,9 +396,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -407,9 +407,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -418,9 +418,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -429,9 +429,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -440,9 +440,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -451,9 +451,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -462,9 +462,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -473,9 +473,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -757,9 +757,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -769,9 +769,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -781,9 +781,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -793,9 +793,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -805,9 +805,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -817,9 +817,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -829,9 +829,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -841,9 +841,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -853,9 +853,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -882,9 +882,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -895,9 +895,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -908,9 +908,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -921,9 +921,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -934,9 +934,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -947,9 +947,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -960,9 +960,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -973,9 +973,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -986,9 +986,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} diff --git a/tests/baselines/reference/typeofUsedBeforeBlockScoped.js b/tests/baselines/reference/typeofUsedBeforeBlockScoped.js index eebf4beae67..cc9003dd4f6 100644 --- a/tests/baselines/reference/typeofUsedBeforeBlockScoped.js +++ b/tests/baselines/reference/typeofUsedBeforeBlockScoped.js @@ -12,8 +12,8 @@ let o = { n: 12 }; var C = (function () { function C() { } + C.s = 2; return C; }()); -C.s = 2; var o2; var o = { n: 12 }; diff --git a/tests/baselines/reference/unqualifiedCallToClassStatic1.js b/tests/baselines/reference/unqualifiedCallToClassStatic1.js index 906e9d3795f..6c78a737fe8 100644 --- a/tests/baselines/reference/unqualifiedCallToClassStatic1.js +++ b/tests/baselines/reference/unqualifiedCallToClassStatic1.js @@ -10,9 +10,9 @@ class Vector { var Vector = (function () { function Vector() { } + Vector.foo = function () { + // 'foo' cannot be called in an unqualified manner. + foo(); + }; return Vector; }()); -Vector.foo = function () { - // 'foo' cannot be called in an unqualified manner. - foo(); -}; diff --git a/tests/baselines/reference/unreachableJavascriptChecked.errors.txt b/tests/baselines/reference/unreachableJavascriptChecked.errors.txt new file mode 100644 index 00000000000..c66b342177f --- /dev/null +++ b/tests/baselines/reference/unreachableJavascriptChecked.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unreachable.js(3,5): error TS7027: Unreachable code detected. + + +==== tests/cases/compiler/unreachable.js (1 errors) ==== + function unreachable() { + return 1; + return 2; + ~~~~~~ +!!! error TS7027: Unreachable code detected. + } \ No newline at end of file diff --git a/tests/baselines/reference/unreachableJavascriptChecked.js b/tests/baselines/reference/unreachableJavascriptChecked.js new file mode 100644 index 00000000000..6bf264bf3d2 --- /dev/null +++ b/tests/baselines/reference/unreachableJavascriptChecked.js @@ -0,0 +1,11 @@ +//// [unreachable.js] +function unreachable() { + return 1; + return 2; +} + +//// [unreachable.js] +function unreachable() { + return 1; + return 2; +} diff --git a/tests/baselines/reference/unreachableJavascriptUnchecked.js b/tests/baselines/reference/unreachableJavascriptUnchecked.js new file mode 100644 index 00000000000..6bf264bf3d2 --- /dev/null +++ b/tests/baselines/reference/unreachableJavascriptUnchecked.js @@ -0,0 +1,11 @@ +//// [unreachable.js] +function unreachable() { + return 1; + return 2; +} + +//// [unreachable.js] +function unreachable() { + return 1; + return 2; +} diff --git a/tests/baselines/reference/unreachableJavascriptUnchecked.symbols b/tests/baselines/reference/unreachableJavascriptUnchecked.symbols new file mode 100644 index 00000000000..f2db6a6a347 --- /dev/null +++ b/tests/baselines/reference/unreachableJavascriptUnchecked.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/unreachable.js === +function unreachable() { +>unreachable : Symbol(unreachable, Decl(unreachable.js, 0, 0)) + + return 1; + return 2; +} diff --git a/tests/baselines/reference/unreachableJavascriptUnchecked.types b/tests/baselines/reference/unreachableJavascriptUnchecked.types new file mode 100644 index 00000000000..266a9038875 --- /dev/null +++ b/tests/baselines/reference/unreachableJavascriptUnchecked.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/unreachable.js === +function unreachable() { +>unreachable : () => 1 | 2 + + return 1; +>1 : 1 + + return 2; +>2 : 2 +} diff --git a/tests/baselines/reference/weakType.errors.txt b/tests/baselines/reference/weakType.errors.txt new file mode 100644 index 00000000000..7064ace5daa --- /dev/null +++ b/tests/baselines/reference/weakType.errors.txt @@ -0,0 +1,72 @@ +tests/cases/compiler/weakType.ts(31,18): error TS2559: Type '{ error?: number; }' has no properties in common with type 'ChangeOptions'. +tests/cases/compiler/weakType.ts(56,5): error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak & Spoiler'. + Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak'. + Types of property 'properties' are incompatible. + Type '{ wrong: string; }' has no properties in common with type '{ b?: number; }'. + + +==== tests/cases/compiler/weakType.ts (2 errors) ==== + interface Settings { + timeout?: number; + onError?(): void; + } + + function getDefaultSettings() { + return { timeout: 1000 }; + } + + function doSomething(settings: Settings) { /* ... */ } + + // forgot to call `getDefaultSettings` + // but it is not caught because we don't check for call signatures + doSomething(getDefaultSettings); + + // this is an oddly popular way of defining settings + // this example is from services/textChanges.ts + type ConfigurableStart = { useStart?: boolean } + type ConfigurableEnd = { useEnd?: boolean } + type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd + interface InsertOptions { + prefix?: string + suffix?: string + } + type ChangeOptions = ConfigurableStartEnd & InsertOptions; + + function del(options: ConfigurableStartEnd = {}, + error: { error?: number } = {}) { + let changes: ChangeOptions[]; + changes.push(options); + changes.push(error); + ~~~~~ +!!! error TS2559: Type '{ error?: number; }' has no properties in common with type 'ChangeOptions'. + } + + class K { + constructor(s: string) { } + } + // Ctor isn't a weak type because it has a construct signature + interface Ctor { + new (s: string): K + n?: number + } + let ctor: Ctor = K + + type Spoiler = { nope?: string } + type Weak = { + a?: number + properties?: { + b?: number + } + } + declare let unknown: { + properties: { + wrong: string + } + } + let weak: Weak & Spoiler = unknown + ~~~~ +!!! error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak & Spoiler'. +!!! error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak'. +!!! error TS2322: Types of property 'properties' are incompatible. +!!! error TS2322: Type '{ wrong: string; }' has no properties in common with type '{ b?: number; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/weakType.js b/tests/baselines/reference/weakType.js new file mode 100644 index 00000000000..6ed3ff1814d --- /dev/null +++ b/tests/baselines/reference/weakType.js @@ -0,0 +1,81 @@ +//// [weakType.ts] +interface Settings { + timeout?: number; + onError?(): void; +} + +function getDefaultSettings() { + return { timeout: 1000 }; +} + +function doSomething(settings: Settings) { /* ... */ } + +// forgot to call `getDefaultSettings` +// but it is not caught because we don't check for call signatures +doSomething(getDefaultSettings); + +// this is an oddly popular way of defining settings +// this example is from services/textChanges.ts +type ConfigurableStart = { useStart?: boolean } +type ConfigurableEnd = { useEnd?: boolean } +type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd +interface InsertOptions { + prefix?: string + suffix?: string +} +type ChangeOptions = ConfigurableStartEnd & InsertOptions; + +function del(options: ConfigurableStartEnd = {}, + error: { error?: number } = {}) { + let changes: ChangeOptions[]; + changes.push(options); + changes.push(error); +} + +class K { + constructor(s: string) { } +} +// Ctor isn't a weak type because it has a construct signature +interface Ctor { + new (s: string): K + n?: number +} +let ctor: Ctor = K + +type Spoiler = { nope?: string } +type Weak = { + a?: number + properties?: { + b?: number + } +} +declare let unknown: { + properties: { + wrong: string + } +} +let weak: Weak & Spoiler = unknown + + +//// [weakType.js] +function getDefaultSettings() { + return { timeout: 1000 }; +} +function doSomething(settings) { } +// forgot to call `getDefaultSettings` +// but it is not caught because we don't check for call signatures +doSomething(getDefaultSettings); +function del(options, error) { + if (options === void 0) { options = {}; } + if (error === void 0) { error = {}; } + var changes; + changes.push(options); + changes.push(error); +} +var K = (function () { + function K(s) { + } + return K; +}()); +var ctor = K; +var weak = unknown; diff --git a/tests/baselines/reference/witness.js b/tests/baselines/reference/witness.js index 9f92c90ffa4..ebd1669d177 100644 --- a/tests/baselines/reference/witness.js +++ b/tests/baselines/reference/witness.js @@ -258,9 +258,9 @@ var c2inst; var C3 = (function () { function C3() { } + C3.q = C3.q; return C3; }()); -C3.q = C3.q; var qq = C3.q; var qq; // Parentheses - tested a bunch above diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 3e8ce3d8d63..436a1401d57 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -15,7 +15,7 @@ declare var fs: { existsSync(path: string): boolean; readdirSync(path: string): string[]; readFileSync(filename: string, encoding?: string): string; - writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; } | string): void; watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void; }; declare var path: any; diff --git a/tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts b/tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts new file mode 100644 index 00000000000..16827602308 --- /dev/null +++ b/tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts @@ -0,0 +1,5 @@ +// @outFile: foo.js +// @Filename: c.ts +let foo: typeof C; +// @Filename: b.ts +class C { } diff --git a/tests/cases/compiler/exactSpellingSuggestion.ts b/tests/cases/compiler/exactSpellingSuggestion.ts new file mode 100644 index 00000000000..99aec9a0199 --- /dev/null +++ b/tests/cases/compiler/exactSpellingSuggestion.ts @@ -0,0 +1,9 @@ +// Fixes #16245 -- always suggest the exact match, even when +// other options are very close +enum U8 { + BIT_0 = 1 << 0, + BIT_1 = 1 << 1, + BIT_2 = 1 << 2 +} + +U8.bit_2 diff --git a/tests/cases/compiler/forAwaitForUnion.ts b/tests/cases/compiler/forAwaitForUnion.ts new file mode 100644 index 00000000000..65e08ab77a9 --- /dev/null +++ b/tests/cases/compiler/forAwaitForUnion.ts @@ -0,0 +1,6 @@ +// @target: esnext +// @lib: esnext +async function f(source: Iterable | AsyncIterable) { + for await (const x of source) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts b/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts index 3433adc17d5..7659350d489 100644 --- a/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts +++ b/tests/cases/compiler/jsFileCompilationBindDuplicateIdentifier.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @checkJs: true // @noEmit: true // @filename: a.js var a = 10; diff --git a/tests/cases/compiler/jsFileCompilationBindErrors.ts b/tests/cases/compiler/jsFileCompilationBindErrors.ts index 37bdbc62916..7c43b329a47 100644 --- a/tests/cases/compiler/jsFileCompilationBindErrors.ts +++ b/tests/cases/compiler/jsFileCompilationBindErrors.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @checkJs: true // @noEmit: true // @filename: a.js let C = "sss"; diff --git a/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts b/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts index 32a9e77fcc7..e7816f92ad1 100644 --- a/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts +++ b/tests/cases/compiler/jsFileCompilationBindMultipleDefaultExports.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @checkJs: true // @noEmit: true // @filename: a.js // @target: es6 diff --git a/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts index b95f85c2139..e9273231316 100644 --- a/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts +++ b/tests/cases/compiler/jsFileCompilationBindReachabilityErrors.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @checkJs: true // @noEmit: true // @filename: a.js // @noFallthroughCasesInSwitch: true diff --git a/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts b/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts index 30b43b1990e..527927be6e6 100644 --- a/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts +++ b/tests/cases/compiler/jsFileCompilationBindStrictModeErrors.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @checkJs: true // @noEmit: true // @filename: a.js // @target: es6 diff --git a/tests/cases/compiler/reexportedMissingAlias.ts b/tests/cases/compiler/reexportedMissingAlias.ts new file mode 100644 index 00000000000..b430cd526c8 --- /dev/null +++ b/tests/cases/compiler/reexportedMissingAlias.ts @@ -0,0 +1,9 @@ +// Fixes #15094 +// @Filename: second.d.ts +export import Component = CompletelyMissing; +// @Filename: first.d.ts +import * as Second from './second'; +export = Second; +// @Filename: crash.ts +import { Component } from './first'; +class C extends Component { } diff --git a/tests/cases/compiler/symbolMergeValueAndImportedType.ts b/tests/cases/compiler/symbolMergeValueAndImportedType.ts new file mode 100644 index 00000000000..4779ff22e9d --- /dev/null +++ b/tests/cases/compiler/symbolMergeValueAndImportedType.ts @@ -0,0 +1,9 @@ +// @target: es2015 +// @module: commonjs +// @lib: es2015,dom +// @filename: main.ts +import { X } from "./other"; +const X = 42; +console.log('X is ' + X); +// @filename: other.ts +export type X = {}; \ No newline at end of file diff --git a/tests/cases/compiler/unreachableJavascriptChecked.ts b/tests/cases/compiler/unreachableJavascriptChecked.ts new file mode 100644 index 00000000000..4db98c4c8c4 --- /dev/null +++ b/tests/cases/compiler/unreachableJavascriptChecked.ts @@ -0,0 +1,8 @@ +// @Filename: unreachable.js +// @allowJs: true +// @checkJs: true +// @outDir: out +function unreachable() { + return 1; + return 2; +} \ No newline at end of file diff --git a/tests/cases/compiler/unreachableJavascriptUnchecked.ts b/tests/cases/compiler/unreachableJavascriptUnchecked.ts new file mode 100644 index 00000000000..d5b1f45e282 --- /dev/null +++ b/tests/cases/compiler/unreachableJavascriptUnchecked.ts @@ -0,0 +1,8 @@ +// @Filename: unreachable.js +// @allowJs: true +// @checkJs: false +// @outDir: out +function unreachable() { + return 1; + return 2; +} \ No newline at end of file diff --git a/tests/cases/compiler/weakType.ts b/tests/cases/compiler/weakType.ts new file mode 100644 index 00000000000..f04f36c9c2f --- /dev/null +++ b/tests/cases/compiler/weakType.ts @@ -0,0 +1,56 @@ +interface Settings { + timeout?: number; + onError?(): void; +} + +function getDefaultSettings() { + return { timeout: 1000 }; +} + +function doSomething(settings: Settings) { /* ... */ } + +// forgot to call `getDefaultSettings` +// but it is not caught because we don't check for call signatures +doSomething(getDefaultSettings); + +// this is an oddly popular way of defining settings +// this example is from services/textChanges.ts +type ConfigurableStart = { useStart?: boolean } +type ConfigurableEnd = { useEnd?: boolean } +type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd +interface InsertOptions { + prefix?: string + suffix?: string +} +type ChangeOptions = ConfigurableStartEnd & InsertOptions; + +function del(options: ConfigurableStartEnd = {}, + error: { error?: number } = {}) { + let changes: ChangeOptions[]; + changes.push(options); + changes.push(error); +} + +class K { + constructor(s: string) { } +} +// Ctor isn't a weak type because it has a construct signature +interface Ctor { + new (s: string): K + n?: number +} +let ctor: Ctor = K + +type Spoiler = { nope?: string } +type Weak = { + a?: number + properties?: { + b?: number + } +} +declare let unknown: { + properties: { + wrong: string + } +} +let weak: Weak & Spoiler = unknown diff --git a/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts new file mode 100644 index 00000000000..295b6470301 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts @@ -0,0 +1,15 @@ +// @module: esnext +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}) + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpression2ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression2ESNext.ts new file mode 100644 index 00000000000..f0e9b358854 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression2ESNext.ts @@ -0,0 +1,16 @@ +// @module: esnext +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +function foo(x: Promise) { + x.then(value => { + let b = new value.B(); + b.print(); + }) +} + +foo(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpression3ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression3ESNext.ts new file mode 100644 index 00000000000..ee7264b8c7e --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression3ESNext.ts @@ -0,0 +1,14 @@ +// @module: esnext +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts new file mode 100644 index 00000000000..91342770d7d --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts @@ -0,0 +1,26 @@ +// @module: esnext +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare var console: any; +class C { + private myModule = import("./0"); + method() { + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpression5ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression5ESNext.ts new file mode 100644 index 00000000000..173b606a50c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression5ESNext.ts @@ -0,0 +1,20 @@ +// @module: esnext +// @target: esnext +// @strictNullChecks: true +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare function bar(): boolean; +const specify = bar() ? "./0" : undefined; +let myModule = import(specify); +let myModule1 = import(undefined); +let myModule2 = import(bar() ? "./1" : null); +let myModule3 = import(null); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpression6ESNext.ts b/tests/cases/conformance/dynamicImport/importCallExpression6ESNext.ts new file mode 100644 index 00000000000..f09521186e8 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpression6ESNext.ts @@ -0,0 +1,19 @@ +// @module: esnext +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare function bar(): boolean; +const specify = bar() ? "./0" : undefined; +let myModule = import(specify); +let myModule1 = import(undefined); +let myModule2 = import(bar() ? "./1" : null); +let myModule3 = import(null); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionCheckReturntype1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionCheckReturntype1.ts new file mode 100644 index 00000000000..1218565fa54 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionCheckReturntype1.ts @@ -0,0 +1,17 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +// @filename: anotherModule.ts +export class D{} + +// @filename: defaultPath.ts +export class C {} + +// @filename: 1.ts +import * as defaultModule from "./defaultPath"; +import * as anotherModule from "./anotherModule"; + +let p1: Promise = import("./defaultPath"); +let p2 = import("./defaultPath") as Promise; +let p3: Promise = import("./defaultPath"); diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts new file mode 100644 index 00000000000..fb299951148 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts @@ -0,0 +1,19 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false +// @declaration: true + +declare function getSpecifier(): string; +declare var whatToLoad: boolean; +declare const directory: string; +declare const moduleFile: number; + +import(getSpecifier()); + +var p0 = import(`${directory}\${moduleFile}`); +var p1 = import(getSpecifier()); +const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") + +function returnDynamicLoad(path: string) { + return import(path); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit2.ts new file mode 100644 index 00000000000..4b9196dea20 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit2.ts @@ -0,0 +1,9 @@ +// @module: esnext +// @target: esnext +// @declaration: true + +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +var p1 = import("./0"); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit3.ts b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit3.ts new file mode 100644 index 00000000000..6d17d624190 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit3.ts @@ -0,0 +1,15 @@ +// @module: esnext +// @target: esnext +// @declaration: true + +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +declare function getPath(): string; +import * as Zero from "./0"; +import("./0"); + +export var p0: Promise = import(getPath()); +export var p1: Promise = import("./0"); +export var p2: Promise = import("./0"); diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts new file mode 100644 index 00000000000..33c31283ea0 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts @@ -0,0 +1,16 @@ +// @module: amd +// @target: es5 +// @lib: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts new file mode 100644 index 00000000000..900ddbdba0c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts @@ -0,0 +1,16 @@ +// @module: commonjs +// @target: es5 +// @lib: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts new file mode 100644 index 00000000000..c00ab6899c6 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts @@ -0,0 +1,16 @@ +// @module: system +// @target: es5 +// @lib: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts new file mode 100644 index 00000000000..699b0ffc342 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts @@ -0,0 +1,16 @@ +// @module: umd +// @target: es5 +// @lib: es6 +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionErrorInES2015.ts b/tests/cases/conformance/dynamicImport/importCallExpressionErrorInES2015.ts new file mode 100644 index 00000000000..a7fcd8533a3 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionErrorInES2015.ts @@ -0,0 +1,15 @@ +// @module: es2015 +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}) + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts b/tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts new file mode 100644 index 00000000000..38dc47f3207 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts @@ -0,0 +1,14 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false + +declare function getSpecifier(): string; +declare var whatToLoad: boolean; + +var a = ["./0"]; +import(...["PathModule"]); + +var p1 = import(...a); +const p2 = import(); +const p3 = import(,); +const p4 = import("pathToModule", "secondModule"); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts new file mode 100644 index 00000000000..63cfc54c732 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts @@ -0,0 +1,15 @@ +// @module: amd +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD2.ts new file mode 100644 index 00000000000..96b2fd4ceff --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD2.ts @@ -0,0 +1,17 @@ +// @module: amd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +// We use Promise for now as there is no way to specify shape of module object +function foo(x: Promise) { + x.then(value => { + let b = new value.B(); + b.print(); + }) +} + +foo(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD3.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD3.ts new file mode 100644 index 00000000000..a2b287b4d95 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD3.ts @@ -0,0 +1,14 @@ +// @module: amd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts new file mode 100644 index 00000000000..10044ab674c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts @@ -0,0 +1,26 @@ +// @module: amd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare var console: any; +class C { + private myModule = import("./0"); + method() { + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts new file mode 100644 index 00000000000..e1457017552 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts @@ -0,0 +1,15 @@ +// @module: commonjs +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS2.ts new file mode 100644 index 00000000000..e42a58a290c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS2.ts @@ -0,0 +1,19 @@ +// @module: commonjs +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +async function compute(promise: Promise) { + let j = await promise; + if (!j) { + j = await import("./1"); + return j.backup(); + } + return j.foo(); +} + +compute(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS3.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS3.ts new file mode 100644 index 00000000000..5990eb3a5a2 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS3.ts @@ -0,0 +1,17 @@ +// @module: commonjs +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +// We use Promise for now as there is no way to specify shape of module object +function foo(x: Promise) { + x.then(value => { + let b = new value.B(); + b.print(); + }) +} + +foo(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS4.ts new file mode 100644 index 00000000000..fba246c0b8b --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS4.ts @@ -0,0 +1,14 @@ +// @module: commonjs +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts new file mode 100644 index 00000000000..db86764802b --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInCJS5.ts @@ -0,0 +1,26 @@ +// @module: commonjs +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare var console: any; +class C { + private myModule = import("./0"); + method() { + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext1.ts new file mode 100644 index 00000000000..166513321a3 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext1.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false + +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +var p1 = import("./0"); +function arguments() { } // this is allow as the file doesn't have implicit "use strict" \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext2.ts new file mode 100644 index 00000000000..754f7e865bb --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInScriptContext2.ts @@ -0,0 +1,11 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false + +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +"use strict" +var p1 = import("./0"); +function arguments() { } \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts new file mode 100644 index 00000000000..a69e844c7a7 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem1.ts @@ -0,0 +1,15 @@ +// @module: system +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem2.ts new file mode 100644 index 00000000000..c6fac3683ee --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem2.ts @@ -0,0 +1,17 @@ +// @module: system +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +// We use Promise for now as there is no way to specify shape of module object +function foo(x: Promise) { + x.then(value => { + let b = new value.B(); + b.print(); + }) +} + +foo(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem3.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem3.ts new file mode 100644 index 00000000000..7f4485d8962 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem3.ts @@ -0,0 +1,14 @@ +// @module: system +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts new file mode 100644 index 00000000000..1ab3040862c --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInSystem4.ts @@ -0,0 +1,26 @@ +// @module: system +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare var console: any; +class C { + private myModule = import("./0"); + method() { + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts new file mode 100644 index 00000000000..05c4d699104 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD1.ts @@ -0,0 +1,15 @@ +// @module: umd +// @target: esnext +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +import("./0"); +var p1 = import("./0"); +p1.then(zero => { + return zero.foo(); +}); + +function foo() { + const p2 = import("./0"); +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD2.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD2.ts new file mode 100644 index 00000000000..2f76d0aa267 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD2.ts @@ -0,0 +1,17 @@ +// @module: umd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +// We use Promise for now as there is no way to specify shape of module object +function foo(x: Promise) { + x.then(value => { + let b = new value.B(); + b.print(); + }) +} + +foo(import("./0")); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD3.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD3.ts new file mode 100644 index 00000000000..58d21ee52d0 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD3.ts @@ -0,0 +1,14 @@ +// @module: umd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +// @filename: 2.ts +async function foo() { + class C extends (await import("./0")).B {} + var c = new C(); + c.print(); +} +foo(); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts new file mode 100644 index 00000000000..ef0f0999407 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionInUMD4.ts @@ -0,0 +1,26 @@ +// @module: umd +// @target: esnext +// @filename: 0.ts +export class B { + print() { return "I am B"} +} + +export function foo() { return "foo" } + +// @filename: 1.ts +export function backup() { return "backup"; } + +// @filename: 2.ts +declare var console: any; +class C { + private myModule = import("./0"); + method() { + this.myModule.then(Zero => { + console.log(Zero.foo()); + }, async err => { + console.log(err); + let one = await import("./1"); + console.log(one.backup()); + }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionReturnPromiseOfAny.ts b/tests/cases/conformance/dynamicImport/importCallExpressionReturnPromiseOfAny.ts new file mode 100644 index 00000000000..34f0b63be6f --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionReturnPromiseOfAny.ts @@ -0,0 +1,34 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true +// @filename: defaultPath.ts +export class C {} + +// @filename: 1.ts +import * as defaultModule from "./defaultPath"; +declare function getSpecifier(): string; +declare function ValidSomeCondition(): boolean; +declare var whatToLoad: boolean; +declare const directory: string; +declare const moduleFile: number; + +import(`${directory}\${moduleFile}`); +import(getSpecifier()); + +var p1 = import(ValidSomeCondition() ? "./0" : "externalModule"); +var p1: Promise = import(getSpecifier()); +var p11: Promise = import(getSpecifier()); +const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") as Promise; +p1.then(zero => { + return zero.foo(); // ok, zero is any +}); + +let j: string; +var p3: Promise = import(j=getSpecifier()); + +function * loadModule(directories: string[]) { + for (const directory of directories) { + const path = `${directory}\moduleFile`; + import(yield path); + } +} diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts b/tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts new file mode 100644 index 00000000000..3af0ec89ac2 --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionSpecifierNotStringTypeError.ts @@ -0,0 +1,17 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false + +declare function getSpecifier(): boolean; +declare var whatToLoad: boolean; + +// Error specifier is not assignable to string +import(getSpecifier()); +var p1 = import(getSpecifier()); +const p2 = import(whatToLoad ? getSpecifier() : "defaulPath") +p1.then(zero => { + return zero.foo(); // ok, zero is any +}); + +var p3 = import(["path1", "path2"]); +var p4 = import(()=>"PathToModule"); \ No newline at end of file diff --git a/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts b/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts new file mode 100644 index 00000000000..895b61af6ff --- /dev/null +++ b/tests/cases/conformance/dynamicImport/importCallExpressionWithTypeArgument.ts @@ -0,0 +1,14 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: false + +// @filename: 0.ts +export function foo() { return "foo"; } + +// @filename: 1.ts +"use strict" +var p1 = import>("./0"); // error +var p2 = import<>("./0"); // error +// p1.then(value => { +// value.anyFunction(); +// }) \ No newline at end of file diff --git a/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts b/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts new file mode 100644 index 00000000000..f2d1f46873d --- /dev/null +++ b/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts @@ -0,0 +1,26 @@ +// @target: es2017 +// @lib: esnext +// @filename: file1.ts +async function f1() { + let y: any; + for await (const x of y) { + } +} +// @filename: file2.ts +async function f2() { + let x: any, y: any; + for await (x of y) { + } +} +// @filename: file3.ts +async function* f3() { + let y: any; + for await (const x of y) { + } +} +// @filename: file4.ts +async function* f4() { + let x: any, y: any; + for await (x of y) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/checkJsdocParamTag1.ts b/tests/cases/conformance/jsdoc/checkJsdocParamTag1.ts new file mode 100644 index 00000000000..1586a10472c --- /dev/null +++ b/tests/cases/conformance/jsdoc/checkJsdocParamTag1.ts @@ -0,0 +1,14 @@ +// @allowJS: true +// @suppressOutputPathCheck: true + +// @filename: 0.js +// @ts-check +/** + * @param {number=} n + * @param {string} [s] + */ +function foo(n, s) {} + +foo(); +foo(1); +foo(1, "hi"); \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/checkJsdocReturnTag1.ts b/tests/cases/conformance/jsdoc/checkJsdocReturnTag1.ts new file mode 100644 index 00000000000..fde7c3fa0f4 --- /dev/null +++ b/tests/cases/conformance/jsdoc/checkJsdocReturnTag1.ts @@ -0,0 +1,25 @@ +// @allowJs: true +// @out: dummy.js + +// @filename: returns.js +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return "hello"; +} + +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { + return "hello world"; +} + +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { + return 5 || "hello"; +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/checkJsdocReturnTag2.ts b/tests/cases/conformance/jsdoc/checkJsdocReturnTag2.ts new file mode 100644 index 00000000000..02b7fbeacef --- /dev/null +++ b/tests/cases/conformance/jsdoc/checkJsdocReturnTag2.ts @@ -0,0 +1,18 @@ +// @allowJs: true +// @out: dummy.js + +// @filename: returns.js +// @ts-check +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return 5; +} + +/** + * @returns {string | number} This comment is not currently exposed + */ +function f1() { + return 5 || true; +} \ No newline at end of file diff --git a/tests/cases/conformance/salsa/jsDocTypes2.ts b/tests/cases/conformance/jsdoc/checkJsdocTypeTag1.ts similarity index 76% rename from tests/cases/conformance/salsa/jsDocTypes2.ts rename to tests/cases/conformance/jsdoc/checkJsdocTypeTag1.ts index 21107f87ccf..fbed9d83b22 100644 --- a/tests/cases/conformance/salsa/jsDocTypes2.ts +++ b/tests/cases/conformance/jsdoc/checkJsdocTypeTag1.ts @@ -3,8 +3,15 @@ // @filename: 0.js // @ts-check +/** @type {String} */ +var S = "hello world"; + +/** @type {number} */ +var n = 10; + /** @type {*} */ var anyT = 2; +anyT = "hello"; /** @type {?} */ var anyT1 = 2; diff --git a/tests/cases/conformance/salsa/jsDocTypes3.ts b/tests/cases/conformance/jsdoc/checkJsdocTypeTag2.ts similarity index 57% rename from tests/cases/conformance/salsa/jsDocTypes3.ts rename to tests/cases/conformance/jsdoc/checkJsdocTypeTag2.ts index bf207bca869..a7dffdb90a7 100644 --- a/tests/cases/conformance/salsa/jsDocTypes3.ts +++ b/tests/cases/conformance/jsdoc/checkJsdocTypeTag2.ts @@ -3,6 +3,11 @@ // @filename: 0.js // @ts-check +/** @type {String} */ +var S = true; + +/** @type {number} */ +var n = "hello"; /** @type {function (number)} */ const x1 = (a) => a + 1; @@ -13,4 +18,8 @@ const x2 = (a) => a + 1; /** @type {string} */ var a; -a = x2(0); \ No newline at end of file +a = x2(0); + +/** @type {function (number): number} */ +const x2 = (a) => a.concat("hi"); +x2(0); \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/jsdocReturnTag1.ts b/tests/cases/conformance/jsdoc/jsdocReturnTag1.ts new file mode 100644 index 00000000000..a425322a749 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocReturnTag1.ts @@ -0,0 +1,23 @@ +// @allowJs: true +// @filename: returns.js +// @out: dummy.js +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return 5; +} + +/** + * @returns {string=} This comment is not currently exposed + */ +function f1() { + return 5; +} + +/** + * @returns {string|number} This comment is not currently exposed + */ +function f2() { + return 5 || "hello"; +} \ No newline at end of file diff --git a/tests/cases/conformance/salsa/jsDocTypes.ts b/tests/cases/conformance/jsdoc/jsdocTypeTag.ts similarity index 87% rename from tests/cases/conformance/salsa/jsDocTypes.ts rename to tests/cases/conformance/jsdoc/jsdocTypeTag.ts index 9a13c533d0a..d566c61e185 100644 --- a/tests/cases/conformance/salsa/jsDocTypes.ts +++ b/tests/cases/conformance/jsdoc/jsdocTypeTag.ts @@ -57,7 +57,8 @@ var nullable; /** @type {Object} */ var Obj; - +/** @type {Function} */ +var Func; // @filename: b.ts var S: string; @@ -78,3 +79,4 @@ var P: Promise; var p: Promise; var nullable: number | null; var Obj: any; +var Func: Function; diff --git a/tests/cases/conformance/jsdoc/returns.ts b/tests/cases/conformance/jsdoc/returns.ts deleted file mode 100644 index 72cb4a6cb67..00000000000 --- a/tests/cases/conformance/jsdoc/returns.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @allowJs: true -// @filename: returns.js -// @out: dummy.js -/** - * @returns {string} This comment is not currently exposed - */ -function f() { - return ""; -} diff --git a/tests/cases/conformance/jsdoc/syntaxErrors.ts b/tests/cases/conformance/jsdoc/syntaxErrors.ts new file mode 100644 index 00000000000..4f9024810dd --- /dev/null +++ b/tests/cases/conformance/jsdoc/syntaxErrors.ts @@ -0,0 +1,20 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @Filename: foo.js +/** + * @param {(x)=>void} x + * @param {typeof String} y + * @param {string & number} z + **/ +function foo(x, y, z) { } + +// @Filename: skipped.js +// @ts-nocheck +/** + * @param {(x)=>void} x + * @param {typeof String} y + * @param {string & number} z + **/ +function bar(x, y, z) { } diff --git a/tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx b/tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx index a9466a43983..32a1af66f84 100644 --- a/tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx +++ b/tests/cases/conformance/jsx/tsxGenericAttributesType9.tsx @@ -5,7 +5,7 @@ import React = require('react'); -export function makeP

(Ctor: React.ComponentClass

): React.ComponentClass

{ +export function makeP

(Ctor: React.ComponentClass

) { return class extends React.PureComponent { public render(): JSX.Element { return ( @@ -13,4 +13,5 @@ export function makeP

(Ctor: React.ComponentClass

): React.ComponentClass

|] + +goTo.file("/a.tsx"); +verify.not +verify.importFixAtPosition([]); diff --git a/tests/cases/fourslash/jsxQualifiedTagCompletion.ts b/tests/cases/fourslash/jsxQualifiedTagCompletion.ts new file mode 100644 index 00000000000..3d799324e7e --- /dev/null +++ b/tests/cases/fourslash/jsxQualifiedTagCompletion.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare var React: any; +//// namespace NS { +//// export var Foo: any = null; +//// } +//// const j = Hello!/**/ +//// + +goTo.marker(); +edit.insert(" | Element; // Base component for plain JS classes - class Component implements ComponentLifecycle { + interface Component extends ComponentLifecycle { } + class Component { constructor(props?: P, context?: any); setState(f: (prevState: S, props: P) => S, callback?: () => any): void; setState(state: S, callback?: () => any): void; diff --git a/tests/webTestResults.html b/tests/webTestResults.html index 9c403248f94..f747cdfa75c 100644 --- a/tests/webTestResults.html +++ b/tests/webTestResults.html @@ -1,21 +1,26 @@ - + + Mocha Tests +
-
- - -
- +
-
- diff --git a/tslint.json b/tslint.json index 9552d193a70..d3178915fe4 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,7 @@ { "rulesDirectory": "built/local/tslint", "rules": { - "no-bom": true, + "boolean-trivia": true, "class-name": true, "comment-format": [true, "check-space" @@ -9,25 +9,35 @@ "indent": [true, "spaces" ], + "jsdoc-format": true, "linebreak-style": [true, "CRLF"], + "next-line": [true, + "check-catch", + "check-else" + ], + "no-bom": true, + "no-in-operator": true, + "no-increment-decrement": true, + "no-inferrable-types": true, + "no-internal-module": true, + "no-null-keyword": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": [true, "ignore-template-strings"], + "no-type-assertion-whitespace": true, + "no-var-keyword": true, + "object-literal-surrounding-space": true, "one-line": [true, "check-open-brace", "check-whitespace" ], - "no-var-keyword": true, + "prefer-const": true, "quotemark": [true, "double", "avoid-escape" ], "semicolon": [true, "always", "ignore-bound-class-methods"], - "whitespace": [true, - "check-branch", - "check-decl", - "check-operator", - "check-module", - "check-separator", - "check-type" - ], + "triple-equals": true, + "type-operator-spacing": true, "typedef-whitespace": [ true, { @@ -45,23 +55,13 @@ "variable-declaration": "onespace" } ], - "next-line": [true, - "check-catch", - "check-else" - ], - "no-internal-module": true, - "no-trailing-whitespace": [true, "ignore-template-strings"], - "no-inferrable-types": true, - "no-null-keyword": true, - "boolean-trivia": true, - "type-operator-spacing": true, - "prefer-const": true, - "no-increment-decrement": true, - "object-literal-surrounding-space": true, - "no-type-assertion-whitespace": true, - "no-in-operator": true, - "no-switch-case-fall-through": true, - "triple-equals": true, - "jsdoc-format": true - } + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-type" + ] + } }

); } }; -} \ No newline at end of file +} + diff --git a/tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload1.tsx b/tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload1.tsx index d8897321f0b..525d035cbfe 100644 --- a/tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload1.tsx +++ b/tests/cases/conformance/jsx/tsxStatelessFunctionComponentOverload1.tsx @@ -38,10 +38,10 @@ declare function TestingOptional(a: {y1: boolean, y2?: number, y3: boolean}): JS // OK const e1 = -const e2 = const e3 = const e4 = const e5 = const e6 = +const e2 = diff --git a/tests/cases/conformance/salsa/constructorFunctions.ts b/tests/cases/conformance/salsa/constructorFunctions.ts new file mode 100644 index 00000000000..4f1a0368244 --- /dev/null +++ b/tests/cases/conformance/salsa/constructorFunctions.ts @@ -0,0 +1,36 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @filename: index.js + +function C1() { + if (!(this instanceof C1)) return new C1(); + this.x = 1; +} + +const c1_v1 = C1(); +const c1_v2 = new C1(); + +var C2 = function () { + if (!(this instanceof C2)) return new C2(); + this.x = 1; +}; + +const c2_v1 = C2(); +const c2_v2 = new C2(); + +/** @class */ +function C3() { + if (!(this instanceof C3)) return new C3(); +}; + +const c3_v1 = C3(); +const c3_v2 = new C3(); + +/** @class */ +var C4 = function () { + if (!(this instanceof C4)) return new C4(); +}; + +const c4_v1 = C4(); +const c4_v2 = new C4(); \ No newline at end of file diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts index a9d5872705c..55c1acb03b3 100644 --- a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveUnionIntersection.ts @@ -1,5 +1,9 @@ // @declaration: true var a: object & string = ""; // error var b: object | string = ""; // ok +var c: object & {} = 123; // error a = b; // error b = a; // ok + +const foo: object & {} = {bar: 'bar'}; // ok +const bar: object & {err: string} = {bar: 'bar'}; // error diff --git a/tests/cases/compiler/spreadUnion.ts b/tests/cases/conformance/types/spread/spreadUnion.ts similarity index 100% rename from tests/cases/compiler/spreadUnion.ts rename to tests/cases/conformance/types/spread/spreadUnion.ts diff --git a/tests/cases/compiler/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts similarity index 67% rename from tests/cases/compiler/spreadUnion2.ts rename to tests/cases/conformance/types/spread/spreadUnion2.ts index 25dba81c0df..e2f72879915 100644 --- a/tests/cases/compiler/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -4,22 +4,21 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; -var o1: { a: number }; +var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; -var o2: { b: number }; +var o2: {} | { b: number }; var o2 = { ...nullUnion }; -var o3: { a: number, b: number }; +var o3: {} | { b: number } | { a: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: { a: number }; +var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: { b: number }; +var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion }; -var o6: { }; var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; -var o6 = { ...nullAndUndefinedUnion }; \ No newline at end of file +var o7 = { ...nullAndUndefinedUnion }; diff --git a/tests/cases/conformance/types/spread/spreadUnion3.ts b/tests/cases/conformance/types/spread/spreadUnion3.ts new file mode 100644 index 00000000000..c16acbdf7d3 --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadUnion3.ts @@ -0,0 +1,14 @@ +// @strictNullChecks: true +function f(x: { y: string } | undefined): { y: string } { + return { y: 123, ...x } // y: string | number +} +f(undefined) + + +function g(t?: { a: number } | null): void { + let b = { ...t }; + let c: number = b.a; // might not have 'a' +} +g() +g(undefined) +g(null) diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts index 11b32abdf50..1f193285681 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts @@ -29,20 +29,20 @@ module TargetHasOptional { var e: E; var f: F; - // all ok + // disallowed by weak type checking c = d; c = e; c = f; - c = a; - a = d; a = e; a = f; - a = c; - b = d; b = e; b = f; + + // ok + c = a; + a = c; b = a; b = c; } @@ -86,4 +86,4 @@ module SourceHasOptional { b = f; // error b = a; // ok b = c; // ok -} \ No newline at end of file +} diff --git a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts index 9a83bb660f8..1095a2183f3 100644 --- a/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts +++ b/tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts @@ -41,7 +41,7 @@ module Optional { } class B implements A { - fooo: Derived; // ok + fooo: Derived; // weak type error } interface A2 { @@ -49,7 +49,7 @@ module Optional { } class B2 implements A2 { - 2: Derived; // ok + 2: Derived; // weak type error } interface A3 { @@ -57,6 +57,6 @@ module Optional { } class B3 implements A3 { - '1.0': Derived; // ok + '1.0': Derived; // weak type error } -} \ No newline at end of file +} diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes1.ts b/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes1.ts new file mode 100644 index 00000000000..6d937adcbf6 --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/genericContextualTypes1.ts @@ -0,0 +1,52 @@ +// @strict: true +// @declaration: true + +type Box = { value: T }; + +declare function wrap(f: (a: A) => B): (a: A) => B; + +declare function compose(f: (a: A) => B, g: (b: B) => C): (a: A) => C; + +declare function list(a: T): T[]; + +declare function unlist(a: T[]): T; + +declare function box(x: V): Box; + +declare function unbox(x: Box): W; + +declare function map(a: T[], f: (x: T) => U): U[]; + +declare function identity(x: T): T; + +declare function zip(a: A, b: B): [A, B]; + +declare function flip(f: (x: X, y: Y) => Z): (y: Y, x: X) => Z; + +const f00: (x: A) => A[] = list; +const f01: (x: A) => A[] = x => [x]; +const f02: (x: A) => A[] = wrap(list); +const f03: (x: A) => A[] = wrap(x => [x]); + +const f10: (x: T) => Box = compose(a => list(a), b => box(b)); +const f11: (x: T) => Box = compose(list, box); +const f12: (x: Box) => T = compose(a => unbox(a), b => unlist(b)); +const f13: (x: Box) => T = compose(unbox, unlist); + +const arrayMap = (f: (x: T) => U) => (a: T[]) => a.map(f); +const arrayFilter = (f: (x: T) => boolean) => (a: T[]) => a.filter(f); + +const f20: (a: string[]) => number[] = arrayMap(x => x.length); +const f21: (a: A[]) => A[][] = arrayMap(x => [x]); +const f22: (a: A[]) => A[] = arrayMap(identity); +const f23: (a: A[]) => Box[] = arrayMap(value => ({ value })); + +const f30: (a: string[]) => string[] = arrayFilter(x => x.length > 10); +const f31: >(a: T[]) => T[] = arrayFilter(x => x.value > 10); + +const f40: (b: B, a: A) => [A, B] = flip(zip); + +// Repro from #16293 + +type fn = (a: A) => A; +const fn: fn = a => a; diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts index cbabc0ba6c5..db893cb61d3 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember5.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -11,9 +11,11 @@ ////} ////|] -verify.rangeAfterCodeFix(`class C { +verify.getAndApplyCodeFix(/*errorCode*/ undefined, /*index*/ 0); +verify.currentFileContentIs(`class C { static method() { ()=>{ this.foo === 10 }; } } -C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +C.foo = undefined; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts index 0e937a3ab6e..8ac7f2b5aff 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember7.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -9,7 +9,9 @@ ////} ////|] -verify.rangeAfterCodeFix(`class C { +verify.getAndApplyCodeFix(/*errorCode*/ undefined, /*index*/ 2) +verify.currentFileContentIs(`class C { static p = ()=>{ this.foo === 10 }; } -C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2); \ No newline at end of file +C.foo = undefined; +`); diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts new file mode 100644 index 00000000000..435b78ba3fa --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts @@ -0,0 +1,34 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: f2.js +//// import * as X from "./f1"; +//// X.C.m0(1, "", []); +//// X.C.x; +//// let c = new X.C; +//// c.m1(); +//// c.y = {}; + +// @Filename: f1.ts +//// export class C {[| +//// |]x: number; +//// static y: string; +//// } + +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); + +verify.rangeIs(` + y: { [x: string]: any; }; + m1(): any { + throw new Error("Method not implemented."); + } + static x: any; + static m0(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts new file mode 100644 index 00000000000..04e2afc667c --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles2.ts @@ -0,0 +1,39 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: f2.ts +//// import * as X from "./f1"; +//// X.C.m0(1, "", []); +//// X.C.x; +//// let c = new X.C; +//// c.m1(); +//// c.y = {}; + +// @Filename: f1.js +//// [|export class C { +//// constructor() { } +//// } +//// +//// |] + +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); + +verify.rangeIs(` +export class C { + m1() { + throw new Error("Method not implemented."); + } + static m0(arg0, arg1, arg2) { + throw new Error("Method not implemented."); + } + constructor() { + this.y = undefined; + } +} +C.x = undefined; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts new file mode 100644 index 00000000000..75be5420e43 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts @@ -0,0 +1,26 @@ +/// + +//// class A {[| +//// |]static foo0() { +//// this.m1(1,2,3); +//// A.m2(1,2); +//// this.prop1 = 10; +//// A.prop2 = "asdf"; +//// } +//// } + +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); + +verify.rangeIs(` + static prop2: string; + static prop1: number; + static m2(arg0: any, arg1: any): any { + throw new Error("Method not implemented."); + } + static m1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } +`); diff --git a/tests/cases/fourslash/codeFixUndeclaredMethod.ts b/tests/cases/fourslash/codeFixUndeclaredMethod.ts new file mode 100644 index 00000000000..6a61f8421aa --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredMethod.ts @@ -0,0 +1,27 @@ +/// + +//// class A {[| +//// |]constructor() { +//// this.foo1(1,2,3); +//// // 7 type args +//// this.foo2<1,2,3,4,5,6,7>(); +//// // 8 type args +//// this.foo3<1,2,3,4,5,6,7,8>(); +//// } +//// } + +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); +verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); + +verify.rangeIs(` + foo3(): any { + throw new Error("Method not implemented."); + } + foo2(): any { + throw new Error("Method not implemented."); + } + foo1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredPropertyAccesses.ts b/tests/cases/fourslash/codeFixUndeclaredPropertyAccesses.ts new file mode 100644 index 00000000000..ee05d2c0a9c --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredPropertyAccesses.ts @@ -0,0 +1,17 @@ +/// + +//// interface I { x: number; } +//// let i: I; +//// i.y; +//// i.foo(); +//// enum E { a,b } +//// let e: typeof E; +//// e.a; +//// e.c; +//// let obj = { a: 1, b: "asdf"}; +//// obj.c; +//// type T = I | U; +//// let t: T; +//// t.x; + +verify.not.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionEntryForUnionMethod.ts b/tests/cases/fourslash/completionEntryForUnionMethod.ts index 8c112a6d52e..f8fd9ad9dc9 100644 --- a/tests/cases/fourslash/completionEntryForUnionMethod.ts +++ b/tests/cases/fourslash/completionEntryForUnionMethod.ts @@ -5,7 +5,7 @@ goTo.marker(); verify.quickInfoIs( - "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}", - "Calls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results."); + "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])", + "Calls a defined callback function on each element of an array, and returns an array that contains the results."); -verify.completionListContains('map', "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: void, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: void, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}"); +verify.completionListContains('map', "(property) map: ((callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[])"); \ No newline at end of file diff --git a/tests/cases/fourslash/contextualTypingOfGenericCallSignatures2.ts b/tests/cases/fourslash/contextualTypingOfGenericCallSignatures2.ts index 0f610a2a539..efb26cb3af1 100644 --- a/tests/cases/fourslash/contextualTypingOfGenericCallSignatures2.ts +++ b/tests/cases/fourslash/contextualTypingOfGenericCallSignatures2.ts @@ -7,5 +7,5 @@ ////// x should not be contextually typed so this should be an error ////f6(/**/x => x()) -verify.quickInfoAt("", "(parameter) x: any"); +verify.quickInfoAt("", "(parameter) x: T extends I"); verify.numberOfErrorsInCurrentFile(1); diff --git a/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts b/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts index a33e2cc5e7a..bfc4d7ea6fd 100644 --- a/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts +++ b/tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts @@ -1,17 +1,17 @@ /// ////interface Comparable { -//// compareTo(other: T): T; +//// compareTo(other: T): T; ////} ////interface Comparer { -//// >(x: T, y: T): T; +//// >(x: T, y: T): T; ////} ////var max2: Comparer = (x/*1*/x, y/*2*/y) => { return x/*3*/x.compareTo(y/*4*/y) }; verify.quickInfos({ - 1: "(parameter) xx: any", - 2: "(parameter) yy: any", - 3: "(parameter) xx: any", - 4: "(parameter) yy: any" + 1: "(parameter) xx: T extends Comparable", + 2: "(parameter) yy: T extends Comparable", + 3: "(parameter) xx: T extends Comparable", + 4: "(parameter) yy: T extends Comparable" }); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3fada673f35..3e80b005625 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -236,7 +236,9 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void; + rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void + getAndApplyCodeFix(errorCode?: number, index?: number): void; + rangeIs(expectedText: string, includeWhiteSpace?: boolean): void; fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, formattingOptions?: FormatCodeOptions): void; importFixAtPosition(expectedTextArray: string[], errorCode?: number): void; diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts new file mode 100644 index 00000000000..260c34d10a6 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: react + +// @Filename: /node_modules/@types/react/index.d.ts +////export = React; +////export as namespace React; +////declare namespace React { +//// export class Component { render(): JSX.Element | null; } +////} +////declare global { +//// namespace JSX { +//// interface Element {} +//// } +////} + +// @Filename: /a.tsx +////[|import { Component } from "react"; +////export class MyMap extends Component { } +////;|] + +goTo.file("/a.tsx"); + +verify.importFixAtPosition([ +`import { Component } from "react"; +import * as React from "react"; +export class MyMap extends Component { } +;`]); diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts new file mode 100644 index 00000000000..ccd69c50199 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: react + +// @Filename: /node_modules/@types/react/index.d.ts +////export = React; +////export as namespace React; +////declare namespace React { +//// export class Component { render(): JSX.Element | null; } +////} +////declare global { +//// namespace JSX { +//// interface Element {} +//// } +////} + +// @Filename: /a.tsx +////[|import { Component } from "react"; +////export class MyMap extends Component { } +////;|] + +goTo.file("/a.tsx"); + +verify.importFixAtPosition([ +`import { Component } from "react"; +import * as React from "react"; +export class MyMap extends Component { } +;`]); diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts new file mode 100644 index 00000000000..a3c8253fbd1 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts @@ -0,0 +1,21 @@ +/// + +// https://github.com/Microsoft/TypeScript/issues/16065 + +// @jsx: react +// @jsxFactory: factory + +// @Filename: /factory.ts +////export function factory() { return {}; } +////declare global { +//// namespace JSX { +//// interface Element {} +//// } +////} + +// @Filename: /a.tsx +////[|