diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cc81f92fbfc..933381afa92 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1384,7 +1384,7 @@ namespace ts { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } - else if (boundExpression.kind === SyntaxKind.Identifier) { + else if (boundExpression.kind === SyntaxKind.Identifier && node.kind === SyntaxKind.ExportAssignment) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } @@ -1435,7 +1435,8 @@ namespace ts { // Declare a 'member' in case it turns out the container was an ES5 class if (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } } @@ -1444,8 +1445,16 @@ namespace ts { // Look up the function in the local scope, since prototype assignments should // follow the function declaration - const classId = ((node.left).expression).expression; - const funcSymbol = container.locals[classId.text]; + const leftSideOfAssignment = node.left as PropertyAccessExpression; + const classPrototype = leftSideOfAssignment.expression as PropertyAccessExpression; + const constructorFunction = classPrototype.expression as Identifier; + + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + constructorFunction.parent = classPrototype; + classPrototype.parent = leftSideOfAssignment; + + const funcSymbol = container.locals[constructorFunction.text]; if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) { return; } @@ -1456,7 +1465,7 @@ namespace ts { } // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, node.left, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } function bindCallExpression(node: CallExpression) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6404a766738..925aae2783b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2845,7 +2845,7 @@ namespace ts { } // Handle module.exports = expr if (declaration.kind === SyntaxKind.BinaryExpression) { - return links.type = checkExpression((declaration).right); + return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right))); } if (declaration.kind === SyntaxKind.PropertyAccessExpression) { // Declarations only exist for property access expressions for certain @@ -7242,6 +7242,15 @@ namespace ts { // mark iteration statement as containing block-scoped binding captured in some function getNodeLinks(current).flags |= NodeCheckFlags.LoopWithCapturedBlockScopedBinding; } + + // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. + // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. + if (container.kind === SyntaxKind.ForStatement && + getAncestor(symbol.valueDeclaration, SyntaxKind.VariableDeclarationList).parent === container && + isAssignedInBodyOfForStatement(node, container)) { + getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.NeedsLoopOutParameter; + } + // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop; } @@ -7251,6 +7260,41 @@ namespace ts { } } + function isAssignedInBodyOfForStatement(node: Identifier, container: ForStatement): boolean { + let current: Node = node; + // skip parenthesized nodes + while (current.parent.kind === SyntaxKind.ParenthesizedExpression) { + current = current.parent; + } + + // check if node is used as LHS in some assignment expression + let isAssigned = false; + if (current.parent.kind === SyntaxKind.BinaryExpression) { + isAssigned = (current.parent).left === current && isAssignmentOperator((current.parent).operatorToken.kind); + } + + if ((current.parent.kind === SyntaxKind.PrefixUnaryExpression || current.parent.kind === SyntaxKind.PostfixUnaryExpression)) { + const expr = current.parent; + isAssigned = expr.operator === SyntaxKind.PlusPlusToken || expr.operator === SyntaxKind.MinusMinusToken; + } + + if (!isAssigned) { + return false; + } + + // at this point we know that node is the target of assignment + // now check that modification happens inside the statement part of the ForStatement + while (current !== container) { + if (current === container.statement) { + return true; + } + else { + current = current.parent; + } + } + return false; + } + function captureLexicalThis(node: Node, container: Node): void { getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis; if (container.kind === SyntaxKind.PropertyDeclaration || container.kind === SyntaxKind.Constructor) { @@ -10412,9 +10456,11 @@ namespace ts { function getReturnTypeFromJSDocComment(func: SignatureDeclaration | FunctionDeclaration): Type { const returnTag = getJSDocReturnTag(func); - if (returnTag) { + if (returnTag && returnTag.typeExpression) { return getTypeFromTypeNode(returnTag.typeExpression.type); } + + return undefined; } function createPromiseType(promisedType: Type): Type { @@ -10489,7 +10535,8 @@ namespace ts { } else { error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; + // Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience + return getUnionType(types); } } @@ -15400,6 +15447,20 @@ namespace ts { return getSymbolOfNode(entityName.parent); } + if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) { + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.PrototypeProperty: + return getSymbolOfNode(entityName.parent); + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.ModuleExports: + return getSymbolOfNode(entityName.parent.parent); + default: + // Fall through if it is not a special property assignment + } + } + if (entityName.parent.kind === SyntaxKind.ExportAssignment) { return resolveEntityName(entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 733e3158593..5bbd74d6f47 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -294,6 +294,11 @@ namespace ts { name: "allowJs", type: "boolean", description: Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output } ]; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 9a57b4b1a37..9e0351b5d2c 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -695,10 +695,6 @@ namespace ts { } function writeImportDeclaration(node: ImportDeclaration) { - if (!node.importClause && !(node.flags & NodeFlags.Export)) { - // do not write non-exported import declarations that don't have import clauses - return; - } emitJsDocComments(node); if (node.flags & NodeFlags.Export) { write("export "); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 05d207664f0..1a8a53d517c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1,4 +1,4 @@ - { +{ "Unterminated string literal.": { "category": "Error", "code": 1002 @@ -2171,6 +2171,7 @@ "category": "Error", "code": 5059 }, + "Concatenate and emit output to single file.": { "category": "Message", @@ -2216,10 +2217,10 @@ "category": "Message", "code": 6011 }, - "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": { - "category": "Message", - "code": 6015 - }, + "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015' (experimental)": { + "category": "Message", + "code": 6015 + }, "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'": { "category": "Message", "code": 6016 @@ -2445,6 +2446,10 @@ "category": "Message", "code": 6084 }, + "Do not emit 'use strict' directives in module output.": { + "category": "Message", + "code": 6112 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", @@ -2632,23 +2637,23 @@ "code": 17004 }, "A constructor cannot contain a 'super' call when its class extends 'null'": { - "category": "Error", - "code": 17005 + "category": "Error", + "code": 17005 }, "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": { - "category": "Error", - "code": 17006 + "category": "Error", + "code": 17006 }, "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": { - "category": "Error", - "code": 17007 + "category": "Error", + "code": 17007 }, "JSX element '{0}' has no corresponding closing tag.": { - "category": "Error", - "code": 17008 + "category": "Error", + "code": 17008 }, "'super' must be called before accessing 'this' in the constructor of a derived class.": { - "category": "Error", - "code": 17009 + "category": "Error", + "code": 17009 } -} +} \ No newline at end of file diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 98ad7c874d6..72614756fb7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -287,6 +287,54 @@ namespace ts { _i = 0x10000000, // Use/preference flag for '_i' } + const enum CopyDirection { + ToOriginal, + ToOutParameter + } + + /** + * If loop contains block scoped binding captured in some function then loop body is converted to a function. + * Lexical bindings declared in loop initializer will be passed into the loop body function as parameters, + * however if this binding is modified inside the body - this new value should be propagated back to the original binding. + * This is done by declaring new variable (out parameter holder) outside of the loop for every binding that is reassigned inside the body. + * On every iteration this variable is initialized with value of corresponding binding. + * At every point where control flow leaves the loop either explicitly (break/continue) or implicitly (at the end of loop body) + * we copy the value inside the loop to the out parameter holder. + * + * for (let x;;) { + * let a = 1; + * let b = () => a; + * x++ + * if (...) break; + * ... + * } + * + * will be converted to + * + * var out_x; + * var loop = function(x) { + * var a = 1; + * var b = function() { return a; } + * x++; + * if (...) return out_x = x, "break"; + * ... + * out_x = x; + * } + * for (var x;;) { + * out_x = x; + * var state = loop(x); + * x = out_x; + * if (state === "break") break; + * } + * + * NOTE: values to out parameters are not copies if loop is abrupted with 'return' - in this case this will end the entire enclosing function + * so nobody can observe this new value. + */ + interface LoopOutParameter { + originalName: Identifier; + outParamName: string; + } + // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { // emit output for the __extends helper function @@ -419,6 +467,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge * for (var x;;) loop(x); */ hoistedLocalVariables?: Identifier[]; + + /** + * List of loop out parameters - detailed descripion can be found in the comment to LoopOutParameter + */ + loopOutParameters?: LoopOutParameter[]; } function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void { @@ -2944,11 +2997,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } let loopParameters: string[]; + let loopOutParameters: LoopOutParameter[]; if (loopInitializer && (getCombinedNodeFlags(loopInitializer) & NodeFlags.BlockScoped)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (const varDeclaration of loopInitializer.declarations) { - collectNames(varDeclaration.name); + processVariableDeclaration(varDeclaration.name); } } @@ -2958,14 +3012,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge writeLine(); write(`var ${functionName} = function(${paramList})`); - if (!bodyIsBlock) { - write(" {"); - writeLine(); - increaseIndent(); - } - const convertedOuterLoopState = convertedLoopState; - convertedLoopState = {}; + convertedLoopState = { loopOutParameters }; if (convertedOuterLoopState) { // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. @@ -2989,16 +3037,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } - emitEmbeddedStatement(node.statement); + write(" {"); + writeLine(); + increaseIndent(); - if (!bodyIsBlock) { - decreaseIndent(); - writeLine(); - write("}"); + if (bodyIsBlock) { + emitLines((node.statement).statements); } - write(";"); + else { + emit(node.statement); + } + + writeLine(); + // end of loop body -> copy out parameter + copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/true); + + decreaseIndent(); + writeLine(); + write("};"); writeLine(); + if (loopOutParameters) { + // declare variables to hold out params for loop body + write(`var `); + for (let i = 0; i < loopOutParameters.length; i++) { + if (i !== 0) { + write(", "); + } + write(loopOutParameters[i].outParamName); + } + write(";"); + writeLine(); + } if (convertedLoopState.argumentsName) { // if alias for arguments is set if (convertedOuterLoopState) { @@ -3062,14 +3132,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return { functionName, paramList, state: currentLoopState }; - function collectNames(name: Identifier | BindingPattern): void { + function processVariableDeclaration(name: Identifier | BindingPattern): void { if (name.kind === SyntaxKind.Identifier) { - const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) ? getGeneratedNameForNode(name) : (name).text; + const nameText = isNameOfNestedBlockScopedRedeclarationOrCapturedBinding(name) + ? getGeneratedNameForNode(name) + : (name).text; + loopParameters.push(nameText); + if (resolver.getNodeCheckFlags(name.parent) & NodeCheckFlags.NeedsLoopOutParameter) { + const reassignedVariable = { originalName: name, outParamName: makeUniqueName(`out_${nameText}`) }; + (loopOutParameters || (loopOutParameters = [])).push(reassignedVariable); + } } else { for (const element of (name).elements) { - collectNames(element.name); + processVariableDeclaration(element.name); } } } @@ -3100,6 +3177,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } + function copyLoopOutParameters(state: ConvertedLoopState, copyDirection: CopyDirection, emitAsStatements: boolean) { + if (state.loopOutParameters) { + for (const outParam of state.loopOutParameters) { + if (copyDirection === CopyDirection.ToOriginal) { + emitIdentifier(outParam.originalName); + write(` = ${outParam.outParamName}`); + } + else { + write(`${outParam.outParamName} = `); + emitIdentifier(outParam.originalName); + } + if (emitAsStatements) { + write(";"); + writeLine(); + } + else { + write(", "); + } + } + } + } + function emitConvertedLoopCall(loop: ConvertedLoop, emitAsBlock: boolean): void { if (emitAsBlock) { write(" {"); @@ -3120,6 +3219,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } write(`${loop.functionName}(${loop.paramList});`); + writeLine(); + + copyLoopOutParameters(loop.state, CopyDirection.ToOriginal, /*emitAsStatements*/ true); if (!isSimpleLoop) { // for non simple loops we need to store result returned from converted loop function and use it to do dispatching @@ -3138,7 +3240,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } else { // top level converted loop - return unwrapped value - write(`return ${loopResult}.value`); + write(`return ${loopResult}.value;`); } writeLine(); } @@ -3439,14 +3541,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { + write ("return "); + // explicit exit from loop -> copy out parameters + copyLoopOutParameters(convertedLoopState, CopyDirection.ToOutParameter, /*emitAsStatements*/ false); if (!node.label) { if (node.kind === SyntaxKind.BreakStatement) { convertedLoopState.nonLocalJumps |= Jump.Break; - write(`return "break";`); + write(`"break";`); } else { convertedLoopState.nonLocalJumps |= Jump.Continue; - write(`return "continue";`); + write(`"continue";`); } } else { @@ -3459,7 +3564,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge labelMarker = `continue-${node.label.text}`; setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); } - write(`return "${labelMarker}";`); + write(`"${labelMarker}";`); } return; @@ -4766,18 +4871,24 @@ const _super = (function (geti, seti) { emitToken(SyntaxKind.CloseBraceToken, body.statements.end); } - function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement { - if (ctor.body) { - const statement = (ctor.body).statements[0]; - if (statement && statement.kind === SyntaxKind.ExpressionStatement) { - const expr = (statement).expression; - if (expr && expr.kind === SyntaxKind.CallExpression) { - const func = (expr).expression; - if (func && func.kind === SyntaxKind.SuperKeyword) { - return statement; - } - } - } + /** + * Return the statement at a given index if it is a super-call statement + * @param ctor a constructor declaration + * @param index an index to constructor's body to check + */ + function getSuperCallAtGivenIndex(ctor: ConstructorDeclaration, index: number): ExpressionStatement { + if (!ctor.body) { + return undefined; + } + const statements = ctor.body.statements; + + if (!statements || index >= statements.length) { + return undefined; + } + + const statement = statements[index]; + if (statement.kind === SyntaxKind.ExpressionStatement) { + return isSuperCallExpression((statement).expression) ? statement : undefined; } } @@ -5061,13 +5172,15 @@ const _super = (function (geti, seti) { if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); + if (baseTypeElement) { - superCall = findInitialSuperCall(ctor); + superCall = getSuperCallAtGivenIndex(ctor, startIndex); if (superCall) { writeLine(); emit(superCall); } } + emitParameterPropertyAssignments(ctor); } else { @@ -7155,7 +7268,7 @@ const _super = (function (geti, seti) { write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`); writeLine(); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); writeLine(); write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`); writeLine(); @@ -7261,7 +7374,7 @@ const _super = (function (geti, seti) { writeModuleName(node, emitRelativePathAsModuleName); emitAMDDependencies(node, /*includeNonAmdDependencies*/ true, emitRelativePathAsModuleName); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/!compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -7273,7 +7386,7 @@ const _super = (function (geti, seti) { } function emitCommonJSModule(node: SourceFile) { - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -7302,7 +7415,7 @@ const _super = (function (geti, seti) { })(`); emitAMDFactoryHeader(dependencyNames); increaseIndent(); - const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true); + const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 57bd9860d12..94ef398cf72 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3995,7 +3995,7 @@ namespace ts { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return finishNode(shorthandDeclaration); + return addJSDocComment(finishNode(shorthandDeclaration)); } else { const propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); @@ -4004,7 +4004,7 @@ namespace ts { propertyAssignment.questionToken = questionToken; parseExpected(SyntaxKind.ColonToken); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); + return addJSDocComment(finishNode(propertyAssignment)); } } @@ -4051,7 +4051,7 @@ namespace ts { setDecoratorContext(/*val*/ true); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseOptionalIdentifier() { @@ -4335,13 +4335,13 @@ namespace ts { const labeledStatement = createNode(SyntaxKind.LabeledStatement, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); - return finishNode(labeledStatement); + return addJSDocComment(finishNode(labeledStatement)); } else { const expressionStatement = createNode(SyntaxKind.ExpressionStatement, fullStart); expressionStatement.expression = expression; parseSemicolon(); - return finishNode(expressionStatement); + return addJSDocComment(finishNode(expressionStatement)); } } @@ -4778,7 +4778,7 @@ namespace ts { parseExpected(SyntaxKind.ConstructorKeyword); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { @@ -4792,7 +4792,7 @@ namespace ts { const isAsync = !!(method.flags & NodeFlags.Async); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); - return finishNode(method); + return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, name: PropertyName, questionToken: Node): ClassElement { @@ -5758,6 +5758,9 @@ namespace ts { function parseJSDocParameter(): ParameterDeclaration { const parameter = createNode(SyntaxKind.Parameter); parameter.type = parseJSDocType(); + if (parseOptional(SyntaxKind.EqualsToken)) { + parameter.questionToken = createNode(SyntaxKind.EqualsToken); + } return finishNode(parameter); } @@ -5765,16 +5768,22 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTypeReference); result.name = parseSimplePropertyName(); - while (parseOptional(SyntaxKind.DotToken)) { - if (token === SyntaxKind.LessThanToken) { - result.typeArguments = parseTypeArguments(); - break; - } - else { - result.name = parseQualifiedName(result.name); + if (token === SyntaxKind.LessThanToken) { + result.typeArguments = parseTypeArguments(); + } + else { + while (parseOptional(SyntaxKind.DotToken)) { + if (token === SyntaxKind.LessThanToken) { + result.typeArguments = parseTypeArguments(); + break; + } + else { + result.name = parseQualifiedName(result.name); + } } } + return finishNode(result); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d0f1deff584..9737eb0c5e1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2068,7 +2068,8 @@ namespace ts { CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement ClassWithBodyScopedClassBinding = 0x0080000, // Decorated class that contains a binding to itself inside of the class body. - BodyScopedClassBinding = 0x00100000, // Binding to a decorated class inside of the class's body. + BodyScopedClassBinding = 0x00100000, // Binding to a decorated class inside of the class's body. + NeedsLoopOutParameter = 0x00200000, // Block scoped binding whose value should be explicitly copied outside of the converted loop } /* @internal */ @@ -2434,6 +2435,7 @@ namespace ts { forceConsistentCasingInFileNames?: boolean; allowSyntheticDefaultImports?: boolean; allowJs?: boolean; + noImplicitUseStrict?: boolean; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8bcf89ce1f2..d93b37ce1ad 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -464,6 +464,10 @@ namespace ts { return !!(getCombinedNodeFlags(node) & NodeFlags.Let); } + export function isSuperCallExpression(n: Node): boolean { + return n.kind === SyntaxKind.CallExpression && (n).expression.kind === SyntaxKind.SuperKeyword; + } + export function isPrologueDirective(node: Node): boolean { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; } @@ -1207,7 +1211,25 @@ namespace ts { node.parent.parent.parent.kind === SyntaxKind.VariableStatement; const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; - return variableStatementNode && variableStatementNode.jsDocComment; + if (variableStatementNode) { + return variableStatementNode.jsDocComment; + } + + // Also recognize when the node is the RHS of an assignment expression + const parent = node.parent; + const isSourceOfAssignmentExpressionStatement = + parent && parent.parent && + parent.kind === SyntaxKind.BinaryExpression && + (parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && + parent.parent.kind === SyntaxKind.ExpressionStatement; + if (isSourceOfAssignmentExpressionStatement) { + return parent.parent.jsDocComment; + } + + const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment; + if (isPropertyAssignmentExpression) { + return parent.jsDocComment; + } } return undefined; @@ -2018,8 +2040,22 @@ namespace ts { } function onSingleFileEmit(host: EmitHost, sourceFile: SourceFile) { - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, - sourceFile.languageVariant === LanguageVariant.JSX && options.jsx === JsxEmit.Preserve ? ".jsx" : ".js"); + // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. + // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. + // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve + let extension = ".js"; + if (options.jsx === JsxEmit.Preserve) { + if (isSourceFileJavaScript(sourceFile)) { + if (fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; + } + } + else if (sourceFile.languageVariant === LanguageVariant.JSX) { + // TypeScript source file preserving JSX syntax + extension = ".jsx"; + } + } + const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); const emitFileNames: EmitFileNames = { jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), diff --git a/src/services/services.ts b/src/services/services.ts index 0016a27acc3..b553faad1ab 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -62,7 +62,7 @@ namespace ts { export interface SourceFile { /* @internal */ version: string; /* @internal */ scriptSnapshot: IScriptSnapshot; - /* @internal */ nameTable: Map; + /* @internal */ nameTable: Map; /* @internal */ getNamedDeclarations(): Map; @@ -808,7 +808,7 @@ namespace ts { public languageVersion: ScriptTarget; public languageVariant: LanguageVariant; public identifiers: Map; - public nameTable: Map; + public nameTable: Map; public resolvedModules: Map; public imports: LiteralExpression[]; public moduleAugmentations: LiteralExpression[]; @@ -1957,8 +1957,6 @@ namespace ts { const text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); const sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents); setSourceFileFields(sourceFile, scriptSnapshot, version); - // after full parsing we can use table with interned strings as name table - sourceFile.nameTable = sourceFile.identifiers; return sourceFile; } @@ -3821,7 +3819,7 @@ namespace ts { return undefined; } - const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; + const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion @@ -3832,9 +3830,9 @@ namespace ts { const entries: CompletionEntry[] = []; - if (isRightOfDot && isSourceFileJavaScript(sourceFile)) { + if (isSourceFileJavaScript(sourceFile)) { const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); - addRange(entries, getJavaScriptCompletionEntries(sourceFile, uniqueNames)); + addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { if (!symbols || symbols.length === 0) { @@ -3867,12 +3865,17 @@ namespace ts { return { isMemberCompletion, isNewIdentifierLocation, entries }; - function getJavaScriptCompletionEntries(sourceFile: SourceFile, uniqueNames: Map): CompletionEntry[] { + function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { const entries: CompletionEntry[] = []; const target = program.getCompilerOptions().target; const nameTable = getNameTable(sourceFile); for (const name in nameTable) { + // Skip identifiers produced only from the current location + if (nameTable[name] === position) { + continue; + } + if (!uniqueNames[name]) { uniqueNames[name] = name; const displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks*/ true); @@ -5487,7 +5490,7 @@ namespace ts { const nameTable = getNameTable(sourceFile); - if (lookUp(nameTable, internedName)) { + if (lookUp(nameTable, internedName) !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -7525,7 +7528,7 @@ namespace ts { } /* @internal */ - export function getNameTable(sourceFile: SourceFile): Map { + export function getNameTable(sourceFile: SourceFile): Map { if (!sourceFile.nameTable) { initializeNameTable(sourceFile); } @@ -7534,7 +7537,7 @@ namespace ts { } function initializeNameTable(sourceFile: SourceFile): void { - const nameTable: Map = {}; + const nameTable: Map = {}; walk(sourceFile); sourceFile.nameTable = nameTable; @@ -7542,7 +7545,7 @@ namespace ts { function walk(node: Node) { switch (node.kind) { case SyntaxKind.Identifier: - nameTable[(node).text] = (node).text; + nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; break; case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: @@ -7554,7 +7557,7 @@ namespace ts { node.parent.kind === SyntaxKind.ExternalModuleReference || isArgumentOfElementAccessExpression(node)) { - nameTable[(node).text] = (node).text; + nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; } break; default: diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js new file mode 100644 index 00000000000..609d353fbc7 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.js @@ -0,0 +1,22 @@ +//// [blockScopedBindingsReassignedInLoop1.ts] +declare function use(n: number): void; +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { + (() => use(++i))(); + } +})(); + +//// [blockScopedBindingsReassignedInLoop1.js] +(function () { + 'use strict'; + var _loop_1 = function(i) { + (function () { return use(++i); })(); + out_i_1 = i; + }; + var out_i_1; + for (var i = 0; i < 9; ++i) { + _loop_1(i); + i = out_i_1; + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols new file mode 100644 index 00000000000..8024124b04e --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts === +declare function use(n: number): void; +>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0)) +>n : Symbol(n, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 21)) + +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) + + (() => use(++i))(); +>use : Symbol(use, Decl(blockScopedBindingsReassignedInLoop1.ts, 0, 0)) +>i : Symbol(i, Decl(blockScopedBindingsReassignedInLoop1.ts, 3, 10)) + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types new file mode 100644 index 00000000000..7ced53508e6 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts === +declare function use(n: number): void; +>use : (n: number) => void +>n : number + +(function () { +>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }})() : void +>(function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }}) : () => void +>function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }} : () => void + + 'use strict' +>'use strict' : string + + for (let i = 0; i < 9; ++i) { +>i : number +>0 : number +>i < 9 : boolean +>i : number +>9 : number +>++i : number +>i : number + + (() => use(++i))(); +>(() => use(++i))() : void +>(() => use(++i)) : () => void +>() => use(++i) : () => void +>use(++i) : void +>use : (n: number) => void +>++i : number +>i : number + } +})(); diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js new file mode 100644 index 00000000000..c48ecd96ffe --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.js @@ -0,0 +1,120 @@ +//// [blockScopedBindingsReassignedInLoop2.ts] +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + y = 5; + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop; + } + else { + y = 5; + } +} + +//// [blockScopedBindingsReassignedInLoop2.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_1 = x, out_y_1 = y, "break"; + } + else { + y = 5; + } + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_1 === "break") break; +} +var _loop_2 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_2 = x, out_y_2 = y, "continue"; + } + else { + y = 5; + } + out_x_2 = x; + out_y_2 = y; +}; +var out_x_2, out_y_2; +for (var x = 1, y = 2; x < y; ++x, --y) { + var state_2 = _loop_2(x, y); + x = out_x_2; + y = out_y_2; + if (state_2 === "continue") continue; +} +var _loop_3 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_3 = x, out_y_3 = y, "break-loop"; + } + else { + y = 5; + } + out_x_3 = x; + out_y_3 = y; +}; +var out_x_3, out_y_3; +loop: for (var x = 1, y = 2; x < y; ++x, --y) { + var state_3 = _loop_3(x, y); + x = out_x_3; + y = out_y_3; + switch(state_3) { + case "break-loop": break loop; + } +} +var _loop_4 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_4 = x, out_y_4 = y, "continue-loop"; + } + else { + y = 5; + } + out_x_4 = x; + out_y_4 = y; +}; +var out_x_4, out_y_4; +loop: for (var x = 1, y = 2; x < y; ++x, --y) { + var state_4 = _loop_4(x, y); + x = out_x_4; + y = out_y_4; + switch(state_4) { + case "continue-loop": continue loop; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols new file mode 100644 index 00000000000..fcaea39564f --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.symbols @@ -0,0 +1,98 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 1, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 8)) + + break; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 0, 15)) + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 11, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 8)) + + continue; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 10, 15)) + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 22, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 8)) + + break loop; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 21, 15)) + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop2.ts, 33, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 8)) + + continue loop; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop2.ts, 32, 15)) + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types new file mode 100644 index 00000000000..244160dcc6b --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types @@ -0,0 +1,160 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break; + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue; + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop: +>loop : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break loop; +>loop : any + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop: +>loop : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue loop; +>loop : any + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js new file mode 100644 index 00000000000..10160202621 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js @@ -0,0 +1,247 @@ +//// [blockScopedBindingsReassignedInLoop3.ts] + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break; + } + else { + y++; + } + } + + y = 5; + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue; + } + else { + y++; + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break loop1; + } + else { + y++; + break loop2 + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue loop1; + } + else { + y++; + continue loop2 + } + } + + y = 5; + } +} + + +//// [blockScopedBindingsReassignedInLoop3.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_1 = x, out_y_1 = y, "break"; + } + else { + var _loop_2 = function(a_1) { + var f = function () { return a_1; }; + if (a_1) { + a_1 = x; + return out_a_1_1 = a_1, "break"; + } + else { + y++; + } + out_a_1_1 = a_1; + }; + var out_a_1_1; + for (var a_1 = 1; a_1 < 5; --a_1) { + var state_1 = _loop_2(a_1); + a_1 = out_a_1_1; + if (state_1 === "break") break; + } + y = 5; + } + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + var state_2 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_2 === "break") break; +} +var _loop_3 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_2 = x, out_y_2 = y, "continue"; + } + else { + var _loop_4 = function(a_2) { + var f = function () { return a_2; }; + if (a_2) { + a_2 = x; + return out_a_2_1 = a_2, "continue"; + } + else { + y++; + } + out_a_2_1 = a_2; + }; + var out_a_2_1; + for (var a_2 = 1; a_2 < 5; --a_2) { + var state_3 = _loop_4(a_2); + a_2 = out_a_2_1; + if (state_3 === "continue") continue; + } + y = 5; + } + out_x_2 = x; + out_y_2 = y; +}; +var out_x_2, out_y_2; +for (var x = 1, y = 2; x < y; ++x, --y) { + var state_4 = _loop_3(x, y); + x = out_x_2; + y = out_y_2; + if (state_4 === "continue") continue; +} +var _loop_5 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_3 = x, out_y_3 = y, "break-loop2"; + } + else { + var _loop_6 = function(a_3) { + var f = function () { return a_3; }; + if (a_3) { + a_3 = x; + return out_a_3_1 = a_3, "break-loop1"; + } + else { + y++; + return out_a_3_1 = a_3, "break-loop2"; + } + out_a_3_1 = a_3; + }; + var out_a_3_1; + loop1: for (var a_3 = 1; a_3 < 5; --a_3) { + var state_5 = _loop_6(a_3); + a_3 = out_a_3_1; + switch(state_5) { + case "break-loop1": break loop1; + case "break-loop2": return state_5; + } + } + y = 5; + } + out_x_3 = x; + out_y_3 = y; +}; +var out_x_3, out_y_3; +loop2: for (var x = 1, y = 2; x < y; ++x, --y) { + var state_6 = _loop_5(x, y); + x = out_x_3; + y = out_y_3; + switch(state_6) { + case "break-loop2": break loop2; + } +} +var _loop_7 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return out_x_4 = x, out_y_4 = y, "continue-loop2"; + } + else { + var _loop_8 = function(a_4) { + var f = function () { return a_4; }; + if (a_4) { + a_4 = x; + return out_a_4_1 = a_4, "continue-loop1"; + } + else { + y++; + return out_a_4_1 = a_4, "continue-loop2"; + } + out_a_4_1 = a_4; + }; + var out_a_4_1; + loop1: for (var a_4 = 1; a_4 < 5; --a_4) { + var state_7 = _loop_8(a_4); + a_4 = out_a_4_1; + switch(state_7) { + case "continue-loop1": continue loop1; + case "continue-loop2": return state_7; + } + } + y = 5; + } + out_x_4 = x; + out_y_4 = y; +}; +var out_x_4, out_y_4; +loop2: for (var x = 1, y = 2; x < y; ++x, --y) { + var state_8 = _loop_7(x, y); + x = out_x_4; + y = out_y_4; + switch(state_8) { + case "continue-loop2": continue loop2; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols new file mode 100644 index 00000000000..f78cd684c3a --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.symbols @@ -0,0 +1,203 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts === + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 2, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) + + break; + } + else { + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 8, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 7, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 8)) + + break; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 1, 15)) + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 24, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) + + continue; + } + else { + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 30, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 29, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 8)) + + continue; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 23, 15)) + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 46, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) + + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 53, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 52, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 8)) + + break loop1; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + + break loop2 + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 45, 15)) + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 70, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) + + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + let f = () => a; +>f : Symbol(f, Decl(blockScopedBindingsReassignedInLoop3.ts, 77, 15)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + if (a) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) + + a = x; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop3.ts, 76, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 8)) + + continue loop1; + } + else { + y++; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + + continue loop2 + } + } + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop3.ts, 69, 15)) + } +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types new file mode 100644 index 00000000000..0753391d5c2 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types @@ -0,0 +1,301 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts === + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break; + } + else { + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + break; + } + else { + y++; +>y++ : number +>y : number + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue; + } + else { + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + continue; + } + else { + y++; +>y++ : number +>y : number + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop2: +>loop2 : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + break loop2; +>loop2 : any + } + else { + loop1: +>loop1 : any + + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + break loop1; +>loop1 : any + } + else { + y++; +>y++ : number +>y : number + + break loop2 +>loop2 : any + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + +loop2: +>loop2 : any + +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + continue loop2; +>loop2 : any + } + else { + loop1: +>loop1 : any + + for (let a = 1; a < 5; --a) { +>a : number +>1 : number +>a < 5 : boolean +>a : number +>5 : number +>--a : number +>a : number + + let f = () => a; +>f : () => number +>() => a : () => number +>a : number + + if (a) { +>a : number + + a = x; +>a = x : number +>a : number +>x : number + + continue loop1; +>loop1 : any + } + else { + y++; +>y++ : number +>y : number + + continue loop2 +>loop2 : any + } + } + + y = 5; +>y = 5 : number +>y : number +>5 : number + } +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js new file mode 100644 index 00000000000..8bff867dc95 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.js @@ -0,0 +1,34 @@ +//// [blockScopedBindingsReassignedInLoop4.ts] +function f1() { + for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + return 1; + } + else { + y = 5; + } + } +} + +//// [blockScopedBindingsReassignedInLoop4.js] +function f1() { + var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) { + return { value: 1 }; + } + else { + y = 5; + } + out_x_1 = x; + out_y_1 = y; + }; + var out_x_1, out_y_1; + for (var x = 1, y = 2; x < y; ++x, --y) { + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (typeof state_1 === "object") return state_1.value; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols new file mode 100644 index 00000000000..90c63914b9f --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.symbols @@ -0,0 +1,28 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts === +function f1() { +>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop4.ts, 0, 0)) + + for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop4.ts, 2, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + + if (x == 1) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 12)) + + return 1; + } + else { + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop4.ts, 1, 19)) + } + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types new file mode 100644 index 00000000000..006f536ccca --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts === +function f1() { +>f1 : () => number + + for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) { +>x == 1 : boolean +>x : number +>1 : number + + return 1; +>1 : number + } + else { + y = 5; +>y = 5 : number +>y : number +>5 : number + } + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js new file mode 100644 index 00000000000..a891147317d --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.js @@ -0,0 +1,27 @@ +//// [blockScopedBindingsReassignedInLoop5.ts] +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else + y = 5; +} + + +//// [blockScopedBindingsReassignedInLoop5.js] +var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_1 = x, out_y_1 = y, "break"; + else + y = 5; + out_x_1 = x; + out_y_1 = y; +}; +var out_x_1, out_y_1; +for (var x = 1, y = 2; x < y; ++x, --y) { + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (state_1 === "break") break; +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols new file mode 100644 index 00000000000..0edc6abe34d --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop5.ts, 1, 7)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 8)) + + break; + else + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop5.ts, 0, 15)) +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types new file mode 100644 index 00000000000..530978dc722 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts === +for (let x = 1, y = 2; x < y; ++x, --y) { +>x : number +>1 : number +>y : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else + y = 5; +>y = 5 : number +>y : number +>5 : number +} + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js new file mode 100644 index 00000000000..a2a074ed4df --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js @@ -0,0 +1,74 @@ +//// [blockScopedBindingsReassignedInLoop6.ts] +function f1() { + for (let [x, y] = [1, 2]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + +function f2() { + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + + + + + + + +//// [blockScopedBindingsReassignedInLoop6.js] +function f1() { + var _loop_1 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_1 = x, out_y_1 = y, "break"; + else if (y == 2) + y = 5; + else + return { value: void 0 }; + out_x_1 = x; + out_y_1 = y; + }; + var out_x_1, out_y_1; + for (var _a = [1, 2], x = _a[0], y = _a[1]; x < y; ++x, --y) { + var state_1 = _loop_1(x, y); + x = out_x_1; + y = out_y_1; + if (typeof state_1 === "object") return state_1.value; + if (state_1 === "break") break; + } +} +function f2() { + var _loop_2 = function(x, y) { + var a = function () { return x++ + y++; }; + if (x == 1) + return out_x_2 = x, out_y_2 = y, "break"; + else if (y == 2) + y = 5; + else + return { value: void 0 }; + out_x_2 = x; + out_y_2 = y; + }; + var out_x_2, out_y_2; + for (var _a = [{ a: 1, b: { c: 2 } }][0], x = _a.a, y = _a.b.c; x < y; ++x, --y) { + var state_2 = _loop_2(x, y); + x = out_x_2; + y = out_y_2; + if (typeof state_2 === "object") return state_2.value; + if (state_2 === "break") break; + } +} diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols new file mode 100644 index 00000000000..8dda6eedd47 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.symbols @@ -0,0 +1,74 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts === +function f1() { +>f1 : Symbol(f1, Decl(blockScopedBindingsReassignedInLoop6.ts, 0, 0)) + + for (let [x, y] = [1, 2]; x < y; ++x, --y) { +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 2, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 14)) + + break; + else if (y == 2) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 1, 16)) + + else + return; + } +} + +function f2() { +>f2 : Symbol(f2, Decl(blockScopedBindingsReassignedInLoop6.ts, 10, 1)) + + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42)) +>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 37)) +>b : Symbol(b, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 42)) +>c : Symbol(c, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 47)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + let a = () => x++ + y++; +>a : Symbol(a, Decl(blockScopedBindingsReassignedInLoop6.ts, 14, 11)) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + if (x == 1) +>x : Symbol(x, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 15)) + + break; + else if (y == 2) +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + y = 5; +>y : Symbol(y, Decl(blockScopedBindingsReassignedInLoop6.ts, 13, 25)) + + else + return; + } +} + + + + + + diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types new file mode 100644 index 00000000000..673c0788a03 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types @@ -0,0 +1,110 @@ +=== tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts === +function f1() { +>f1 : () => void + + for (let [x, y] = [1, 2]; x < y; ++x, --y) { +>x : number +>y : number +>[1, 2] : [number, number] +>1 : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else if (y == 2) +>y == 2 : boolean +>y : number +>2 : number + + y = 5; +>y = 5 : number +>y : number +>5 : number + + else + return; + } +} + +function f2() { +>f2 : () => void + + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { +>a : any +>x : number +>b : any +>c : any +>y : number +>[{a: 1, b: {c: 2}}] : [{ a: number; b: { c: number; }; }] +>{a: 1, b: {c: 2}} : { a: number; b: { c: number; }; } +>a : number +>1 : number +>b : { c: number; } +>{c: 2} : { c: number; } +>c : number +>2 : number +>x < y : boolean +>x : number +>y : number +>++x, --y : number +>++x : number +>x : number +>--y : number +>y : number + + let a = () => x++ + y++; +>a : () => number +>() => x++ + y++ : () => number +>x++ + y++ : number +>x++ : number +>x : number +>y++ : number +>y : number + + if (x == 1) +>x == 1 : boolean +>x : number +>1 : number + + break; + else if (y == 2) +>y == 2 : boolean +>y : number +>2 : number + + y = 5; +>y = 5 : number +>y : number +>5 : number + + else + return; + } +} + + + + + + diff --git a/tests/baselines/reference/capturedLetConstInLoop11.js b/tests/baselines/reference/capturedLetConstInLoop11.js index fa295739d02..9190dd3ec02 100644 --- a/tests/baselines/reference/capturedLetConstInLoop11.js +++ b/tests/baselines/reference/capturedLetConstInLoop11.js @@ -30,6 +30,6 @@ function foo() { }; for (;;) { var state_2 = _loop_2(); - if (typeof state_2 === "object") return state_2.value + if (typeof state_2 === "object") return state_2.value; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop5.js b/tests/baselines/reference/capturedLetConstInLoop5.js index 7807edd122e..a1a4d4b0a8f 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.js +++ b/tests/baselines/reference/capturedLetConstInLoop5.js @@ -294,7 +294,7 @@ function foo0(x) { for (var _i = 0, _a = []; _i < _a.length; _i++) { var x_1 = _a[_i]; var state_1 = _loop_1(x_1); - if (typeof state_1 === "object") return state_1.value + if (typeof state_1 === "object") return state_1.value; } use(v); } @@ -310,7 +310,7 @@ function foo00(x) { var v; for (var x_2 in []) { var state_2 = _loop_2(x_2); - if (typeof state_2 === "object") return state_2.value + if (typeof state_2 === "object") return state_2.value; } use(v); } @@ -326,7 +326,7 @@ function foo1(x) { var v; for (var x_3 = 0; x_3 < 1; ++x_3) { var state_3 = _loop_3(x_3); - if (typeof state_3 === "object") return state_3.value + if (typeof state_3 === "object") return state_3.value; } use(v); } @@ -343,7 +343,7 @@ function foo2(x) { var v; while (1 === 1) { var state_4 = _loop_4(); - if (typeof state_4 === "object") return state_4.value + if (typeof state_4 === "object") return state_4.value; } use(v); } @@ -359,7 +359,7 @@ function foo3(x) { var v; do { var state_5 = _loop_5(); - if (typeof state_5 === "object") return state_5.value + if (typeof state_5 === "object") return state_5.value; } while (1 === 1); use(v); } @@ -376,7 +376,7 @@ function foo4(x) { var v; for (var y = 0; y < 1; ++y) { var state_6 = _loop_6(y); - if (typeof state_6 === "object") return state_6.value + if (typeof state_6 === "object") return state_6.value; } use(v); } @@ -392,7 +392,7 @@ function foo5(x) { var v; for (var x_7 = 0, y = 1; x_7 < 1; ++x_7) { var state_7 = _loop_7(x_7, y); - if (typeof state_7 === "object") return state_7.value + if (typeof state_7 === "object") return state_7.value; } use(v); } @@ -409,7 +409,7 @@ function foo6(x) { var v; while (1 === 1) { var state_8 = _loop_8(); - if (typeof state_8 === "object") return state_8.value + if (typeof state_8 === "object") return state_8.value; } ; use(v); @@ -427,7 +427,7 @@ function foo7(x) { var v; do { var state_9 = _loop_9(); - if (typeof state_9 === "object") return state_9.value + if (typeof state_9 === "object") return state_9.value; } while (1 === 1); use(v); } @@ -444,7 +444,7 @@ function foo8(x) { var v; for (var y = 0; y < 1; ++y) { var state_10 = _loop_10(y); - if (typeof state_10 === "object") return state_10.value + if (typeof state_10 === "object") return state_10.value; } use(v); } @@ -462,7 +462,7 @@ function foo0_c(x) { for (var _i = 0, _a = []; _i < _a.length; _i++) { var x_11 = _a[_i]; var state_11 = _loop_11(x_11); - if (typeof state_11 === "object") return state_11.value + if (typeof state_11 === "object") return state_11.value; } use(v); } @@ -478,7 +478,7 @@ function foo00_c(x) { var v; for (var x_12 in []) { var state_12 = _loop_12(x_12); - if (typeof state_12 === "object") return state_12.value + if (typeof state_12 === "object") return state_12.value; } use(v); } @@ -494,7 +494,7 @@ function foo1_c(x) { var v; for (var x_13 = 0; x_13 < 1;) { var state_13 = _loop_13(x_13); - if (typeof state_13 === "object") return state_13.value + if (typeof state_13 === "object") return state_13.value; } use(v); } @@ -511,7 +511,7 @@ function foo2_c(x) { var v; while (1 === 1) { var state_14 = _loop_14(); - if (typeof state_14 === "object") return state_14.value + if (typeof state_14 === "object") return state_14.value; } use(v); } @@ -527,7 +527,7 @@ function foo3_c(x) { var v; do { var state_15 = _loop_15(); - if (typeof state_15 === "object") return state_15.value + if (typeof state_15 === "object") return state_15.value; } while (1 === 1); use(v); } @@ -544,7 +544,7 @@ function foo4_c(x) { var v; for (var y = 0; y < 1;) { var state_16 = _loop_16(y); - if (typeof state_16 === "object") return state_16.value + if (typeof state_16 === "object") return state_16.value; } use(v); } @@ -560,7 +560,7 @@ function foo5_c(x) { var v; for (var x_17 = 0, y = 1; x_17 < 1;) { var state_17 = _loop_17(x_17, y); - if (typeof state_17 === "object") return state_17.value + if (typeof state_17 === "object") return state_17.value; } use(v); } @@ -577,7 +577,7 @@ function foo6_c(x) { var v; while (1 === 1) { var state_18 = _loop_18(); - if (typeof state_18 === "object") return state_18.value + if (typeof state_18 === "object") return state_18.value; } use(v); } @@ -594,7 +594,7 @@ function foo7_c(x) { var v; do { var state_19 = _loop_19(); - if (typeof state_19 === "object") return state_19.value + if (typeof state_19 === "object") return state_19.value; } while (1 === 1); use(v); } @@ -611,7 +611,7 @@ function foo8_c(x) { var v; for (var y = 0; y < 1;) { var state_20 = _loop_20(y); - if (typeof state_20 === "object") return state_20.value + if (typeof state_20 === "object") return state_20.value; } use(v); } diff --git a/tests/baselines/reference/capturedLetConstInLoop8.js b/tests/baselines/reference/capturedLetConstInLoop8.js index b10beb7b44e..560b99bb566 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8.js +++ b/tests/baselines/reference/capturedLetConstInLoop8.js @@ -198,7 +198,7 @@ function foo() { }; l1: for (var x = 0; x < 1; ++x) { var state_2 = _loop_1(x); - if (typeof state_2 === "object") return state_2.value + if (typeof state_2 === "object") return state_2.value; if (state_2 === "break") break; if (state_2 === "continue") continue; switch(state_2) { @@ -280,7 +280,7 @@ function foo_c() { }; l1: for (var x = 0; x < 1;) { var state_4 = _loop_3(x); - if (typeof state_4 === "object") return state_4.value + if (typeof state_4 === "object") return state_4.value; if (state_4 === "break") break; if (state_4 === "continue") continue; switch(state_4) { diff --git a/tests/baselines/reference/capturedLetConstInLoop9.js b/tests/baselines/reference/capturedLetConstInLoop9.js index cbd4f7efe79..1f79b1694cb 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9.js +++ b/tests/baselines/reference/capturedLetConstInLoop9.js @@ -225,7 +225,7 @@ function foo() { l0: for (var _f = 0, _g = []; _f < _g.length; _f++) { var a = _g[_f]; var state_4 = _loop_3(a); - if (typeof state_4 === "object") return state_4.value + if (typeof state_4 === "object") return state_4.value; if (state_4 === "break") break; switch(state_4) { case "break-l0": break l0; diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js new file mode 100644 index 00000000000..88ce3f1418b --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.js @@ -0,0 +1,37 @@ +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + + +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B(x) { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.x = x; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols new file mode 100644 index 00000000000..3931a7115f6 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 6, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types new file mode 100644 index 00000000000..cfdf0af0300 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..2e594dba0ec --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js @@ -0,0 +1,29 @@ +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + + +//// [emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor(x) { + "use strict"; + 'someStringForEgngInject'; + super(); + this.x = x; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..8b8c09f2611 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 6, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..4424042c241 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} + diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js new file mode 100644 index 00000000000..920ad1f7bda --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.js @@ -0,0 +1,39 @@ +//// [emitSuperCallBeforeEmitPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.blub = 12; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols new file mode 100644 index 00000000000..0b118b7c991 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + + blub = 12; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 5, 19)) + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types new file mode 100644 index 00000000000..2d16fed121d --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blub = 12; +>blub : number +>12 : number + + constructor() { + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..4b3e9e73b9f --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.js @@ -0,0 +1,29 @@ +//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor() { + 'someStringForEgngInject'; + super(); + this.blub = 12; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..4d4b01a3666 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 12; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 5, 19)) + + constructor() { + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..39e8f885777 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blub = 12; +>blub : number +>12 : number + + constructor() { + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js new file mode 100644 index 00000000000..3fa18140034 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js @@ -0,0 +1,38 @@ +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts] +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + this.blub = 6; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B(x) { + "use strict"; + 'someStringForEgngInject'; + _super.call(this); + this.x = x; + this.blah = 2; + } + return B; +}(A)); diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols new file mode 100644 index 00000000000..1fb4ed01d85 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + + blah = 2; +>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 5, 19)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 7, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types new file mode 100644 index 00000000000..acb5703581a --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blah = 2; +>blah : number +>2 : number + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js new file mode 100644 index 00000000000..5e27acf8d9a --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js @@ -0,0 +1,30 @@ +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts] +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} + +//// [emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.js] +class A { + constructor() { + this.blub = 6; + } +} +class B extends A { + constructor(x) { + "use strict"; + 'someStringForEgngInject'; + super(); + this.x = x; + this.blah = 2; + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols new file mode 100644 index 00000000000..41cb20f3841 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts === +class A { +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blub = 6; +>blub : Symbol(blub, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 9)) +} + + +class B extends A { +>B : Symbol(B, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 2, 1)) +>A : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + + blah = 2; +>blah : Symbol(blah, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 5, 19)) + + constructor(public x: number) { +>x : Symbol(x, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 7, 16)) + + "use strict"; + 'someStringForEgngInject'; + super() +>super : Symbol(A, Decl(emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types new file mode 100644 index 00000000000..96fc1fc2dc3 --- /dev/null +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts === +class A { +>A : A + + blub = 6; +>blub : number +>6 : number +} + + +class B extends A { +>B : B +>A : A + + blah = 2; +>blah : number +>2 : number + + constructor(public x: number) { +>x : number + + "use strict"; +>"use strict" : string + + 'someStringForEgngInject'; +>'someStringForEgngInject' : string + + super() +>super() : void +>super : typeof A + } +} diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.js b/tests/baselines/reference/es6ImportWithoutFromClause.js index 9666409b924..cc8509baade 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.js +++ b/tests/baselines/reference/es6ImportWithoutFromClause.js @@ -17,3 +17,4 @@ import "es6ImportWithoutFromClause_0"; //// [es6ImportWithoutFromClause_0.d.ts] export declare var a: number; //// [es6ImportWithoutFromClause_1.d.ts] +import "es6ImportWithoutFromClause_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js index 39b6b04464c..ea533a9a963 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.js @@ -36,3 +36,5 @@ export declare var a: number; //// [es6ImportWithoutFromClauseAmd_1.d.ts] export declare var b: number; //// [es6ImportWithoutFromClauseAmd_2.d.ts] +import "es6ImportWithoutFromClauseAmd_0"; +import "es6ImportWithoutFromClauseAmd_2"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js index c39cd1172a0..d0f7c9fbe65 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.js @@ -18,3 +18,4 @@ require("es6ImportWithoutFromClauseInEs5_0"); //// [es6ImportWithoutFromClauseInEs5_0.d.ts] export declare var a: number; //// [es6ImportWithoutFromClauseInEs5_1.d.ts] +import "es6ImportWithoutFromClauseInEs5_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js index e63dd4bb53a..51bb0f3338d 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js +++ b/tests/baselines/reference/es6ImportWithoutFromClauseNonInstantiatedModule.js @@ -17,3 +17,4 @@ import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; export interface i { } //// [es6ImportWithoutFromClauseNonInstantiatedModule_1.d.ts] +import "es6ImportWithoutFromClauseNonInstantiatedModule_0"; diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.js b/tests/baselines/reference/jsxPreserveWithJsInput.js new file mode 100644 index 00000000000..2cc59ffa355 --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxPreserveWithJsInput.ts] //// + +//// [a.js] + +var elemA = 42; + +//// [b.jsx] +var elemB = {"test"}; + +//// [c.js] +var elemC = {42}; + +//// [d.ts] +var elemD = 42; + +//// [e.tsx] +var elemE = {true}; + + +//// [a.js] +var elemA = 42; +//// [b.jsx] +var elemB = {"test"}; +//// [c.js] +var elemC = {42}; +//// [d.js] +var elemD = 42; +//// [e.jsx] +var elemE = {true}; diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.symbols b/tests/baselines/reference/jsxPreserveWithJsInput.symbols new file mode 100644 index 00000000000..6ad2f614875 --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/a.js === + +var elemA = 42; +>elemA : Symbol(elemA, Decl(a.js, 1, 3)) + +=== tests/cases/compiler/b.jsx === +var elemB = {"test"}; +>elemB : Symbol(elemB, Decl(b.jsx, 0, 3)) +>b : Symbol(unknown) +>b : Symbol(unknown) + +=== tests/cases/compiler/c.js === +var elemC = {42}; +>elemC : Symbol(elemC, Decl(c.js, 0, 3)) +>c : Symbol(unknown) +>c : Symbol(unknown) + +=== tests/cases/compiler/d.ts === +var elemD = 42; +>elemD : Symbol(elemD, Decl(d.ts, 0, 3)) + +=== tests/cases/compiler/e.tsx === +var elemE = {true}; +>elemE : Symbol(elemE, Decl(e.tsx, 0, 3)) +>e : Symbol(unknown) +>e : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.types b/tests/baselines/reference/jsxPreserveWithJsInput.types new file mode 100644 index 00000000000..7f4ed6daa2b --- /dev/null +++ b/tests/baselines/reference/jsxPreserveWithJsInput.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/a.js === + +var elemA = 42; +>elemA : number +>42 : number + +=== tests/cases/compiler/b.jsx === +var elemB = {"test"}; +>elemB : any +>{"test"} : any +>b : any +>"test" : string +>b : any + +=== tests/cases/compiler/c.js === +var elemC = {42}; +>elemC : any +>{42} : any +>c : any +>42 : number +>c : any + +=== tests/cases/compiler/d.ts === +var elemD = 42; +>elemD : number +>42 : number + +=== tests/cases/compiler/e.tsx === +var elemE = {true}; +>elemE : any +>{true} : any +>e : any +>true : boolean +>e : any + diff --git a/tests/baselines/reference/keepImportsInDts1.js b/tests/baselines/reference/keepImportsInDts1.js new file mode 100644 index 00000000000..8189ce43088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/keepImportsInDts1.ts] //// + +//// [test.d.ts] + +export {}; +//// [main.ts] +import "test" + +//// [main.js] +define(["require", "exports", "test"], function (require, exports) { + "use strict"; +}); + + +//// [main.d.ts] +import "test"; diff --git a/tests/baselines/reference/keepImportsInDts1.symbols b/tests/baselines/reference/keepImportsInDts1.symbols new file mode 100644 index 00000000000..92bd84c2088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.symbols @@ -0,0 +1,6 @@ +=== c:/test.d.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts1.types b/tests/baselines/reference/keepImportsInDts1.types new file mode 100644 index 00000000000..92bd84c2088 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts1.types @@ -0,0 +1,6 @@ +=== c:/test.d.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts2.js b/tests/baselines/reference/keepImportsInDts2.js new file mode 100644 index 00000000000..559b4814526 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/keepImportsInDts2.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "./folder/test" + +//// [test.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [main.js] +define(["require", "exports", "./folder/test"], function (require, exports) { + "use strict"; +}); + + +//// [test.d.ts] +export { }; +//// [main.d.ts] +import "./folder/test"; diff --git a/tests/baselines/reference/keepImportsInDts2.symbols b/tests/baselines/reference/keepImportsInDts2.symbols new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts2.types b/tests/baselines/reference/keepImportsInDts2.types new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts2.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts3.js b/tests/baselines/reference/keepImportsInDts3.js new file mode 100644 index 00000000000..e48ba693726 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/keepImportsInDts3.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "test" + +//// [outputfile.js] +define("test", ["require", "exports"], function (require, exports) { + "use strict"; +}); +define("app/main", ["require", "exports", "test"], function (require, exports) { + "use strict"; +}); + + +//// [outputfile.d.ts] +declare module "test" { + export { }; +} +declare module "app/main" { + import "test"; +} diff --git a/tests/baselines/reference/keepImportsInDts3.symbols b/tests/baselines/reference/keepImportsInDts3.symbols new file mode 100644 index 00000000000..29c4a4e44b4 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.symbols @@ -0,0 +1,6 @@ +=== c:/test.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts3.types b/tests/baselines/reference/keepImportsInDts3.types new file mode 100644 index 00000000000..29c4a4e44b4 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts3.types @@ -0,0 +1,6 @@ +=== c:/test.ts === + +No type information for this code.export {}; +No type information for this code.=== c:/app/main.ts === +import "test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts4.js b/tests/baselines/reference/keepImportsInDts4.js new file mode 100644 index 00000000000..badec87984e --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/keepImportsInDts4.ts] //// + +//// [test.ts] + +export {}; +//// [main.ts] +import "./folder/test" + +//// [outputfile.js] +define("folder/test", ["require", "exports"], function (require, exports) { + "use strict"; +}); +define("main", ["require", "exports", "folder/test"], function (require, exports) { + "use strict"; +}); + + +//// [outputfile.d.ts] +declare module "folder/test" { + export { }; +} +declare module "main" { + import "folder/test"; +} diff --git a/tests/baselines/reference/keepImportsInDts4.symbols b/tests/baselines/reference/keepImportsInDts4.symbols new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/keepImportsInDts4.types b/tests/baselines/reference/keepImportsInDts4.types new file mode 100644 index 00000000000..ce6f4c7c168 --- /dev/null +++ b/tests/baselines/reference/keepImportsInDts4.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/folder/test.ts === + +No type information for this code.export {}; +No type information for this code.=== tests/cases/compiler/main.ts === +import "./folder/test" +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js index 60ba2217349..2e84e1492be 100644 --- a/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js +++ b/tests/baselines/reference/moduleAugmentationCollidingNamesInAugmentation1.js @@ -73,3 +73,5 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map1"; +import "./map2"; diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js index 589d0f506e9..7b44fb7a637 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.js @@ -66,3 +66,4 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js index d8fd65a1464..547d017c502 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.js @@ -71,3 +71,4 @@ declare module "./observable" { } export {}; //// [main.d.ts] +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js index 733f88e6129..2d65953e2a3 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.js @@ -63,3 +63,4 @@ declare module "observable" { export {}; //// [main.d.ts] /// +import "./map"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.js b/tests/baselines/reference/moduleAugmentationGlobal3.js index 4cff75f5df0..caa080a558c 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal3.js +++ b/tests/baselines/reference/moduleAugmentationGlobal3.js @@ -50,3 +50,4 @@ declare global { } export {}; //// [f3.d.ts] +import "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.js b/tests/baselines/reference/moduleAugmentationGlobal4.js index 11c5d968df2..38f186d0e05 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal4.js +++ b/tests/baselines/reference/moduleAugmentationGlobal4.js @@ -45,3 +45,5 @@ declare global { export { }; export {}; //// [f3.d.ts] +import "./f1"; +import "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.js b/tests/baselines/reference/moduleAugmentationGlobal5.js index 3efdd2dbb98..70c81893bd8 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal5.js +++ b/tests/baselines/reference/moduleAugmentationGlobal5.js @@ -32,3 +32,5 @@ require("B"); //// [f3.d.ts] /// /// +import "A"; +import "B"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js index 7159e7b5d0c..8e0b7dad19d 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js @@ -69,3 +69,4 @@ declare module "./f1" { } } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index 3a4a807a334..498df8ab90e 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -74,3 +74,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index d872a79e985..8d9e69c5076 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -72,3 +72,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index c9b622ccf25..c3cba4c01f8 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -76,3 +76,4 @@ export declare class B { n: number; } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js index f0b297720b3..f5aff705eb4 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js @@ -95,3 +95,4 @@ declare module "./f1" { } } //// [f4.d.ts] +import "./f3"; diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js index fab9cebb179..2e6503c4774 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.js +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.js @@ -33,3 +33,4 @@ var y = x.getA().x; //// [f.d.ts] /// +import "array"; diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js index 92916206e76..504c015bcb8 100644 --- a/tests/baselines/reference/moduleAugmentationsBundledOutput1.js +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.js @@ -139,4 +139,6 @@ declare module "m4" { } } declare module "test" { + import "m2"; + import "m4"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports1.js b/tests/baselines/reference/moduleAugmentationsImports1.js index 2c635a0719e..922bb61d952 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.js +++ b/tests/baselines/reference/moduleAugmentationsImports1.js @@ -101,4 +101,5 @@ declare module "d" { } } declare module "main" { + import "d"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports2.js b/tests/baselines/reference/moduleAugmentationsImports2.js index f70426b49bd..605a07e29e1 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.js +++ b/tests/baselines/reference/moduleAugmentationsImports2.js @@ -111,4 +111,6 @@ declare module "e" { } } declare module "main" { + import "d"; + import "e"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports3.js b/tests/baselines/reference/moduleAugmentationsImports3.js index 3654583b5c9..0a946f42be3 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.js +++ b/tests/baselines/reference/moduleAugmentationsImports3.js @@ -98,4 +98,6 @@ declare module "e" { } } declare module "main" { + import "D"; + import "e"; } diff --git a/tests/baselines/reference/moduleAugmentationsImports4.js b/tests/baselines/reference/moduleAugmentationsImports4.js index 9b64016113f..a48bbb04631 100644 --- a/tests/baselines/reference/moduleAugmentationsImports4.js +++ b/tests/baselines/reference/moduleAugmentationsImports4.js @@ -87,4 +87,6 @@ declare module "b" { } } declare module "main" { + import "D"; + import "E"; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings3.js b/tests/baselines/reference/nestedBlockScopedBindings3.js index 97fba2da301..f9474381816 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings3.js +++ b/tests/baselines/reference/nestedBlockScopedBindings3.js @@ -123,9 +123,12 @@ function a4() { var _loop_5 = function(x) { x = x + 1; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0; x < 1;) { _loop_5(x); + x = out_x_1; } switch (1) { case 1: @@ -137,9 +140,12 @@ function a5() { var _loop_6 = function(x) { x = x + 1; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0; x < 1;) { _loop_6(x); + x = out_x_2; } switch (1) { case 1: diff --git a/tests/baselines/reference/nestedBlockScopedBindings4.js b/tests/baselines/reference/nestedBlockScopedBindings4.js index 51cddcf676d..6b391070d93 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings4.js +++ b/tests/baselines/reference/nestedBlockScopedBindings4.js @@ -53,9 +53,12 @@ function a1() { var _loop_1 = function(x) { x = x + 1; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0; x < 1;) { _loop_1(x); + x = out_x_1; } for (var x = void 0;;) { x = x + 2; @@ -68,24 +71,33 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0;;) { _loop_2(x); + x = out_x_2; } } function a3() { var _loop_3 = function(x) { x = x + 1; (function () { return x; }); + out_x_3 = x; }; + var out_x_3; for (var x = void 0; x < 1;) { _loop_3(x); + x = out_x_3; } var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_4 = x; }; + var out_x_4; for (var x = void 0;;) { _loop_4(x); + x = out_x_4; } } diff --git a/tests/baselines/reference/nestedBlockScopedBindings5.js b/tests/baselines/reference/nestedBlockScopedBindings5.js index c80c72c0ed6..df4fcf76423 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings5.js +++ b/tests/baselines/reference/nestedBlockScopedBindings5.js @@ -108,9 +108,12 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0;;) { _loop_2(x); + x = out_x_1; } } function a3() { @@ -124,9 +127,12 @@ function a3() { var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0; false;) { _loop_4(x); + x = out_x_2; } switch (1) { case 1: @@ -157,9 +163,12 @@ function a5() { var _loop_5 = function(x) { x = x + 2; (function () { return x; }); + out_x_3 = x; }; + var out_x_3; for (var x = void 0; false;) { _loop_5(x); + x = out_x_3; } switch (1) { case 1: diff --git a/tests/baselines/reference/nestedBlockScopedBindings6.js b/tests/baselines/reference/nestedBlockScopedBindings6.js index 78207b98fcd..be9771471e9 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings6.js +++ b/tests/baselines/reference/nestedBlockScopedBindings6.js @@ -119,9 +119,12 @@ function a2() { var _loop_2 = function(x) { x = x + 2; (function () { return x; }); + out_x_1 = x; }; + var out_x_1; for (var x = void 0;;) { _loop_2(x); + x = out_x_1; } } function a3() { @@ -136,9 +139,12 @@ function a3() { var _loop_4 = function(x) { x = x + 2; (function () { return x; }); + out_x_2 = x; }; + var out_x_2; for (var x = void 0;;) { _loop_4(x); + x = out_x_2; } } function a4() { diff --git a/tests/baselines/reference/noErrorOnEmptyDts.js b/tests/baselines/reference/noErrorOnEmptyDts.js deleted file mode 100644 index 83595e3d2ad..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [tests/cases/compiler/noErrorOnEmptyDts.ts] //// - -//// [test.d.ts] - - -// comment - -//// [main.ts] -import "test" - -//// [main.js] -"use strict"; -require("test"); diff --git a/tests/baselines/reference/noErrorOnEmptyDts.symbols b/tests/baselines/reference/noErrorOnEmptyDts.symbols deleted file mode 100644 index 78446a19fb8..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== c:/node_modules/test.d.ts === - -No type information for this code. -No type information for this code.// comment -No type information for this code. -No type information for this code.=== c:/app/main.ts === -import "test" -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/noErrorOnEmptyDts.types b/tests/baselines/reference/noErrorOnEmptyDts.types deleted file mode 100644 index 78446a19fb8..00000000000 --- a/tests/baselines/reference/noErrorOnEmptyDts.types +++ /dev/null @@ -1,8 +0,0 @@ -=== c:/node_modules/test.d.ts === - -No type information for this code. -No type information for this code.// comment -No type information for this code. -No type information for this code.=== c:/app/main.ts === -import "test" -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.js b/tests/baselines/reference/noImplicitUseStrict_amd.js new file mode 100644 index 00000000000..ac15f548c47 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_amd.js @@ -0,0 +1,8 @@ +//// [noImplicitUseStrict_amd.ts] + +export var x = 0; + +//// [noImplicitUseStrict_amd.js] +define(["require", "exports"], function (require, exports) { + exports.x = 0; +}); diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.symbols b/tests/baselines/reference/noImplicitUseStrict_amd.symbols new file mode 100644 index 00000000000..de1faa2213c --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_amd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_amd.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_amd.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.types b/tests/baselines/reference/noImplicitUseStrict_amd.types new file mode 100644 index 00000000000..c9e1b5749dc --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_amd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_amd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.js b/tests/baselines/reference/noImplicitUseStrict_commonjs.js new file mode 100644 index 00000000000..9c726938f04 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.js @@ -0,0 +1,6 @@ +//// [noImplicitUseStrict_commonjs.ts] + +export var x = 0; + +//// [noImplicitUseStrict_commonjs.js] +exports.x = 0; diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols b/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols new file mode 100644 index 00000000000..af53dc272d2 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_commonjs.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.types b/tests/baselines/reference/noImplicitUseStrict_commonjs.types new file mode 100644 index 00000000000..9999d3b94ba --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_commonjs.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.js b/tests/baselines/reference/noImplicitUseStrict_es6.js new file mode 100644 index 00000000000..27dbbc7ea79 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.js @@ -0,0 +1,6 @@ +//// [noImplicitUseStrict_es6.ts] + +export var x = 0; + +//// [noImplicitUseStrict_es6.js] +export var x = 0; diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.symbols b/tests/baselines/reference/noImplicitUseStrict_es6.symbols new file mode 100644 index 00000000000..31bc1904ff9 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_es6.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_es6.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.types b/tests/baselines/reference/noImplicitUseStrict_es6.types new file mode 100644 index 00000000000..838c7316be0 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_es6.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_system.js b/tests/baselines/reference/noImplicitUseStrict_system.js new file mode 100644 index 00000000000..cf5a7e1b261 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_system.js @@ -0,0 +1,15 @@ +//// [noImplicitUseStrict_system.ts] + +export var x = 0; + +//// [noImplicitUseStrict_system.js] +System.register([], function(exports_1, context_1) { + var __moduleName = context_1 && context_1.id; + var x; + return { + setters:[], + execute: function() { + exports_1("x", x = 0); + } + } +}); diff --git a/tests/baselines/reference/noImplicitUseStrict_system.symbols b/tests/baselines/reference/noImplicitUseStrict_system.symbols new file mode 100644 index 00000000000..62b89a6593d --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_system.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_system.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_system.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_system.types b/tests/baselines/reference/noImplicitUseStrict_system.types new file mode 100644 index 00000000000..1da563f938b --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_system.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_system.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.js b/tests/baselines/reference/noImplicitUseStrict_umd.js new file mode 100644 index 00000000000..ca252daeb9d --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_umd.js @@ -0,0 +1,15 @@ +//// [noImplicitUseStrict_umd.ts] + +export var x = 0; + +//// [noImplicitUseStrict_umd.js] +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + exports.x = 0; +}); diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.symbols b/tests/baselines/reference/noImplicitUseStrict_umd.symbols new file mode 100644 index 00000000000..a72a251ad09 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_umd.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/noImplicitUseStrict_umd.ts === + +export var x = 0; +>x : Symbol(x, Decl(noImplicitUseStrict_umd.ts, 1, 10)) + diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.types b/tests/baselines/reference/noImplicitUseStrict_umd.types new file mode 100644 index 00000000000..6a3fd6ece77 --- /dev/null +++ b/tests/baselines/reference/noImplicitUseStrict_umd.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noImplicitUseStrict_umd.ts === + +export var x = 0; +>x : number +>0 : number + diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 3b315861548..bcfbdf22414 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -75,8 +75,8 @@ var B = (function (_super) { __extends(B, _super); function B() { "use strict"; // No error - this.s = 9; _super.call(this); + this.s = 9; } return B; }(A)); diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts new file mode 100644 index 00000000000..e052702bce2 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop1.ts @@ -0,0 +1,7 @@ +declare function use(n: number): void; +(function () { + 'use strict' + for (let i = 0; i < 9; ++i) { + (() => use(++i))(); + } +})(); \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts new file mode 100644 index 00000000000..84d9f8d214b --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts @@ -0,0 +1,41 @@ +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + y = 5; + } +} + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop; + } + else { + y = 5; + } +} + +loop: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop; + } + else { + y = 5; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts new file mode 100644 index 00000000000..a68c708193a --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop3.ts @@ -0,0 +1,91 @@ + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break; + } + else { + y++; + } + } + + y = 5; + } +} + + +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue; + } + else { + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue; + } + else { + y++; + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + break loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + break loop1; + } + else { + y++; + break loop2 + } + } + + y = 5; + } +} + +loop2: +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + continue loop2; + } + else { + loop1: + for (let a = 1; a < 5; --a) { + let f = () => a; + if (a) { + a = x; + continue loop1; + } + else { + y++; + continue loop2 + } + } + + y = 5; + } +} diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts new file mode 100644 index 00000000000..82f4bcc5dd0 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop4.ts @@ -0,0 +1,11 @@ +function f1() { + for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) { + return 1; + } + else { + y = 5; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts new file mode 100644 index 00000000000..c6c577ea9fb --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts @@ -0,0 +1,7 @@ +for (let x = 1, y = 2; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else + y = 5; +} diff --git a/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts b/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts new file mode 100644 index 00000000000..e735bb61ac8 --- /dev/null +++ b/tests/cases/compiler/blockScopedBindingsReassignedInLoop6.ts @@ -0,0 +1,28 @@ +function f1() { + for (let [x, y] = [1, 2]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + +function f2() { + for (let [{a: x, b: {c: y}}] = [{a: 1, b: {c: 2}}]; x < y; ++x, --y) { + let a = () => x++ + y++; + if (x == 1) + break; + else if (y == 2) + y = 5; + else + return; + } +} + + + + + diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts new file mode 100644 index 00000000000..5172ccfe21f --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1.ts @@ -0,0 +1,12 @@ +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..e62f753d725 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.ts @@ -0,0 +1,13 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts new file mode 100644 index 00000000000..52d41c3731a --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1.ts @@ -0,0 +1,15 @@ +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..f6c7164ae75 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclaration1ES6.ts @@ -0,0 +1,15 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + + blub = 12; + + constructor() { + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts new file mode 100644 index 00000000000..a2d8bf8473f --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.ts @@ -0,0 +1,13 @@ +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts new file mode 100644 index 00000000000..8bd8420f8f7 --- /dev/null +++ b/tests/cases/compiler/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.ts @@ -0,0 +1,14 @@ +// @target: ES6 +class A { + blub = 6; +} + + +class B extends A { + blah = 2; + constructor(public x: number) { + "use strict"; + 'someStringForEgngInject'; + super() + } +} \ No newline at end of file diff --git a/tests/cases/compiler/jsxPreserveWithJsInput.ts b/tests/cases/compiler/jsxPreserveWithJsInput.ts new file mode 100644 index 00000000000..f229e40a550 --- /dev/null +++ b/tests/cases/compiler/jsxPreserveWithJsInput.ts @@ -0,0 +1,18 @@ +// @outdir: out +// @jsx: preserve +// @allowjs: true + +// @filename: a.js +var elemA = 42; + +// @filename: b.jsx +var elemB = {"test"}; + +// @filename: c.js +var elemC = {42}; + +// @filename: d.ts +var elemD = 42; + +// @filename: e.tsx +var elemE = {true}; diff --git a/tests/cases/compiler/keepImportsInDts1.ts b/tests/cases/compiler/keepImportsInDts1.ts new file mode 100644 index 00000000000..50bdc5830a8 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts1.ts @@ -0,0 +1,7 @@ +// @module: amd +// @declaration: true + +// @filename: c:/test.d.ts +export {}; +// @filename: c:/app/main.ts +import "test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts2.ts b/tests/cases/compiler/keepImportsInDts2.ts new file mode 100644 index 00000000000..407526d7595 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts2.ts @@ -0,0 +1,7 @@ +// @module: amd +// @declaration: true + +// @filename: folder/test.ts +export {}; +// @filename: main.ts +import "./folder/test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts3.ts b/tests/cases/compiler/keepImportsInDts3.ts new file mode 100644 index 00000000000..cdd83dce132 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts3.ts @@ -0,0 +1,8 @@ +// @module: amd +// @declaration: true +// @out: outputfile.js + +// @filename: c:/test.ts +export {}; +// @filename: c:/app/main.ts +import "test" \ No newline at end of file diff --git a/tests/cases/compiler/keepImportsInDts4.ts b/tests/cases/compiler/keepImportsInDts4.ts new file mode 100644 index 00000000000..272932be488 --- /dev/null +++ b/tests/cases/compiler/keepImportsInDts4.ts @@ -0,0 +1,8 @@ +// @module: amd +// @declaration: true +// @out: outputfile.js + +// @filename: folder/test.ts +export {}; +// @filename: main.ts +import "./folder/test" \ No newline at end of file diff --git a/tests/cases/compiler/noErrorOnEmptyDts.ts b/tests/cases/compiler/noErrorOnEmptyDts.ts deleted file mode 100644 index 1266ea2bd75..00000000000 --- a/tests/cases/compiler/noErrorOnEmptyDts.ts +++ /dev/null @@ -1,8 +0,0 @@ -// @module: commonjs - -// @filename: c:/node_modules/test.d.ts - -// comment - -// @filename: c:/app/main.ts -import "test" \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_amd.ts b/tests/cases/compiler/noImplicitUseStrict_amd.ts new file mode 100644 index 00000000000..3a2a4760221 --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_amd.ts @@ -0,0 +1,4 @@ +// @module: amd +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_commonjs.ts b/tests/cases/compiler/noImplicitUseStrict_commonjs.ts new file mode 100644 index 00000000000..f8377dba07a --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_commonjs.ts @@ -0,0 +1,4 @@ +// @module: commonjs +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_es6.ts b/tests/cases/compiler/noImplicitUseStrict_es6.ts new file mode 100644 index 00000000000..f56b0fd9021 --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_es6.ts @@ -0,0 +1,5 @@ +// @module: es6 +// @target: es6 +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_system.ts b/tests/cases/compiler/noImplicitUseStrict_system.ts new file mode 100644 index 00000000000..37ff5de469d --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_system.ts @@ -0,0 +1,4 @@ +// @module: system +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitUseStrict_umd.ts b/tests/cases/compiler/noImplicitUseStrict_umd.ts new file mode 100644 index 00000000000..f26f2ee2aff --- /dev/null +++ b/tests/cases/compiler/noImplicitUseStrict_umd.ts @@ -0,0 +1,4 @@ +// @module: umd +// @noImplicitUseStrict: true + +export var x = 0; \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions16.ts b/tests/cases/fourslash/getJavaScriptCompletions16.ts new file mode 100644 index 00000000000..4d4b76d98d6 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions16.ts @@ -0,0 +1,35 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// "use strict"; +//// +//// class Something { +//// +//// /** +//// * @param {number} a +//// */ +//// constructor(a, b) { +//// a/*body*/ +//// } +//// +//// /** +//// * @param {number} a +//// */ +//// method(a) { +//// a/*method*/ +//// } +//// } +//// let x = new Something(/*sig*/); + +goTo.marker('body'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); +edit.backspace(); + +goTo.marker('sig'); +verify.currentSignatureHelpIs('Something(a: number, b: any): Something'); + +goTo.marker('method'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); diff --git a/tests/cases/fourslash/getJavaScriptCompletions18.ts b/tests/cases/fourslash/getJavaScriptCompletions18.ts new file mode 100644 index 00000000000..a30d4943f4f --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions18.ts @@ -0,0 +1,21 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// /** +//// * @param {number} a +//// * @param {string} b +//// */ +//// exports.foo = function(a, b) { +//// a/*a*/; +//// b/*b*/ +//// }; + +goTo.marker('a'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); + + +goTo.marker('b'); +edit.insert('.'); +verify.completionListContains('substr', undefined, undefined, 'method'); diff --git a/tests/cases/fourslash/getJavaScriptCompletions19.ts b/tests/cases/fourslash/getJavaScriptCompletions19.ts new file mode 100644 index 00000000000..5a361930e86 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions19.ts @@ -0,0 +1,25 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// function fn() { +//// if (foo) { +//// return 0; +//// } else { +//// return '0'; +//// } +//// } +//// let x = fn(); +//// if(typeof x === 'string') { +//// x/*str*/ +//// } else { +//// x/*num*/ +//// } + +goTo.marker('str'); +edit.insert('.'); +verify.completionListContains('substr', undefined, undefined, 'method'); + +goTo.marker('num'); +edit.insert('.'); +verify.completionListContains('toFixed', undefined, undefined, 'method'); diff --git a/tests/cases/fourslash/getJavaScriptCompletions20.ts b/tests/cases/fourslash/getJavaScriptCompletions20.ts new file mode 100644 index 00000000000..d254705bb91 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptCompletions20.ts @@ -0,0 +1,21 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// /** +//// * A person +//// * @constructor +//// * @param {string} name - The name of the person. +//// * @param {number} age - The age of the person. +//// */ +//// function Person(name, age) { +//// this.name = name; +//// this.age = age; +//// } +//// +//// +//// Person.getName = 10; +//// Person.getNa/**/ = 10; + +goTo.marker(); +verify.not.memberListContains('getNa'); diff --git a/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts new file mode 100644 index 00000000000..240df24bf52 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts @@ -0,0 +1,15 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// function f() { +//// // helloWorld leaks from here into the global space? +//// if (helloWorld) { +//// return 3; +//// } +//// return 5; +//// } +//// +//// hello/**/ + +verify.completionListContains('helloWorld'); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts new file mode 100644 index 00000000000..5aa8474757d --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: file.js +//// /** +//// * This is a very cool function that is very nice. +//// * @returns something +//// * @param p anotherthing +//// */ +//// function a1(p) { +//// try { +//// throw new Error('x'); +//// } catch (x) { x--; } +//// return 23; +//// } +//// +//// x - /**/a1() + +goTo.marker(); +verify.quickInfoExists(); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts new file mode 100644 index 00000000000..2524e50e668 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts @@ -0,0 +1,14 @@ +/// + +// @allowJs: true +// @Filename: a.js +//// function Person(age) { +//// if (age >= 18) { +//// this.canVote = true; +//// } else { +//// this.canVote = false; +//// } +//// } + +verify.getSyntacticDiagnostics(`[]`); +verify.getSemanticDiagnostics(`[]`); diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics24.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics24.ts new file mode 100644 index 00000000000..cf70f883e99 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics24.ts @@ -0,0 +1,16 @@ +/// + +// @allowJs: true +// @Filename: a.js +//// function Person(age) { +//// if (age >= 18) { +//// this.canVote = true; +//// } else { +//// this.canVote = 23; +//// } +//// } +//// let x = new Person(100); +//// x.canVote/**/; + +goTo.marker(); +verify.quickInfoIs('(property) Person.canVote: boolean | number'); diff --git a/tests/cases/fourslash/javaScriptModules13.ts b/tests/cases/fourslash/javaScriptModules13.ts index 4eed369836f..cb3ef36783f 100644 --- a/tests/cases/fourslash/javaScriptModules13.ts +++ b/tests/cases/fourslash/javaScriptModules13.ts @@ -23,4 +23,6 @@ verify.completionListContains('y'); verify.not.completionListContains('invisible'); edit.insert('x.'); -verify.completionListContains('a'); +verify.memberListContains('a', undefined, undefined, 'property'); +edit.insert('a.'); +verify.memberListContains('toFixed', undefined, undefined, 'method'); diff --git a/tests/cases/fourslash/javaScriptModules19.ts b/tests/cases/fourslash/javaScriptModules19.ts new file mode 100644 index 00000000000..91e2439dcc9 --- /dev/null +++ b/tests/cases/fourslash/javaScriptModules19.ts @@ -0,0 +1,26 @@ +/// + +// Assignments to 'module.exports' create an external module + +// @allowJs: true +// @Filename: myMod.js +//// var x = { a: 10 }; +//// module.exports = x; + +// @Filename: isGlobal.js +//// var y = 10; + +// @Filename: consumer.js +//// var x = require('myMod'); +//// /**/; + +goTo.file('consumer.js'); +goTo.marker(); + +verify.completionListContains('y'); +verify.not.completionListContains('invisible'); + +edit.insert('x.'); +verify.memberListContains('a', undefined, undefined, 'property'); +edit.insert('a.'); +verify.memberListContains('toFixed', undefined, undefined, 'method'); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures2.ts b/tests/cases/fourslash/jsDocFunctionSignatures2.ts new file mode 100644 index 00000000000..174ea7d6560 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures2.ts @@ -0,0 +1,12 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js + +//// /** @type {function(string, boolean=): number} */ +//// var f6; +//// +//// f6('', /**/false) + +goTo.marker(); +verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number') diff --git a/tests/cases/fourslash/jsDocFunctionSignatures3.ts b/tests/cases/fourslash/jsDocFunctionSignatures3.ts new file mode 100644 index 00000000000..3679035d31d --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures3.ts @@ -0,0 +1,32 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js + +//// var someObject = { +//// /** +//// * @param {string} param1 Some string param. +//// * @param {number} parm2 Some number param. +//// */ +//// someMethod: function(param1, param2) { +//// console.log(param1/*1*/); +//// return false; +//// }, +//// /** +//// * @param {number} p1 Some number param. +//// */ +//// otherMethod(p1) { +//// p1/*2*/ +//// } +//// +//// }; + +goTo.marker('1'); +edit.insert('.'); +verify.memberListContains('substr', undefined, undefined, 'method'); +edit.backspace(); + +goTo.marker('2'); +edit.insert('.'); +verify.memberListContains('toFixed', undefined, undefined, 'method'); +edit.backspace(); diff --git a/tests/cases/fourslash/jsDocGenerics1.ts b/tests/cases/fourslash/jsDocGenerics1.ts new file mode 100644 index 00000000000..61358e3f490 --- /dev/null +++ b/tests/cases/fourslash/jsDocGenerics1.ts @@ -0,0 +1,34 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: ref.d.ts +//// namespace Thing { +//// export interface Thung { +//// a: number; +//// ] +//// ] + + +// @Filename: Foo.js +//// +//// /** @type {Array} */ +//// var v; +//// v[0]./*1*/ +//// +//// /** @type {{x: Array>}} */ +//// var w; +//// w.x[0][0]./*2*/ +//// +//// /** @type {Array} */ +//// var x; +//// x[0].a./*3*/ + + +goTo.marker('1'); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); + +goTo.marker('2'); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); + +goTo.marker('3'); +verify.memberListContains("toFixed", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); diff --git a/tests/cases/fourslash/renameCrossJsTs01.ts b/tests/cases/fourslash/renameCrossJsTs01.ts new file mode 100644 index 00000000000..52cb4c587d1 --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = /**/[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameCrossJsTs02.ts b/tests/cases/fourslash/renameCrossJsTs02.ts new file mode 100644 index 00000000000..7ff1ae96ff3 --- /dev/null +++ b/tests/cases/fourslash/renameCrossJsTs02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.ts +////import { [|area|] } from './a'; +////var t = [|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports01.ts b/tests/cases/fourslash/renameJsExports01.ts new file mode 100644 index 00000000000..923d30eedf9 --- /dev/null +++ b/tests/cases/fourslash/renameJsExports01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports.[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod./**/[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsExports02.ts b/tests/cases/fourslash/renameJsExports02.ts new file mode 100644 index 00000000000..86b0471dc1f --- /dev/null +++ b/tests/cases/fourslash/renameJsExports02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////exports./**/[|area|] = function (r) { return r * r; } + +// @Filename: b.js +////var mod = require('./a'); +////var t = mod.[|area|](10); + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty01.ts b/tests/cases/fourslash/renameJsPrototypeProperty01.ts new file mode 100644 index 00000000000..f756f57edbf --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype.[|x|] = 10; +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsPrototypeProperty02.ts b/tests/cases/fourslash/renameJsPrototypeProperty02.ts new file mode 100644 index 00000000000..721dc312eb6 --- /dev/null +++ b/tests/cases/fourslash/renameJsPrototypeProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +////} +////bar.prototype./**/[|x|] = 10; +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty01.ts b/tests/cases/fourslash/renameJsThisProperty01.ts new file mode 100644 index 00000000000..91338e0431d --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty01.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this.[|x|] = 10; +////} +////var t = new bar(); +////t./**/[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file diff --git a/tests/cases/fourslash/renameJsThisProperty02.ts b/tests/cases/fourslash/renameJsThisProperty02.ts new file mode 100644 index 00000000000..8398507c9ca --- /dev/null +++ b/tests/cases/fourslash/renameJsThisProperty02.ts @@ -0,0 +1,12 @@ +/// + +// @allowJs: true +// @Filename: a.js +////function bar() { +//// this./**/[|x|] = 10; +////} +////var t = new bar(); +////t.[|x|] = 11; + +goTo.marker(); +verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false); \ No newline at end of file