diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index cac9f75e2eeab..c877c6f9773eb 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -125,6 +125,7 @@ module ts { Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, + yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index adf1bf041cf7e..5ee797482a9ea 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -491,6 +491,10 @@ "category": "Error", "code": 1162 }, + "'yield' expression must be contained_within a generator declaration.": { + "category": "Error", + "code": 1163 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index efceaeb596732..4219ad40ef47d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -895,11 +895,35 @@ module ts { // // Getting this all correct is tricky and requires careful reading of the grammar to // understand when these values should be changed versus when they should be inherited. - var strictModeContext = false; - var disallowInContext = false; + var contextFlags: ParserContextFlags = 0; + + function setContextFlag(val: Boolean, flag: ParserContextFlags) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } + } + + function setStrictModeContext(val: boolean) { + setContextFlag(val, ParserContextFlags.StrictMode); + } + + function setDisallowInContext(val: boolean) { + setContextFlag(val, ParserContextFlags.DisallowIn); + } + + function setYieldContext(val: boolean) { + setContextFlag(val, ParserContextFlags.Yield); + } + + function setGeneratorParameterContext(val: boolean) { + setContextFlag(val, ParserContextFlags.GeneratorParameter); + } function allowInAnd(func: () => T): T { - if (disallowInContext) { + if (contextFlags & ParserContextFlags.DisallowIn) { setDisallowInContext(false); var result = func(); setDisallowInContext(true); @@ -911,7 +935,7 @@ module ts { } function disallowInAnd(func: () => T): T { - if (disallowInContext) { + if (contextFlags & ParserContextFlags.DisallowIn) { // no need to do anything special if 'in' is already disallowed. return func(); } @@ -922,8 +946,44 @@ module ts { return result; } - function setDisallowInContext(val: boolean) { - disallowInContext = val; + function doInYieldContext(func: () => T): T { + if (contextFlags & ParserContextFlags.Yield) { + // no need to do anything special if we're already in the [Yield] context. + return func(); + } + + setYieldContext(true); + var result = func(); + setYieldContext(false); + return result; + } + + function doOutsideOfYieldContext(func: () => T): T { + if (contextFlags & ParserContextFlags.Yield) { + setYieldContext(false); + var result = func(); + setYieldContext(true); + return result; + } + + // no need to do anything special if we're not in the [Yield] context. + return func(); + } + + function inYieldContext() { + return (contextFlags & ParserContextFlags.Yield) !== 0; + } + + function inStrictModeContext() { + return (contextFlags & ParserContextFlags.StrictMode) !== 0; + } + + function inGeneratorParameterContext() { + return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; + } + + function inDisallowInContext() { + return (contextFlags & ParserContextFlags.DisallowIn) !== 0; } function getLineStarts(): number[] { @@ -1051,7 +1111,17 @@ module ts { } function isIdentifier(): boolean { - return token === SyntaxKind.Identifier || (strictModeContext ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord); + if (token === SyntaxKind.Identifier) { + return true; + } + + // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is + // considered a keyword and is not an identifier. + if (token === SyntaxKind.YieldKeyword && inYieldContext()) { + return false; + } + + return inStrictModeContext() ? token > SyntaxKind.LastFutureReservedWord : token > SyntaxKind.LastReservedWord; } function parseExpected(t: SyntaxKind): boolean { @@ -1108,12 +1178,8 @@ module ts { function finishNode(node: T): T { node.end = scanner.getStartPos(); - if (strictModeContext) { - node.flags |= NodeFlags.ParsedInStrictModeContext; - } - - if (disallowInContext) { - node.flags |= NodeFlags.ParsedInDisallowInContext + if (contextFlags) { + node.parserContextFlags = contextFlags; } return node; @@ -1176,7 +1242,7 @@ module ts { function parseAnyContextualModifier(): boolean { return isModifier(token) && tryParse(() => { nextToken(); - return token === SyntaxKind.OpenBracketToken || isPropertyName(); + return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isPropertyName(); }); } @@ -1196,8 +1262,9 @@ module ts { case ParsingContext.ClassMembers: return lookAhead(isClassMemberStart); case ParsingContext.EnumMembers: - case ParsingContext.ObjectLiteralMembers: return isPropertyName(); + case ParsingContext.ObjectLiteralMembers: + return token === SyntaxKind.AsteriskToken || isPropertyName(); case ParsingContext.BaseTypeReferences: return isIdentifier() && ((token !== SyntaxKind.ExtendsKeyword && token !== SyntaxKind.ImplementsKeyword) || !lookAhead(() => (nextToken(), isIdentifier()))); case ParsingContext.VariableDeclarations: @@ -1301,16 +1368,16 @@ module ts { parsingContext |= 1 << kind; var result = >[]; result.pos = getNodePos(); - var savedStrictModeContext = strictModeContext; + var savedStrictModeContext = inStrictModeContext(); while (!isListTerminator(kind)) { if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseElement(); result.push(element); // test elements only if we are not already in strict mode - if (!strictModeContext && checkForStrictMode) { + if (!inStrictModeContext() && checkForStrictMode) { if (isPrologueDirective(element)) { if (isUseStrictPrologueDirective(element)) { - strictModeContext = true; + setStrictModeContext(true); checkForStrictMode = false; } } @@ -1327,7 +1394,7 @@ module ts { nextToken(); } } - strictModeContext = savedStrictModeContext; + setStrictModeContext(savedStrictModeContext); result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; @@ -1389,12 +1456,13 @@ module ts { return result; } - function parseBracketedList(kind: ParsingContext, parseElement: () => T, startToken: SyntaxKind, endToken: SyntaxKind): NodeArray { - if (parseExpected(startToken)) { + function parseBracketedList(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray { + if (parseExpected(open)) { var result = parseDelimitedList(kind, parseElement); - parseExpected(endToken); + parseExpected(close); return result; } + return createMissingList(); } @@ -1566,7 +1634,15 @@ module ts { if (parseOptional(SyntaxKind.DotDotDotToken)) { node.flags |= NodeFlags.Rest; } - node.name = parseIdentifier(); + + // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 + // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt + // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + + node.name = inGeneratorParameterContext() + ? doInYieldContext(parseIdentifier) + : parseIdentifier(); + if (node.name.kind === SyntaxKind.Missing && node.flags === 0 && isModifier(token)) { // in cases like // 'use strict' @@ -1583,7 +1659,9 @@ module ts { node.flags |= NodeFlags.QuestionMark; } node.type = parseParameterType(); - node.initializer = parseInitializer(/*inParameter*/ true); + node.initializer = inGeneratorParameterContext() + ? doOutsideOfYieldContext(parseParameterInitializer) + : parseParameterInitializer(); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in @@ -1596,18 +1674,28 @@ module ts { return finishNode(node); } - function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean): ParsedSignature { + function parseParameterInitializer() { + return parseInitializer(/*inParameter*/ true); + } + + function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean, yieldAndGeneratorParameterContext: boolean): ParsedSignature { var signature = {}; - fillSignature(kind, returnToken, returnTokenRequired, signature); + fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature); return signature; } - function fillSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean, signature: ParsedSignature): void { + function fillSignature( + kind: SyntaxKind, + returnToken: SyntaxKind, + returnTokenRequired: boolean, + yieldAndGeneratorParameterContext: boolean, + signature: ParsedSignature): void { + if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken); + signature.parameters = parseParameterList(yieldAndGeneratorParameterContext); if (returnTokenRequired) { parseExpected(returnToken); @@ -1618,15 +1706,47 @@ module ts { } } - // Because we use this for index signatures as well, we sometimes use - // parentheses, and sometimes use brackets. - function parseParameterList(startDelimiter: SyntaxKind, endDelimiter: SyntaxKind) { - return parseBracketedList(ParsingContext.Parameters, parseParameter, startDelimiter, endDelimiter); + // Note: after careful analysis of the grammar, it does not appear to be possible to + // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling + // this FormalParameters production either always sets both to true, or always sets + // both to false. As such we only have a single parameter to represent both. + function parseParameterList(yieldAndGeneratorParameterContext: boolean) { + // FormalParameters[Yield,GeneratorParameter] : + // ... + // + // FormalParameter[Yield,GeneratorParameter] : + // BindingElement[?Yield, ?GeneratorParameter] + // + // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 + // SingleNameBinding[?Yield, ?GeneratorParameter] + // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt + // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // + // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 + // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt + // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + if (parseExpected(SyntaxKind.OpenParenToken)) { + var savedYieldContext = inYieldContext(); + var savedGeneratorParameterContext = inGeneratorParameterContext(); + + setYieldContext(yieldAndGeneratorParameterContext); + setGeneratorParameterContext(yieldAndGeneratorParameterContext); + + var result = parseDelimitedList(ParsingContext.Parameters, parseParameter); + parseExpected(SyntaxKind.CloseParenToken); + + setYieldContext(savedYieldContext); + setGeneratorParameterContext(savedGeneratorParameterContext); + + return result; + } + + return createMissingList(); } function parseSignatureMember(kind: SyntaxKind, returnToken: SyntaxKind): SignatureDeclaration { var node = createNode(kind); - fillSignature(kind, returnToken, /* returnTokenRequired */ false, node); + fillSignature(kind, returnToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node); parseSemicolon(); return finishNode(node); } @@ -1634,7 +1754,7 @@ module ts { function parseIndexSignatureMember(fullStart: number, modifiers: ModifiersArray): SignatureDeclaration { var node = createNode(SyntaxKind.IndexSignature, fullStart); setModifiers(node, modifiers); - node.parameters = parseParameterList(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); + node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); parseSemicolon(); return finishNode(node) @@ -1652,7 +1772,11 @@ module ts { var method = createNode(SyntaxKind.Method, fullStart); method.name = name; method.flags = flags; - fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, method); + + // Method signatues don't exist in expression contexts. So they have neither + // [Yield] nor [GeneratorParameter] + fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, method); + parseSemicolon(); return finishNode(method); } @@ -1735,7 +1859,7 @@ module ts { function parseFunctionType(typeKind: SyntaxKind): SignatureDeclaration { var node = createNode(typeKind); fillSignature(typeKind === SyntaxKind.FunctionType ? SyntaxKind.CallSignature : SyntaxKind.ConstructSignature, - SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true, node); + SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true, /*yieldAndGeneratorParameterContext:*/ false, node); return finishNode(node); } @@ -1855,6 +1979,23 @@ module ts { } function parseType(): TypeNode { + // The rules about 'yield' only apply to actual code/expression contexts. They don't + // apply to 'type' contexts. So we disable these parameters here before moving on. + var savedYieldContext = inYieldContext(); + var savedGeneratorParameterContext = inGeneratorParameterContext(); + + setYieldContext(false); + setGeneratorParameterContext(false); + + var result = parseTypeWorker(); + + setYieldContext(savedYieldContext); + setGeneratorParameterContext(savedGeneratorParameterContext); + + return result; + } + + function parseTypeWorker(): TypeNode { if (isStartOfFunctionType()) { return parseFunctionType(SyntaxKind.FunctionType); } @@ -1899,6 +2040,10 @@ module ts { case SyntaxKind.MinusMinusToken: case SyntaxKind.LessThanToken: case SyntaxKind.Identifier: + case SyntaxKind.YieldKeyword: + // Yield always starts an expression. Either it is an identifier (in which case + // it is definitely an expression). Or it's a keyword (either because we're in + // a generator, or in strict mode (or both)) and it started a yield expression. return true; default: return isIdentifier(); @@ -1947,18 +2092,22 @@ module ts { } function parseAssignmentExpression(): Expression { - // Augmented by TypeScript: - // - // AssignmentExpression[in]: - // 1) ConditionalExpression[in] - // 2) LeftHandSideExpression = AssignmentExpression[in] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[in] - // 4) ArrowFunctionExpression <-- added by TypeScript + // AssignmentExpression[in,yield]: + // 1) ConditionalExpression[?in,?yield] + // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] + // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] + // 4) ArrowFunctionExpression[?in,?yield] + // 5) [+Yield] YieldExpression[?In] // // Note: for ease of implementation we treat productions '2' and '3' as the same thing. // (i.e. they're both BinaryExpressions with an assignment operator in it). - // First, check if we have an arrow function (production '4') that starts with a parenthesized + // First, do the simple check if we have a YieldExpression (production '5'). + if (isYieldExpression()) { + return parseYieldExpression(); + } + + // Then, check if we have an arrow function (production '4') that starts with a parenthesized // parameter list. If we do, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done // with AssignmentExpression if we see one. @@ -1991,6 +2140,68 @@ module ts { return expr; } + function isYieldExpression(): boolean { + if (token === SyntaxKind.YieldKeyword) { + // If we have a 'yield' keyword, and htis is a context where yield expressions are + // allowed, then definitely parse out a yield expression. + if (inYieldContext()) { + return true; + } + + if (inStrictModeContext()) { + // If we're in strict mode, then 'yield' is a keyword, could only ever start + // a yield expression. + return true; + } + + // We're in a context where 'yield expr' is not allowed. However, if we can + // definitely tell that the user was trying to parse a 'yield expr' and not + // just a normal expr that start with a 'yield' identifier, then parse out + // a 'yield expr'. We can then report an error later that they are only + // allowed in generator expressions. + // + // for example, if we see 'yield(foo)', then we'll have to treat that as an + // invocation expression of something called 'yield'. However, if we have + // 'yield foo' then that is not legal as a normal expression, so we can + // definitely recognize this as a yield expression. + // + // for now we just check if the next token is an identifier. More heuristics + // can be added here later as necessary. We just need to make sure that we + // don't accidently consume something legal. + return lookAhead(() => { + nextToken(); + return !scanner.hasPrecedingLineBreak() && isIdentifier(); + }); + } + + return false; + } + + function parseYieldExpression(): YieldExpression { + var node = createNode(SyntaxKind.YieldExpression); + + // YieldExpression[In] : + // yield + // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] + // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] + nextToken(); + + if (!scanner.hasPrecedingLineBreak() && + (token === SyntaxKind.AsteriskToken || isStartOfExpression())) { + if (parseOptional(SyntaxKind.AsteriskToken)) { + node.flags = NodeFlags.YieldStar; + } + + node.expression = parseAssignmentExpression(); + return finishNode(node); + } + else { + // if the next token is not on the same line as yield. or we don't have an '*' or + // the start of an expressin, then this is just a simple "yield" expression. + return finishNode(node); + } + } + function parseSimpleArrowFunctionExpression(identifier: Identifier): Expression { Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); parseExpected(SyntaxKind.EqualsGreaterThanToken); @@ -2020,7 +2231,8 @@ module ts { var pos = getNodePos(); if (triState === Tristate.True) { - var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false); + // Arrow function are never generators. + var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false); // If we have an arrow, then try to parse the body. // Even if not, try to parse if we have an opening brace, just in case we're in an error state. @@ -2123,7 +2335,8 @@ module ts { function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature { return tryParse(() => { - var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false); + // Arrow functions are never generators. + var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false); // Parsing a signature isn't enough. // Parenthesized arrow signatures often look like other valid expressions. @@ -2145,7 +2358,7 @@ module ts { var body: Node; if (token === SyntaxKind.OpenBraceToken) { - body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false); + body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ false); } else if (isStatement(/* inErrorRecovery */ true) && !isStartOfExpressionStatement() && token !== SyntaxKind.FunctionKeyword) { // Check if we got a plain statement (i.e. no expression-statements, no functions expressions/declarations) @@ -2162,7 +2375,7 @@ module ts { // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - body = parseFunctionBlock(/* ignoreMissingOpenBrace */ true); + body = parseFunctionBlock(/*allowYield:*/ false, /* ignoreMissingOpenBrace */ true); } else { body = parseAssignmentExpression(); @@ -2191,7 +2404,7 @@ module ts { while (true) { reScanGreaterToken(); var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!disallowInContext || token !== SyntaxKind.InKeyword)) { + if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== SyntaxKind.InKeyword)) { var operator = token; nextToken(); expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence)); @@ -2504,15 +2717,20 @@ module ts { function parsePropertyAssignment(): Declaration { var nodePos = scanner.getStartPos(); + var isGenerator = parseOptional(SyntaxKind.AsteriskToken); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); var node: Declaration; - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { + if (isGenerator || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { node = createNode(SyntaxKind.PropertyAssignment, nodePos); node.name = propertyName; - var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false); - var body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false); + if (isGenerator) { + node.flags |= NodeFlags.Generator; + } + var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator); + + var body = parseFunctionBlock(isGenerator, /* ignoreMissingOpenBrace */ false); // do not propagate property name as name for function expression // for scenarios like // var x = 1; @@ -2569,16 +2787,31 @@ module ts { } function parseFunctionExpression(): FunctionExpression { + // GeneratorExpression : + // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // FunctionExpression: + // function BindingIdentifieropt(FormalParameters) { FunctionBody } + var pos = getNodePos(); parseExpected(SyntaxKind.FunctionKeyword); - var name = isIdentifier() ? parseIdentifier() : undefined; - var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false); - var body = parseFunctionBlock(/* ignoreMissingOpenBrace */ false); - return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body); + var isGenerator = parseOptional(SyntaxKind.AsteriskToken); + var name = isGenerator ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); + var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator); + + var body = parseFunctionBlock(/*allowYield:*/ isGenerator, /* ignoreMissingOpenBrace */ false); + return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body, isGenerator ? NodeFlags.Generator : undefined); } - function makeFunctionExpression(kind: SyntaxKind, pos: number, name: Identifier, sig: ParsedSignature, body: Node): FunctionExpression { + function parseOptionalIdentifier() { + return isIdentifier() ? parseIdentifier() : undefined; + } + + function makeFunctionExpression(kind: SyntaxKind, pos: number, name: Identifier, sig: ParsedSignature, body: Node, flags?: NodeFlags): FunctionExpression { var node = createNode(kind, pos); + if (flags) { + node.flags = flags; + } + node.name = name; node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; @@ -2611,10 +2844,15 @@ module ts { return finishNode(node); } - function parseFunctionBlock(ignoreMissingOpenBrace: boolean): Block { + function parseFunctionBlock(allowYield: boolean, ignoreMissingOpenBrace: boolean): Block { + var savedYieldContext = inYieldContext(); + setYieldContext(allowYield); + var block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true); block.kind = SyntaxKind.FunctionBlock; + setYieldContext(savedYieldContext); + return block; } @@ -2979,9 +3217,9 @@ module ts { } } - function parseFunctionBlockOrSemicolon(): Block { + function parseFunctionBlockOrSemicolon(isGenerator: boolean): Block { if (token === SyntaxKind.OpenBraceToken) { - return parseFunctionBlock(/* ignoreMissingOpenBrace */ false); + return parseFunctionBlock(isGenerator, /* ignoreMissingOpenBrace */ false); } if (canParseSemicolon()) { @@ -3040,9 +3278,14 @@ module ts { var node = createNode(SyntaxKind.FunctionDeclaration, fullStart); setModifiers(node, modifiers); parseExpected(SyntaxKind.FunctionKeyword); + var isGenerator = parseOptional(SyntaxKind.AsteriskToken); + if (isGenerator) { + node.flags |= NodeFlags.Generator; + } + node.name = parseIdentifier(); - fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node); - node.body = parseFunctionBlockOrSemicolon(); + fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator); return finishNode(node); } @@ -3050,29 +3293,34 @@ module ts { var node = createNode(SyntaxKind.Constructor, pos); setModifiers(node, modifiers); parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node); - node.body = parseFunctionBlockOrSemicolon(); + fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false); return finishNode(node); } function parsePropertyMemberDeclaration(fullStart: number, modifiers: ModifiersArray): Declaration { - var name = parsePropertyName(); var flags = modifiers ? modifiers.flags : 0; + var isGenerator = parseOptional(SyntaxKind.AsteriskToken); + if (isGenerator) { + flags |= NodeFlags.Generator; + } + + var name = parsePropertyName(); if (parseOptional(SyntaxKind.QuestionToken)) { // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. flags |= NodeFlags.QuestionMark; } - if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { + if (isGenerator || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) { var method = createNode(SyntaxKind.Method, fullStart); setModifiers(method, modifiers); if (flags) { method.flags = flags; } method.name = name; - fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, method); - method.body = parseFunctionBlockOrSemicolon(); + fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ isGenerator, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator); return finishNode(method); } else { @@ -3093,8 +3341,8 @@ module ts { var node = createNode(kind, fullStart); setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, node); - node.body = parseFunctionBlockOrSemicolon(); + fillSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false, /*yieldAndGeneratorParameterContext:*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator:*/ false); return finishNode(node); } @@ -3107,6 +3355,10 @@ module ts { nextToken(); } + if (token === SyntaxKind.AsteriskToken) { + return true; + } + // Try to get the first property-like token following all modifiers. // This can either be an identifier or the 'get' or 'set' keywords. if (isPropertyName()) { @@ -3183,7 +3435,7 @@ module ts { if (token === SyntaxKind.ConstructorKeyword) { return parseConstructorDeclaration(fullStart, modifiers); } - if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral) { + if (token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || token === SyntaxKind.AsteriskToken) { return parsePropertyMemberDeclaration(fullStart, modifiers); } if (token === SyntaxKind.OpenBracketToken) { @@ -3202,12 +3454,26 @@ module ts { node.typeParameters = parseTypeParameters(); // TODO(jfreeman): Parse arbitrary sequence of heritage clauses and error for order and duplicates - node.baseType = parseOptional(SyntaxKind.ExtendsKeyword) ? parseTypeReference() : undefined; + + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + + node.baseType = inGeneratorParameterContext() + ? doOutsideOfYieldContext(parseClassBaseType) + : parseClassBaseType(); + if (parseOptional(SyntaxKind.ImplementsKeyword)) { node.implementedTypes = parseDelimitedList(ParsingContext.BaseTypeReferences, parseTypeReference); } if (parseExpected(SyntaxKind.OpenBraceToken)) { - node.members = parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration); + // ClassTail[Yield,GeneratorParameter] : See 14.5 + // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } + // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + + node.members = inGeneratorParameterContext() + ? doOutsideOfYieldContext(parseClassMembers) + : parseClassMembers(); parseExpected(SyntaxKind.CloseBraceToken); } else { @@ -3216,6 +3482,14 @@ module ts { return finishNode(node); } + function parseClassMembers() { + return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassMemberDeclaration); + } + + function parseClassBaseType(): TypeReferenceNode { + return parseOptional(SyntaxKind.ExtendsKeyword) ? parseTypeReference() : undefined; + } + function parseInterfaceDeclaration(fullStart: number, modifiers: ModifiersArray): InterfaceDeclaration { var node = createNode(SyntaxKind.InterfaceDeclaration, fullStart); setModifiers(node, modifiers); @@ -3654,7 +3928,6 @@ module ts { return checkCallOrNewExpression(node); case SyntaxKind.EnumDeclaration: return checkEnumDeclaration(node); - case SyntaxKind.Parameter: return checkParameter(node); case SyntaxKind.BinaryExpression: return checkBinaryExpression(node); case SyntaxKind.CatchBlock: return checkCatchBlock(node); case SyntaxKind.ClassDeclaration: return checkClassDeclaration(node); @@ -3673,6 +3946,7 @@ module ts { case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(node); case SyntaxKind.ObjectLiteral: return checkObjectLiteral(node); case SyntaxKind.NumericLiteral: return checkNumericLiteral(node); + case SyntaxKind.Parameter: return checkParameter(node); case SyntaxKind.PostfixOperator: return checkPostfixOperator(node); case SyntaxKind.PrefixOperator: return checkPrefixOperator(node); case SyntaxKind.Property: return checkProperty(node); @@ -3689,6 +3963,7 @@ module ts { case SyntaxKind.VariableDeclaration: return checkVariableDeclaration(node); case SyntaxKind.VariableStatement: return checkVariableStatement(node); case SyntaxKind.WithStatement: return checkWithStatement(node); + case SyntaxKind.YieldExpression: return checkYieldExpression(node); } } @@ -3750,7 +4025,7 @@ module ts { } function checkBinaryExpression(node: BinaryExpression) { - if (node.flags & NodeFlags.ParsedInStrictModeContext) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { if (isEvalOrArgumentsIdentifier(node.left)) { // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an @@ -3902,7 +4177,7 @@ module ts { var colonStart = skipTrivia(sourceText, node.variable.end); return grammarErrorAtPos(colonStart, ":".length, Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); } - if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.variable)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.variable)) { // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the // Catch production is eval or arguments return reportInvalidUseInStrictMode(node.variable); @@ -4022,7 +4297,7 @@ module ts { } function checkFunctionName(name: Node) { - if (name && name.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(name)) { + if (name && name.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(name)) { // It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the // Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1) return reportInvalidUseInStrictMode(name); @@ -4143,7 +4418,7 @@ module ts { var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.flags & NodeFlags.ParsedInStrictModeContext) !== 0; + var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0; for (var i = 0, n = node.properties.length; i < n; i++) { var prop = node.properties[i]; @@ -4207,7 +4482,7 @@ module ts { function checkNumericLiteral(node: LiteralExpression): boolean { if (node.flags & NodeFlags.OctalLiteral) { - if (node.flags & NodeFlags.ParsedInStrictModeContext) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); } else if (languageVersion >= ScriptTarget.ES5) { @@ -4351,7 +4626,7 @@ module ts { // or if its FunctionBody is strict code(11.1.5). // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.name)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) { return reportInvalidUseInStrictMode(node.name); } } @@ -4410,13 +4685,13 @@ module ts { // The identifier eval or arguments may not appear as the LeftHandSideExpression of an // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.operand)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.operand)) { return reportInvalidUseInStrictMode(node.operand); } } function checkPrefixOperator(node: UnaryExpression) { - if (node.flags & NodeFlags.ParsedInStrictModeContext) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { // The identifier eval or arguments may not appear as the LeftHandSideExpression of an // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator @@ -4601,7 +4876,7 @@ module ts { if (!inAmbientContext && !node.initializer && isConst(node)) { return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } - if (node.flags & NodeFlags.ParsedInStrictModeContext && isEvalOrArgumentsIdentifier(node.name)) { + if (node.parserContextFlags & ParserContextFlags.StrictMode && isEvalOrArgumentsIdentifier(node.name)) { // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments return reportInvalidUseInStrictMode(node.name); @@ -4663,12 +4938,18 @@ module ts { } function checkWithStatement(node: WithStatement): boolean { - if (node.flags & NodeFlags.ParsedInStrictModeContext) { + if (node.parserContextFlags & ParserContextFlags.StrictMode) { // Strict mode code may not include a WithStatement. The occurrence of a WithStatement in such // a context is an return grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } + + function checkYieldExpression(node: YieldExpression): boolean { + if (!(node.parserContextFlags & ParserContextFlags.Yield)) { + return grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); + } + } } export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ee01e40b66a33..a2fc1f144fe1e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -183,6 +183,7 @@ module ts { ConditionalExpression, TemplateExpression, TemplateSpan, + YieldExpression, OmittedExpression, // Element Block, @@ -269,22 +270,30 @@ module ts { DeclarationFile = 0x00000400, // Node is a .d.ts file Let = 0x00000800, // Variable declaration Const = 0x00001000, // Variable declaration - - // Set if this node was parsed in strict mode. Used for grammar error checks, as well as - // checking if the node can be reused in incremental settings. - ParsedInStrictModeContext = 0x00002000, - ParsedInDisallowInContext = 0x00004000, - - OctalLiteral = 0x00008000, + OctalLiteral = 0x00002000, + Generator = 0x00004000, + YieldStar = 0x00008000, Modifier = Export | Ambient | Public | Private | Protected | Static, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } + export const enum ParserContextFlags { + // Set if this node was parsed in strict mode. Used for grammar error checks, as well as + // checking if the node can be reused in incremental settings. + StrictMode = 1 << 0, + DisallowIn = 1 << 1, + Yield = 1 << 2, + GeneratorParameter = 1 << 3, + } + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; + // Specific context the parser was in when this node was created. Normally undefined. + // Only set when the parser was in some interesting context (like async/yield). + parserContextFlags?: ParserContextFlags; id?: number; // Unique id (used to look up NodeLinks) parent?: Node; // Parent node (initialized by binding) symbol?: Symbol; // Symbol declared by node (initialized by binding) @@ -431,6 +440,10 @@ module ts { operator: SyntaxKind; operand: Expression; } + + export interface YieldExpression extends Expression { + expression: Expression; + } export interface BinaryExpression extends Expression { left: Expression; diff --git a/src/services/syntax/constants.ts b/src/services/syntax/constants.ts index 8845af18af63f..87d4a6a2c774c 100644 --- a/src/services/syntax/constants.ts +++ b/src/services/syntax/constants.ts @@ -1,29 +1,24 @@ /// module TypeScript { + export const enum ParserContextFlags { + StrictMode = 1 << 0, + DisallowIn = 1 << 1, + Yield = 1 << 2, + GeneratorParameter = 1 << 3, + + Mask = 0xF + } + export enum SyntaxNodeConstants { None = 0, - // Masks that we use to place information about a node into a single int. The first bit tells - // us if we've computed the data for a node. - // - // The second bit tells us if the node is incrementally reusable if it does not - // containe any skipped tokens, zero width tokens, regex tokens in it ("/", "/=" or "/.../"), - // and contains no tokens that were parser generated. - // - // The next bit lets us know if the nodes was parsed in a strict context or node. A node can - // only be used by the incremental parser if it is parsed in the same strict context as before. - // last masks off the part of the int - // + // The first four bit of the flags are used to store parser context flags. // The width of the node is stored in the remainder of the int. This allows us up to 128MB // for a node by using all 27 bits. However, in the common case, we'll use less than 27 bits // for the width. Thus, the info will be stored in a single int in chakra. - DataComputed = 0x00000001, // 0000 0000 0000 0000 0000 0000 0000 0001 - IncrementallyUnusableMask = 0x00000002, // 0000 0000 0000 0000 0000 0000 0000 0010 - ParsedInStrictModeContext = 0x00000004, // 0000 0000 0000 0000 0000 0000 0000 0100 - ParsedInDisallowInContext = 0x00000008, // 0000 0000 0000 0000 0000 0000 0000 1000 - ParsedInYieldContext = 0x00000010, // 0000 0000 0000 0000 0000 0000 0001 0000 - ParsedInGeneratorParameterContext = 0x00000020, // 0000 0000 0000 0000 0000 0000 0010 0000 - FullWidthShift = 1 << 6, // 1111 1111 1111 1111 1111 1111 1100 0000 + DataComputed = 1 << 4, // 0000 0000 0000 0000 0000 0000 0001 0000 + IncrementallyUnusableMask = 1 << 5, // 0000 0000 0000 0000 0000 0000 0010 0000 + FullWidthShift = 1 << 6, // 1111 1111 1111 1111 1111 1111 1100 0000 } } \ No newline at end of file diff --git a/src/services/syntax/parser.ts b/src/services/syntax/parser.ts index 3a16f23e2b1a8..53f4608ff57fc 100644 --- a/src/services/syntax/parser.ts +++ b/src/services/syntax/parser.ts @@ -195,10 +195,7 @@ module TypeScript.Parser { // // Getting this all correct is tricky and requires careful reading of the grammar to // understand when these values should be changed versus when they should be inherited. - var strictModeContext: boolean = false; - var disallowInContext: boolean = false; - var yieldContext: boolean = false; - var generatorParameterContext: boolean = false; + var contextFlags: ParserContextFlags = 0; // Current state of the parser. If we need to rewind we will store and reset these values as // appropriate. @@ -209,8 +206,6 @@ module TypeScript.Parser { // started at. var diagnostics: Diagnostic[] = []; - var parseNodeData: number = 0; - var _skippedTokens: ISyntaxToken[] = undefined; function parseSyntaxTree(_source: IParserSource, isDeclaration: boolean): SyntaxTree { @@ -224,7 +219,7 @@ module TypeScript.Parser { // Now, clear out our state so that our singleton parser doesn't keep things alive. diagnostics = []; - parseNodeData = SyntaxNodeConstants.None; + contextFlags = 0; fileName = undefined; source.release(); source = undefined; @@ -285,10 +280,7 @@ module TypeScript.Parser { // are unaffected by strict mode. It's just the parser will decide what to do with it // differently depending on what mode it is in. if (node && - parsedInStrictModeContext(node) === strictModeContext && - parsedInDisallowInContext(node) === disallowInContext && - parsedInYieldContext(node) === yieldContext && - parsedInGeneratorParameterContext(node) === generatorParameterContext) { + parserContextFlags(node) === contextFlags) { return node; } @@ -422,7 +414,7 @@ module TypeScript.Parser { // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (tokenKind === SyntaxKind.YieldKeyword && yieldContext) { + if (tokenKind === SyntaxKind.YieldKeyword && inYieldContext()) { return false; } @@ -432,7 +424,7 @@ module TypeScript.Parser { if (tokenKind <= SyntaxKind.LastFutureReservedStrictKeyword) { // Could be a keyword or identifier. It's an identifier if we're not in strict // mode. - return !strictModeContext; + return !inStrictModeContext(); } // If it's typescript keyword, then it's actually a javascript identifier. @@ -634,39 +626,52 @@ module TypeScript.Parser { throw Errors.invalidOperation(); } - function updateParseNodeData() { - parseNodeData = - (strictModeContext ? SyntaxNodeConstants.ParsedInStrictModeContext : 0) | - (disallowInContext ? SyntaxNodeConstants.ParsedInDisallowInContext : 0) | - (yieldContext ? SyntaxNodeConstants.ParsedInYieldContext : 0) | - (generatorParameterContext ? SyntaxNodeConstants.ParsedInGeneratorParameterContext : 0); + function setContextFlag(val: boolean, flag: ParserContextFlags) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; + } } function setStrictModeContext(val: boolean) { - strictModeContext = val; - updateParseNodeData(); + setContextFlag(val, ParserContextFlags.StrictMode); } function setDisallowInContext(val: boolean) { - disallowInContext = val; - updateParseNodeData(); + setContextFlag(val, ParserContextFlags.DisallowIn); } function setYieldContext(val: boolean) { - yieldContext = val; - updateParseNodeData(); + setContextFlag(val, ParserContextFlags.Yield); } function setGeneratorParameterContext(val: boolean) { - generatorParameterContext = val; - updateParseNodeData(); + setContextFlag(val, ParserContextFlags.GeneratorParameter); + } + + function inStrictModeContext() { + return (contextFlags & ParserContextFlags.StrictMode) !== 0; + } + + function inDisallowInContext() { + return (contextFlags & ParserContextFlags.DisallowIn) !== 0; + } + + function inYieldContext() { + return (contextFlags & ParserContextFlags.Yield) !== 0; + } + + function inGeneratorParameterContext() { + return (contextFlags & ParserContextFlags.GeneratorParameter) !== 0; } function parseSourceUnit(): SourceUnitSyntax { // Note: saving and restoring the 'isInStrictMode' state is not really necessary here // (as it will never be read afterwards). However, for symmetry with the rest of the // parsing code, we do the same here. - var savedIsInStrictMode = strictModeContext + var savedIsInStrictMode = inStrictModeContext() // Note: any skipped tokens produced after the end of all the module elements will be // added as skipped trivia to the start of the EOF token. @@ -674,7 +679,7 @@ module TypeScript.Parser { setStrictModeContext(savedIsInStrictMode); - var sourceUnit = new SourceUnitSyntax(parseNodeData, moduleElements, consumeToken(currentToken())); + var sourceUnit = new SourceUnitSyntax(contextFlags, moduleElements, consumeToken(currentToken())); if (Debug.shouldAssert(AssertionLevel.Aggressive)) { Debug.assert(fullWidth(sourceUnit) === source.text.length()); @@ -693,7 +698,7 @@ module TypeScript.Parser { } function updateStrictModeState(items: any[]): void { - if (!strictModeContext) { + if (!inStrictModeContext()) { // Check if all the items are directive prologue elements. for (var i = 0, n = items.length; i < n; i++) { if (!isDirectivePrologueElement(items[i])) { @@ -789,12 +794,12 @@ module TypeScript.Parser { } function parseImportDeclaration(): ImportDeclarationSyntax { - return new ImportDeclarationSyntax(parseNodeData, + return new ImportDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.ImportKeyword), eatIdentifierToken(), eatToken(SyntaxKind.EqualsToken), parseModuleReference(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseExportAssignment(): ExportAssignmentSyntax { - return new ExportAssignmentSyntax(parseNodeData, + return new ExportAssignmentSyntax(contextFlags, eatToken(SyntaxKind.ExportKeyword), eatToken(SyntaxKind.EqualsToken), eatIdentifierToken(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -808,12 +813,12 @@ module TypeScript.Parser { } function parseExternalModuleReference(): ExternalModuleReferenceSyntax { - return new ExternalModuleReferenceSyntax(parseNodeData, + return new ExternalModuleReferenceSyntax(contextFlags, eatToken(SyntaxKind.RequireKeyword), eatToken(SyntaxKind.OpenParenToken), eatToken(SyntaxKind.StringLiteral), eatToken(SyntaxKind.CloseParenToken)); } function parseModuleNameModuleReference(): ModuleNameModuleReferenceSyntax { - return new ModuleNameModuleReferenceSyntax(parseNodeData, parseName(/*allowIdentifierNames:*/ false)); + return new ModuleNameModuleReferenceSyntax(contextFlags, parseName(/*allowIdentifierNames:*/ false)); } function tryParseTypeArgumentList(inExpression: boolean): TypeArgumentListSyntax { @@ -825,7 +830,7 @@ module TypeScript.Parser { if (!inExpression) { // if we're not in an expression, this must be a type argument list. Just parse // it out as such. - return new TypeArgumentListSyntax(parseNodeData, + return new TypeArgumentListSyntax(contextFlags, consumeToken(_currentToken), parseSeparatedSyntaxList(ListParsingState.TypeArgumentList_Types), eatToken(SyntaxKind.GreaterThanToken)); @@ -851,7 +856,7 @@ module TypeScript.Parser { } else { releaseRewindPoint(rewindPoint); - return new TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, greaterThanToken); + return new TypeArgumentListSyntax(contextFlags, lessThanToken, typeArguments, greaterThanToken); } } @@ -944,7 +949,7 @@ module TypeScript.Parser { var dotToken = consumeToken(currentToken()); var identifierName = eatRightSideOfName(allowIdentifierNames); - current = new QualifiedNameSyntax(parseNodeData, current, dotToken, identifierName); + current = new QualifiedNameSyntax(contextFlags, current, dotToken, identifierName); shouldContinue = identifierName.fullWidth() > 0; } @@ -954,7 +959,7 @@ module TypeScript.Parser { function parseEnumDeclaration(): EnumDeclarationSyntax { var openBraceToken: ISyntaxToken; - return new EnumDeclarationSyntax(parseNodeData, + return new EnumDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.EnumKeyword), eatIdentifierToken(), @@ -973,7 +978,7 @@ module TypeScript.Parser { } function allowInAnd(func: () => T): T { - if (disallowInContext) { + if (inDisallowInContext()) { setDisallowInContext(false); var result = func(); setDisallowInContext(true); @@ -985,7 +990,7 @@ module TypeScript.Parser { } function disallowInAnd(func: () => T): T { - if (disallowInContext) { + if (inDisallowInContext()) { // no need to do anything special if 'in' is already disallowed. return func(); } @@ -997,7 +1002,7 @@ module TypeScript.Parser { } function enterYieldContextAnd(func: () => T): T { - if (yieldContext) { + if (inYieldContext()) { // no need to do anything special if we're already in the [Yield] context. return func(); } @@ -1009,7 +1014,7 @@ module TypeScript.Parser { } function exitYieldContextAnd(func: () => T): T { - if (yieldContext) { + if (inYieldContext()) { setYieldContext(false); var result = func(); setYieldContext(true); @@ -1019,30 +1024,6 @@ module TypeScript.Parser { // no need to do anything special if we're not in the [Yield] context. return func(); } - - function enterGeneratorParameterContextAnd(func: () => T): T { - if (generatorParameterContext) { - // no need to do anything special if we're already in the [GeneratorParameter] context - return func(); - } - - setGeneratorParameterContext(true); - var result = func(); - setGeneratorParameterContext(false); - return result; - } - - function exitGeneratorParameterContextAnd(func: () => T): T { - if (generatorParameterContext) { - setGeneratorParameterContext(false); - var result = func(); - setGeneratorParameterContext(true); - return result; - } - - // no need to do anything special if we're not in the [GeneratorParameter] context - return func(); - } function tryParseEnumElementEqualsValueClause(): EqualsValueClauseSyntax { return isEqualsValueClause(/*inParameter*/ false) ? allowInAnd(parseEqualsValueClause) : undefined; @@ -1059,7 +1040,7 @@ module TypeScript.Parser { return undefined; } - return new EnumElementSyntax(parseNodeData, parsePropertyName(), tryParseEnumElementEqualsValueClause()); + return new EnumElementSyntax(contextFlags, parsePropertyName(), tryParseEnumElementEqualsValueClause()); } function isModifierKind(kind: SyntaxKind): boolean { @@ -1133,7 +1114,7 @@ module TypeScript.Parser { // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } if (isHeritageClause()) { - return isClassHeritageClause && generatorParameterContext + return isClassHeritageClause && inGeneratorParameterContext() ? exitYieldContextAnd(parseHeritageClausesWorker) : parseHeritageClausesWorker(); } @@ -1151,7 +1132,7 @@ module TypeScript.Parser { function parseClassDeclaration(): ClassDeclarationSyntax { var openBraceToken: ISyntaxToken; - return new ClassDeclarationSyntax(parseNodeData, + return new ClassDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.ClassKeyword), eatIdentifierToken(), @@ -1168,7 +1149,7 @@ module TypeScript.Parser { // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } if (openBraceToken.fullWidth() > 0) { - return generatorParameterContext + return inGeneratorParameterContext() ? exitYieldContextAnd(parseClassElements) : parseClassElements(); } @@ -1207,16 +1188,16 @@ module TypeScript.Parser { } function parseGetAccessor(modifiers: ISyntaxToken[], getKeyword: ISyntaxToken): GetAccessorSyntax { - return new GetAccessorSyntax(parseNodeData, + return new GetAccessorSyntax(contextFlags, modifiers, consumeToken(getKeyword), parsePropertyName(), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameter:*/ false), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false), parseFunctionBody(/*isGenerator:*/ false)); } function parseSetAccessor(modifiers: ISyntaxToken[], setKeyword: ISyntaxToken): SetAccessorSyntax { - return new SetAccessorSyntax(parseNodeData, + return new SetAccessorSyntax(contextFlags, modifiers, consumeToken(setKeyword), parsePropertyName(), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameterContext:*/ false), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false), parseFunctionBody(/*isGenerator:*/ false)); } @@ -1342,10 +1323,10 @@ module TypeScript.Parser { // Note: if we see an arrow after the close paren, then try to parse out a function // block anyways. It's likely the user just though '=> expr' was legal anywhere a // block was legal. - return new ConstructorDeclarationSyntax(parseNodeData, + return new ConstructorDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.ConstructorKeyword), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameterContext:*/ false), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false), parseFunctionBody(/*isGenerator:*/ false)); } @@ -1354,18 +1335,18 @@ module TypeScript.Parser { // block anyways. It's likely the user just though '=> expr' was legal anywhere a // block was legal. var isGenerator = asteriskToken !== undefined; - return new MemberFunctionDeclarationSyntax(parseNodeData, + return new MemberFunctionDeclarationSyntax(contextFlags, modifiers, asteriskToken, propertyName, - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ isGenerator, /*generatorParameterContext:*/ isGenerator), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ isGenerator), parseFunctionBody(isGenerator)); } function parseMemberVariableDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): MemberVariableDeclarationSyntax { - return new MemberVariableDeclarationSyntax(parseNodeData, + return new MemberVariableDeclarationSyntax(contextFlags, modifiers, - new VariableDeclaratorSyntax(parseNodeData, propertyName, + new VariableDeclaratorSyntax(contextFlags, propertyName, parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false), isEqualsValueClause(/*inParameter*/ false) ? allowInAnd(parseEqualsValueClause) : undefined), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); @@ -1376,7 +1357,7 @@ module TypeScript.Parser { } function parseIndexMemberDeclaration(): IndexMemberDeclarationSyntax { - return new IndexMemberDeclarationSyntax(parseNodeData, + return new IndexMemberDeclarationSyntax(contextFlags, parseModifiers(), parseIndexSignature(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewLine:*/ false)); } @@ -1390,16 +1371,17 @@ module TypeScript.Parser { } function parseFunctionDeclarationWorker(modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, asteriskToken: ISyntaxToken): FunctionDeclarationSyntax { + // FunctionDeclaration[Yield, Default] : // function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } // GeneratorDeclaration[Yield, Default] : // function * BindingIdentifier[?Yield](FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } var isGenerator = asteriskToken !== undefined; - return new FunctionDeclarationSyntax(parseNodeData, + return new FunctionDeclarationSyntax(contextFlags, modifiers, functionKeyword, asteriskToken, eatIdentifierToken(), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ isGenerator, /*generatorParameterContext:*/ isGenerator), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ isGenerator), parseFunctionBody(isGenerator)); } @@ -1417,7 +1399,7 @@ module TypeScript.Parser { function parseModuleDeclaration(): ModuleDeclarationSyntax { var openBraceToken: ISyntaxToken; - return new ModuleDeclarationSyntax(parseNodeData, + return new ModuleDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.ModuleKeyword), parseModuleName(), @@ -1427,7 +1409,7 @@ module TypeScript.Parser { } function parseInterfaceDeclaration(): InterfaceDeclarationSyntax { - return new InterfaceDeclarationSyntax(parseNodeData, + return new InterfaceDeclarationSyntax(contextFlags, parseModifiers(), eatToken(SyntaxKind.InterfaceKeyword), eatIdentifierToken(), @@ -1439,14 +1421,14 @@ module TypeScript.Parser { function parseObjectType(): ObjectTypeSyntax { var openBraceToken: ISyntaxToken; - return new ObjectTypeSyntax(parseNodeData, + return new ObjectTypeSyntax(contextFlags, openBraceToken = eatToken(SyntaxKind.OpenBraceToken), openBraceToken.fullWidth() > 0 ? parseSeparatedSyntaxList(ListParsingState.ObjectType_TypeMembers) : [], eatToken(SyntaxKind.CloseBraceToken)); } function parseTupleType(currentToken: ISyntaxToken): TupleTypeSyntax { - return new TupleTypeSyntax(parseNodeData, + return new TupleTypeSyntax(contextFlags, consumeToken(currentToken), parseSeparatedSyntaxList(ListParsingState.TupleType_Types), eatToken(SyntaxKind.CloseBracketToken)); @@ -1503,7 +1485,7 @@ module TypeScript.Parser { // A call signature for a type member can both use 'yield' as a parameter name, and // does not have parameter initializers. So we can pass 'false' for both [Yield] // and [GeneratorParameter]. - return parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameterContext:*/ false); + return parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false); } else if (isConstructSignature()) { return parseConstructSignature(); @@ -1529,13 +1511,13 @@ module TypeScript.Parser { function parseConstructSignature(): ConstructSignatureSyntax { // Construct signatures have no [Yield] or [GeneratorParameter] restrictions. - return new ConstructSignatureSyntax(parseNodeData, + return new ConstructSignatureSyntax(contextFlags, eatToken(SyntaxKind.NewKeyword), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameterContext:*/ false)); + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false)); } function parseIndexSignature(): IndexSignatureSyntax { - return new IndexSignatureSyntax(parseNodeData, + return new IndexSignatureSyntax(contextFlags, eatToken(SyntaxKind.OpenBracketToken), parseSeparatedSyntaxList(ListParsingState.IndexSignature_Parameters), eatToken(SyntaxKind.CloseBracketToken), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); @@ -1544,14 +1526,14 @@ module TypeScript.Parser { function parseMethodSignature(propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken): MethodSignatureSyntax { // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [GeneratorParameter] - return new MethodSignatureSyntax(parseNodeData, + return new MethodSignatureSyntax(contextFlags, propertyName, questionToken, - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldContext:*/ false, /*generatorParameterContext:*/ false)); + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false)); } function parsePropertySignature(propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken): PropertySignatureSyntax { - return new PropertySignatureSyntax(parseNodeData, + return new PropertySignatureSyntax(contextFlags, propertyName, questionToken, parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); } @@ -1632,7 +1614,7 @@ module TypeScript.Parser { return undefined; } - return new HeritageClauseSyntax(parseNodeData, + return new HeritageClauseSyntax(contextFlags, consumeToken(extendsOrImplementsKeyword), parseSeparatedSyntaxList(ListParsingState.HeritageClause_TypeNameList)); } @@ -1813,7 +1795,7 @@ module TypeScript.Parser { } function parseDebuggerStatement(debuggerKeyword: ISyntaxToken): DebuggerStatementSyntax { - return new DebuggerStatementSyntax(parseNodeData, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); + return new DebuggerStatementSyntax(contextFlags, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseDoStatement(doKeyword: ISyntaxToken): DoStatementSyntax { @@ -1824,7 +1806,7 @@ module TypeScript.Parser { // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - return new DoStatementSyntax(parseNodeData, + return new DoStatementSyntax(contextFlags, consumeToken(doKeyword), parseStatement(/*inErrorRecovery:*/ false), eatToken(SyntaxKind.WhileKeyword), eatToken(SyntaxKind.OpenParenToken), allowInAnd(parseExpression), eatToken(SyntaxKind.CloseParenToken), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ true)); } @@ -1834,7 +1816,7 @@ module TypeScript.Parser { } function parseLabeledStatement(identifierToken: ISyntaxToken): LabeledStatementSyntax { - return new LabeledStatementSyntax(parseNodeData, + return new LabeledStatementSyntax(contextFlags, consumeToken(identifierToken), eatToken(SyntaxKind.ColonToken), parseStatement(/*inErrorRecovery:*/ false)); } @@ -1858,7 +1840,7 @@ module TypeScript.Parser { finallyClause = parseFinallyClause(); } - return new TryStatementSyntax(parseNodeData, tryKeyword, block, catchClause, finallyClause); + return new TryStatementSyntax(contextFlags, tryKeyword, block, catchClause, finallyClause); } function parseCatchClauseBlock(): BlockSyntax { @@ -1871,13 +1853,13 @@ module TypeScript.Parser { } function parseCatchClause(): CatchClauseSyntax { - return new CatchClauseSyntax(parseNodeData, + return new CatchClauseSyntax(contextFlags, eatToken(SyntaxKind.CatchKeyword), eatToken(SyntaxKind.OpenParenToken), eatIdentifierToken(), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false), eatToken(SyntaxKind.CloseParenToken), parseCatchClauseBlock()); } function parseFinallyClause(): FinallyClauseSyntax { - return new FinallyClauseSyntax(parseNodeData, + return new FinallyClauseSyntax(contextFlags, eatToken(SyntaxKind.FinallyKeyword), parseStatementBlock()); } @@ -1886,7 +1868,7 @@ module TypeScript.Parser { // WithStatement[Yield, Return] : // with (Expression[In, ?Yield]) Statement[?Yield, ?Return] - return new WithStatementSyntax(parseNodeData, + return new WithStatementSyntax(contextFlags, consumeToken(withKeyword), eatToken(SyntaxKind.OpenParenToken), allowInAnd(parseExpression), @@ -1898,7 +1880,7 @@ module TypeScript.Parser { // IterationStatement[Yield, Return] : // while (Expression[In, ?Yield]) Statement[?Yield, ?Return] - return new WhileStatementSyntax(parseNodeData, + return new WhileStatementSyntax(contextFlags, consumeToken(whileKeyword), eatToken(SyntaxKind.OpenParenToken), allowInAnd(parseExpression), @@ -1921,7 +1903,7 @@ module TypeScript.Parser { } function parseEmptyStatement(semicolonToken: ISyntaxToken): EmptyStatementSyntax { - return new EmptyStatementSyntax(parseNodeData, consumeToken(semicolonToken)); + return new EmptyStatementSyntax(contextFlags, consumeToken(semicolonToken)); } function parseForOrForInStatement(forKeyword: ISyntaxToken): IStatementSyntax { @@ -1957,7 +1939,7 @@ module TypeScript.Parser { // for ( var ForBinding[?Yield] in Expression[In, ?Yield] ) Statement[?Yield, ?Return] // for ( ForDeclaration[?Yield] in Expression[In, ?Yield] ) Statement[?Yield, ?Return] - return new ForInStatementSyntax(parseNodeData, + return new ForInStatementSyntax(contextFlags, forKeyword, openParenToken, initializer, eatToken(SyntaxKind.InKeyword), allowInAnd(parseExpression), eatToken(SyntaxKind.CloseParenToken), parseStatement(/*inErrorRecovery:*/ false)); } @@ -1968,7 +1950,7 @@ module TypeScript.Parser { // for (ExpressionNoInopt; Expressionopt ; Expressionopt ) Statement // for (var VariableDeclarationListNoIn; Expressionopt; Expressionopt) Statement - return new ForStatementSyntax(parseNodeData, + return new ForStatementSyntax(contextFlags, forKeyword, openParenToken, initializer, eatToken(SyntaxKind.SemicolonToken), tryParseForStatementCondition(), eatToken(SyntaxKind.SemicolonToken), tryParseForStatementIncrementor(), @@ -2014,12 +1996,12 @@ module TypeScript.Parser { } function parseBreakStatement(breakKeyword: ISyntaxToken): BreakStatementSyntax { - return new BreakStatementSyntax(parseNodeData, + return new BreakStatementSyntax(contextFlags, consumeToken(breakKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseContinueStatement(continueKeyword: ISyntaxToken): ContinueStatementSyntax { - return new ContinueStatementSyntax(parseNodeData, + return new ContinueStatementSyntax(contextFlags, consumeToken(continueKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2037,7 +2019,7 @@ module TypeScript.Parser { var openParenToken: ISyntaxToken; var openBraceToken: ISyntaxToken; - return new SwitchStatementSyntax(parseNodeData, + return new SwitchStatementSyntax(contextFlags, consumeToken(switchKeyword), openParenToken = eatToken(SyntaxKind.OpenParenToken), parseSwitchExpression(openParenToken), @@ -2082,7 +2064,7 @@ module TypeScript.Parser { // CaseClause[Yield, Return] : // case Expression[In, ?Yield] : StatementList[?Yield, ?Return]opt - return new CaseSwitchClauseSyntax(parseNodeData, + return new CaseSwitchClauseSyntax(contextFlags, consumeToken(caseKeyword), allowInAnd(parseExpression), eatToken(SyntaxKind.ColonToken), @@ -2092,14 +2074,14 @@ module TypeScript.Parser { function parseDefaultSwitchClause(defaultKeyword: ISyntaxToken): DefaultSwitchClauseSyntax { // Debug.assert(isDefaultSwitchClause()); - return new DefaultSwitchClauseSyntax(parseNodeData, + return new DefaultSwitchClauseSyntax(contextFlags, consumeToken(defaultKeyword), eatToken(SyntaxKind.ColonToken), parseSyntaxList(ListParsingState.SwitchClause_Statements)); } function parseThrowStatement(throwKeyword: ISyntaxToken): ThrowStatementSyntax { - return new ThrowStatementSyntax(parseNodeData, + return new ThrowStatementSyntax(contextFlags, consumeToken(throwKeyword), tryParseThrowStatementExpression(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2116,7 +2098,7 @@ module TypeScript.Parser { } function parseReturnStatement(returnKeyword: ISyntaxToken): ReturnStatementSyntax { - return new ReturnStatementSyntax(parseNodeData, + return new ReturnStatementSyntax(contextFlags, consumeToken(returnKeyword), tryParseReturnStatementExpression(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2145,7 +2127,7 @@ module TypeScript.Parser { // Elisionopt AssignmentExpression[In, ?Yield] if (currentToken().kind === SyntaxKind.CommaToken) { - return new OmittedExpressionSyntax(parseNodeData); + return new OmittedExpressionSyntax(contextFlags); } return allowInAnd(tryParseAssignmentExpressionOrHigher); @@ -2227,7 +2209,7 @@ module TypeScript.Parser { // ExpressionStatement[Yield] : // [lookahead not-in {{, function, class, let [ }] Expression[In, ?Yield]; - return new ExpressionStatementSyntax(parseNodeData, + return new ExpressionStatementSyntax(contextFlags, allowInAnd(parseExpression), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2237,7 +2219,7 @@ module TypeScript.Parser { // if (Expression[In, ?Yield]) Statement[?Yield, ?Return] else Statement[?Yield, ?Return] // if (Expression[In, ?Yield]) Statement[?Yield, ?Return] - return new IfStatementSyntax(parseNodeData, + return new IfStatementSyntax(contextFlags, consumeToken(ifKeyword), eatToken(SyntaxKind.OpenParenToken), allowInAnd(parseExpression), @@ -2250,7 +2232,7 @@ module TypeScript.Parser { } function parseElseClause(): ElseClauseSyntax { - return new ElseClauseSyntax(parseNodeData, eatToken(SyntaxKind.ElseKeyword), parseStatement(/*inErrorRecovery:*/ false)); + return new ElseClauseSyntax(contextFlags, eatToken(SyntaxKind.ElseKeyword), parseStatement(/*inErrorRecovery:*/ false)); } function isVariableStatement(modifierCount: number): boolean { @@ -2261,14 +2243,14 @@ module TypeScript.Parser { // VariableStatement[Yield] : // var VariableDeclarationList[In, ?Yield]; - return new VariableStatementSyntax(parseNodeData, + return new VariableStatementSyntax(contextFlags, parseModifiers(), allowInAnd(parseVariableDeclaration), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseVariableDeclaration(): VariableDeclarationSyntax { // Debug.assert(currentToken().kind === SyntaxKind.VarKeyword); - return new VariableDeclarationSyntax(parseNodeData, + return new VariableDeclarationSyntax(contextFlags, eatToken(SyntaxKind.VarKeyword), parseSeparatedSyntaxList(ListParsingState.VariableDeclaration_VariableDeclarators)); } @@ -2328,7 +2310,7 @@ module TypeScript.Parser { } } - return new VariableDeclaratorSyntax(parseNodeData, propertyName, typeAnnotation, equalsValueClause); + return new VariableDeclaratorSyntax(contextFlags, propertyName, typeAnnotation, equalsValueClause); } function isEqualsValueClause(inParameter: boolean): boolean { @@ -2372,7 +2354,7 @@ module TypeScript.Parser { // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - return new EqualsValueClauseSyntax(parseNodeData, + return new EqualsValueClauseSyntax(contextFlags, eatToken(SyntaxKind.EqualsToken), parseAssignmentExpressionOrHigher()); } @@ -2389,7 +2371,7 @@ module TypeScript.Parser { break; } - leftOperand = new BinaryExpressionSyntax(parseNodeData, + leftOperand = new BinaryExpressionSyntax(contextFlags, leftOperand, consumeToken(_currentToken), parseAssignmentExpressionOrHigher()); @@ -2411,8 +2393,6 @@ module TypeScript.Parser { // precedence than 'comma'. Otherwise we'll get: "var a = (1, (b = 2))", instead of // "var a = (1), b = (2)"); function tryParseAssignmentExpressionOrHigherWorker(force: boolean): IExpressionSyntax { - // Augmented by TypeScript: - // // AssignmentExpression[in,yield]: // 1) ConditionalExpression[?in,?yield] // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] @@ -2458,7 +2438,7 @@ module TypeScript.Parser { // Check for recursive assignment expressions. if (SyntaxFacts.isAssignmentOperatorToken(operatorToken.kind)) { - return new BinaryExpressionSyntax(parseNodeData, + return new BinaryExpressionSyntax(contextFlags, leftOperand, consumeToken(operatorToken), parseAssignmentExpressionOrHigher()); @@ -2473,11 +2453,11 @@ module TypeScript.Parser { if (_currentToken.kind === SyntaxKind.YieldKeyword) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. - if (yieldContext) { + if (inYieldContext()) { return true; } - if (strictModeContext) { + if (inStrictModeContext()) { // If we're in strict mode, then 'yield' is a keyword, could only ever start // a yield expression. return true; @@ -2518,12 +2498,12 @@ module TypeScript.Parser { if (!isOnDifferentLineThanPreviousToken(_currentToken) && (_currentToken.kind === SyntaxKind.AsteriskToken || isExpression(_currentToken))) { - return new YieldExpressionSyntax(parseNodeData, yieldKeyword, tryEatToken(SyntaxKind.AsteriskToken), parseAssignmentExpressionOrHigher()); + return new YieldExpressionSyntax(contextFlags, yieldKeyword, tryEatToken(SyntaxKind.AsteriskToken), parseAssignmentExpressionOrHigher()); } else { // if the next token is not on the same line as yield. or we don't have an '*' or // the start of an expressin, then this is just a simple "yield" expression. - return new YieldExpressionSyntax(parseNodeData, yieldKeyword, /*asterixToken:*/ undefined, /*expression;*/ undefined); + return new YieldExpressionSyntax(contextFlags, yieldKeyword, /*asterixToken:*/ undefined, /*expression;*/ undefined); } } @@ -2543,7 +2523,7 @@ module TypeScript.Parser { case SyntaxKind.ExclamationToken: case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - return new PrefixUnaryExpressionSyntax(parseNodeData, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new PrefixUnaryExpressionSyntax(contextFlags, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); case SyntaxKind.TypeOfKeyword: return parseTypeOfExpression(_currentToken); case SyntaxKind.VoidKeyword: return parseVoidExpression(_currentToken); case SyntaxKind.DeleteKeyword: return parseDeleteExpression(_currentToken); @@ -2583,7 +2563,7 @@ module TypeScript.Parser { // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - return new ConditionalExpressionSyntax(parseNodeData, + return new ConditionalExpressionSyntax(contextFlags, leftOperand, consumeToken(_currentToken), allowInAnd(parseAssignmentExpressionOrHigher), @@ -2610,7 +2590,7 @@ module TypeScript.Parser { } // also, if it's the 'in' operator, only allow if our caller allows it. - if (tokenKind === SyntaxKind.InKeyword && disallowInContext) { + if (tokenKind === SyntaxKind.InKeyword && inDisallowInContext()) { break; } @@ -2627,7 +2607,7 @@ module TypeScript.Parser { // Precedence is okay, so we'll "take" this operator. // Now skip the operator token we're on. - leftOperand = new BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), + leftOperand = new BinaryExpressionSyntax(contextFlags, leftOperand, consumeToken(operatorToken), tryParseBinaryExpressionOrHigher(currentToken(), /*force:*/ true, newPrecedence)); } @@ -2713,7 +2693,7 @@ module TypeScript.Parser { switch (currentTokenKind) { case SyntaxKind.OpenParenToken: - expression = new InvocationExpressionSyntax(parseNodeData, expression, parseArgumentList(/*typeArgumentList:*/ undefined, _currentToken)); + expression = new InvocationExpressionSyntax(contextFlags, expression, parseArgumentList(/*typeArgumentList:*/ undefined, _currentToken)); continue; case SyntaxKind.LessThanToken: @@ -2726,7 +2706,7 @@ module TypeScript.Parser { break; } - expression = new InvocationExpressionSyntax(parseNodeData, expression, argumentList); + expression = new InvocationExpressionSyntax(contextFlags, expression, argumentList); continue; case SyntaxKind.OpenBracketToken: @@ -2734,12 +2714,12 @@ module TypeScript.Parser { continue; case SyntaxKind.DotToken: - expression = new MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + expression = new MemberAccessExpressionSyntax(contextFlags, expression, consumeToken(_currentToken), eatIdentifierNameToken()); continue; case SyntaxKind.NoSubstitutionTemplateToken: case SyntaxKind.TemplateStartToken: - expression = new TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); + expression = new TemplateAccessExpressionSyntax(contextFlags, expression, parseTemplateExpression(_currentToken)); continue; } @@ -2758,12 +2738,12 @@ module TypeScript.Parser { continue; case SyntaxKind.DotToken: - expression = new MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + expression = new MemberAccessExpressionSyntax(contextFlags, expression, consumeToken(_currentToken), eatIdentifierNameToken()); continue; case SyntaxKind.NoSubstitutionTemplateToken: case SyntaxKind.TemplateStartToken: - expression = new TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); + expression = new TemplateAccessExpressionSyntax(contextFlags, expression, parseTemplateExpression(_currentToken)); continue; } @@ -2827,7 +2807,7 @@ module TypeScript.Parser { var currentTokenKind = currentToken().kind; return currentTokenKind === SyntaxKind.OpenParenToken || currentTokenKind === SyntaxKind.DotToken ? expression - : new MemberAccessExpressionSyntax(parseNodeData, expression, eatToken(SyntaxKind.DotToken), eatIdentifierNameToken()); + : new MemberAccessExpressionSyntax(contextFlags, expression, eatToken(SyntaxKind.DotToken), eatIdentifierNameToken()); } function tryParsePostfixExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IPostfixExpressionSyntax { @@ -2848,7 +2828,7 @@ module TypeScript.Parser { break; } - return new PostfixUnaryExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken)); + return new PostfixUnaryExpressionSyntax(contextFlags, expression, consumeToken(_currentToken)); } return expression; @@ -2887,7 +2867,7 @@ module TypeScript.Parser { // we'll bail out here and give a poor error message when we try to parse this // as an arithmetic expression. if (isDot) { - return new ArgumentListSyntax(parseNodeData, typeArgumentList, + return new ArgumentListSyntax(contextFlags, typeArgumentList, createMissingToken(SyntaxKind.OpenParenToken, undefined, DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected), [], eatToken(SyntaxKind.CloseParenToken)); @@ -2916,7 +2896,7 @@ module TypeScript.Parser { function parseArgumentList(typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken): ArgumentListSyntax { Debug.assert(openParenToken.kind === SyntaxKind.OpenParenToken && openParenToken.fullWidth() > 0); - return new ArgumentListSyntax(parseNodeData, + return new ArgumentListSyntax(contextFlags, typeArgumentList, consumeToken(openParenToken), parseSeparatedSyntaxList(ListParsingState.ArgumentList_AssignmentExpressions), @@ -2948,7 +2928,7 @@ module TypeScript.Parser { function parseElementAccessExpression(expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken): ElementAccessExpressionSyntax { // Debug.assert(currentToken().kind === SyntaxKind.OpenBracketToken); - return new ElementAccessExpressionSyntax(parseNodeData, expression, consumeToken(openBracketToken), + return new ElementAccessExpressionSyntax(contextFlags, expression, consumeToken(openBracketToken), parseElementAccessArgumentExpression(openBracketToken), eatToken(SyntaxKind.CloseBracketToken)); } @@ -3016,15 +2996,15 @@ module TypeScript.Parser { } function parseTypeOfExpression(typeOfKeyword: ISyntaxToken): TypeOfExpressionSyntax { - return new TypeOfExpressionSyntax(parseNodeData, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new TypeOfExpressionSyntax(contextFlags, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseDeleteExpression(deleteKeyword: ISyntaxToken): DeleteExpressionSyntax { - return new DeleteExpressionSyntax(parseNodeData, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new DeleteExpressionSyntax(contextFlags, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseVoidExpression(voidKeyword: ISyntaxToken): VoidExpressionSyntax { - return new VoidExpressionSyntax(parseNodeData, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new VoidExpressionSyntax(contextFlags, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseFunctionExpression(functionKeyword: ISyntaxToken): FunctionExpressionSyntax { @@ -3034,13 +3014,15 @@ module TypeScript.Parser { function parseFunctionExpressionWorker(functionKeyword: ISyntaxToken, asteriskToken: ISyntaxToken) { // GeneratorExpression : // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // FunctionExpression: + // function BindingIdentifieropt(FormalParameters) { FunctionBody } var isGenerator = asteriskToken !== undefined; - return new FunctionExpressionSyntax(parseNodeData, + return new FunctionExpressionSyntax(contextFlags, functionKeyword, asteriskToken, - enterYieldContextAnd(eatOptionalIdentifierToken), - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yield:*/ isGenerator, /*generatorParameter:*/ isGenerator), + asteriskToken ? enterYieldContextAnd(eatOptionalIdentifierToken) : eatOptionalIdentifierToken(), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ isGenerator), parseFunctionBody(isGenerator)); } @@ -3054,7 +3036,7 @@ module TypeScript.Parser { // See comment in tryParseMemberExpressionOrHigher for a more complete explanation of // this decision. - return new ObjectCreationExpressionSyntax(parseNodeData, + return new ObjectCreationExpressionSyntax(contextFlags, consumeToken(newKeyword), tryParseMemberExpressionOrHigher(currentToken(), /*force:*/ true), tryParseArgumentList()); } @@ -3074,7 +3056,7 @@ module TypeScript.Parser { } while (templateClauses[templateClauses.length - 1].templateMiddleOrEndToken.kind === SyntaxKind.TemplateMiddleToken); - return new TemplateExpressionSyntax(parseNodeData, startToken, Syntax.list(templateClauses)); + return new TemplateExpressionSyntax(contextFlags, startToken, Syntax.list(templateClauses)); } function parseTemplateClause(): TemplateClauseSyntax { @@ -3095,18 +3077,18 @@ module TypeScript.Parser { token = createMissingToken(SyntaxKind.TemplateEndToken, undefined, DiagnosticCode._0_expected, ["{"]); } - return new TemplateClauseSyntax(parseNodeData, expression, token); + return new TemplateClauseSyntax(contextFlags, expression, token); } function parseCastExpression(lessThanToken: ISyntaxToken): CastExpressionSyntax { - return new CastExpressionSyntax(parseNodeData, + return new CastExpressionSyntax(contextFlags, consumeToken(lessThanToken), parseType(), eatToken(SyntaxKind.GreaterThanToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseParenthesizedExpression(openParenToken: ISyntaxToken): ParenthesizedExpressionSyntax { // ( Expression[In, ?Yield] ) - return new ParenthesizedExpressionSyntax(parseNodeData, + return new ParenthesizedExpressionSyntax(contextFlags, consumeToken(openParenToken), allowInAnd(parseExpression), eatToken(SyntaxKind.CloseParenToken)); @@ -3155,23 +3137,20 @@ module TypeScript.Parser { var _currentToken = currentToken(); // Debug.assert(currentToken.kind === SyntaxKind.OpenParenToken || currentToken.kind === SyntaxKind.LessThanToken); - // Note: ES6 specifies the formal parametes of an arrow function like this: - // - // ArrowFormalParameters[Yield, GeneratorParameter] : - // (StrictFormalParameters[?Yield, ?GeneratorParameter]) - // - // However, the 'GeneratorParameter' portion appears to be a spec bug. There does not - // appear to be any way for that value to be passed in through any grammar constructs. - // - // [Yield], on the other hand, is available, and is passed through. - - var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ true, /*yield:*/ yieldContext, /*generatorParameter:*/ false); + // From the static semantic section: + // 1.If the [Yield] grammar parameter is present for CoverParenthesizedExpressionAndArrowParameterList[Yield] + // return the result of parsing the lexical token stream matched by CoverParenthesizedExpressionAndArrowParameterList[Yield] + // using ArrowFormalParameters[Yield, GeneratorParameter] as the goal symbol. + // 2.If the [Yield] grammar parameter is not present for CoverParenthesizedExpressionAndArrowParameterList[Yield] + // return the result of parsing the lexical token stream matched by CoverParenthesizedExpressionAndArrowParameterList + // using ArrowFormalParameters as the goal symbol. + var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ true, /*yieldAndGeneratorParameterContext:*/ inYieldContext()); if (requireArrow && currentToken().kind !== SyntaxKind.EqualsGreaterThanToken) { return undefined; } - return new ParenthesizedArrowFunctionExpressionSyntax(parseNodeData, + return new ParenthesizedArrowFunctionExpressionSyntax(contextFlags, callSignature, eatToken(SyntaxKind.EqualsGreaterThanToken), parseArrowFunctionBody()); @@ -3202,7 +3181,7 @@ module TypeScript.Parser { // We've seen a statement (and it isn't an expressionStatement like 'foo()'), so // treat this like a block with a missing open brace. - return new BlockSyntax(parseNodeData, + return new BlockSyntax(contextFlags, /*equalsGreaterThanToken*/ undefined, eatToken(SyntaxKind.OpenBraceToken), parseFunctionBlockStatements(), @@ -3226,7 +3205,7 @@ module TypeScript.Parser { function parseSimpleArrowFunctionExpression(): SimpleArrowFunctionExpressionSyntax { // Debug.assert(isSimpleArrowFunctionExpression()); - return new SimpleArrowFunctionExpressionSyntax(parseNodeData, + return new SimpleArrowFunctionExpressionSyntax(contextFlags, eatSimpleParameter(), eatToken(SyntaxKind.EqualsGreaterThanToken), parseArrowFunctionBody()); @@ -3403,7 +3382,7 @@ module TypeScript.Parser { function parseObjectLiteralExpression(openBraceToken: ISyntaxToken): ObjectLiteralExpressionSyntax { // Debug.assert(currentToken().kind === SyntaxKind.OpenBraceToken); - return new ObjectLiteralExpressionSyntax(parseNodeData, + return new ObjectLiteralExpressionSyntax(contextFlags, consumeToken(openBraceToken), parseSeparatedSyntaxList(ListParsingState.ObjectLiteralExpression_PropertyAssignments), eatToken(SyntaxKind.CloseBraceToken)); @@ -3463,7 +3442,7 @@ module TypeScript.Parser { // // Also, if we have an identifier and it is followed by a colon then this is // definitely a simple property assignment. - return new SimplePropertyAssignmentSyntax(parseNodeData, + return new SimplePropertyAssignmentSyntax(contextFlags, propertyName, eatToken(SyntaxKind.ColonToken), allowInAnd(parseAssignmentExpressionOrHigher)); @@ -3527,7 +3506,7 @@ module TypeScript.Parser { var _currentToken = currentToken(); if (_currentToken.kind === SyntaxKind.OpenBracketToken) { - return generatorParameterContext + return inGeneratorParameterContext() ? exitYieldContextAnd(parseComputedPropertyName) : parseComputedPropertyName(); } @@ -3548,7 +3527,7 @@ module TypeScript.Parser { // ComputedPropertyName[Yield] : // [AssignmentExpression[In, ?Yield]] - return new ComputedPropertyNameSyntax(parseNodeData, + return new ComputedPropertyNameSyntax(contextFlags, eatToken(SyntaxKind.OpenBracketToken), allowInAnd(parseAssignmentExpressionOrHigher), eatToken(SyntaxKind.CloseBracketToken)); @@ -3556,16 +3535,16 @@ module TypeScript.Parser { function parseFunctionPropertyAssignment(asteriskToken: ISyntaxToken, propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax { var isGenerator = asteriskToken !== undefined; - return new FunctionPropertyAssignmentSyntax(parseNodeData, + return new FunctionPropertyAssignmentSyntax(contextFlags, asteriskToken, propertyName, - parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yield:*/ isGenerator, /*generatorParameter:*/ isGenerator), + parseCallSignature(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ isGenerator), parseFunctionBody(isGenerator)); } function parseArrayLiteralExpression(openBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax { // Debug.assert(currentToken().kind === SyntaxKind.OpenBracketToken); - return new ArrayLiteralExpressionSyntax(parseNodeData, + return new ArrayLiteralExpressionSyntax(contextFlags, consumeToken(openBracketToken), parseSeparatedSyntaxList(ListParsingState.ArrayLiteralExpression_AssignmentExpressions), eatToken(SyntaxKind.CloseBracketToken)); @@ -3575,7 +3554,7 @@ module TypeScript.Parser { // Different from function blocks in that we don't check for strict mode, nor do accept // a block without an open curly. var openBraceToken: ISyntaxToken; - return new BlockSyntax(parseNodeData, + return new BlockSyntax(contextFlags, tryEatToken(SyntaxKind.EqualsGreaterThanToken), openBraceToken = eatToken(SyntaxKind.OpenBraceToken), openBraceToken.fullWidth() > 0 ? parseSyntaxList(ListParsingState.Block_Statements) : [], @@ -3591,7 +3570,7 @@ module TypeScript.Parser { // check if they wrote something like: => expr // or if it was more like : => statement if (isExpression(currentToken())) { - return new ExpressionBody(parseNodeData, equalsGreaterThanToken, parseExpression()); + return new ExpressionBody(contextFlags, equalsGreaterThanToken, parseExpression()); } } @@ -3600,7 +3579,7 @@ module TypeScript.Parser { function parseFunctionBlock(_allowYield: boolean, equalsGreaterThanToken: ISyntaxToken): BlockSyntax { var openBraceToken: ISyntaxToken; - return new BlockSyntax(parseNodeData, + return new BlockSyntax(contextFlags, equalsGreaterThanToken, openBraceToken = eatToken(SyntaxKind.OpenBraceToken), equalsGreaterThanToken || openBraceToken.fullWidth() > 0 @@ -3610,17 +3589,17 @@ module TypeScript.Parser { } function parseFunctionBlockStatements() { - var savedIsInStrictMode = strictModeContext; + var savedIsInStrictMode = inStrictModeContext(); var statements = parseSyntaxList(ListParsingState.Block_Statements, updateStrictModeState); setStrictModeContext(savedIsInStrictMode); return statements; } - function parseCallSignature(requireCompleteTypeParameterList: boolean, _yieldContext: boolean, _generatorParameterContext: boolean): CallSignatureSyntax { - return new CallSignatureSyntax(parseNodeData, + function parseCallSignature(requireCompleteTypeParameterList: boolean, yieldAndGeneratorParameterContext: boolean): CallSignatureSyntax { + return new CallSignatureSyntax(contextFlags, tryParseTypeParameterList(requireCompleteTypeParameterList), - parseParameterList(_yieldContext, _generatorParameterContext), + parseParameterList(yieldAndGeneratorParameterContext), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); } @@ -3645,7 +3624,7 @@ module TypeScript.Parser { } else { releaseRewindPoint(rewindPoint); - return new TypeParameterListSyntax(parseNodeData, lessThanToken, typeParameters, greaterThanToken); + return new TypeParameterListSyntax(contextFlags, lessThanToken, typeParameters, greaterThanToken); } } @@ -3659,7 +3638,7 @@ module TypeScript.Parser { return undefined; } - return new TypeParameterSyntax(parseNodeData, eatIdentifierToken(), tryParseConstraint()); + return new TypeParameterSyntax(contextFlags, eatIdentifierToken(), tryParseConstraint()); } function tryParseConstraint(): ConstraintSyntax { @@ -3667,10 +3646,14 @@ module TypeScript.Parser { return undefined; } - return new ConstraintSyntax(parseNodeData, eatToken(SyntaxKind.ExtendsKeyword), parseTypeOrExpression()); + return new ConstraintSyntax(contextFlags, eatToken(SyntaxKind.ExtendsKeyword), parseTypeOrExpression()); } - function parseParameterList(_yieldContext: boolean, _generatorParameterContext: boolean): ParameterListSyntax { + // Note: after careful analysis of the grammar, it does not appear to be possible to + // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling + // this FormalParameters production either always sets both to true, or always sets + // both to false. As such we only have a single parameter to represent both. + function parseParameterList(yieldAndGeneratorParameterContext: boolean): ParameterListSyntax { // FormalParameters[Yield,GeneratorParameter] : // ... // @@ -3686,14 +3669,15 @@ module TypeScript.Parser { // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - var savedYieldContext = yieldContext; - var savedGeneratorParameterContext = generatorParameterContext; - setYieldContext(_yieldContext); - setGeneratorParameterContext(_generatorParameterContext); + var savedYieldContext = inYieldContext(); + var savedGeneratorParameterContext = inGeneratorParameterContext(); + + setYieldContext(yieldAndGeneratorParameterContext); + setGeneratorParameterContext(yieldAndGeneratorParameterContext); var openParenToken: ISyntaxToken; - var result = new ParameterListSyntax(parseNodeData, + var result = new ParameterListSyntax(contextFlags, openParenToken = eatToken(SyntaxKind.OpenParenToken), openParenToken.fullWidth() > 0 ? parseSeparatedSyntaxList(ListParsingState.ParameterList_Parameters) : [], eatToken(SyntaxKind.CloseParenToken)); @@ -3720,7 +3704,7 @@ module TypeScript.Parser { } function parseTypeAnnotation(allowStringLiteral: boolean): TypeAnnotationSyntax { - return new TypeAnnotationSyntax(parseNodeData, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); + return new TypeAnnotationSyntax(contextFlags, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); } function isType(): boolean { @@ -3772,8 +3756,8 @@ module TypeScript.Parser { function tryParseType(): ITypeSyntax { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - var savedYieldContext = yieldContext; - var savedGeneratorParameterContext = generatorParameterContext; + var savedYieldContext = inYieldContext(); + var savedGeneratorParameterContext = inGeneratorParameterContext(); setYieldContext(false); setGeneratorParameterContext(false); @@ -3804,7 +3788,7 @@ module TypeScript.Parser { if (type) { var barToken: ISyntaxToken; while ((barToken = currentToken()).kind === SyntaxKind.BarToken) { - type = new UnionTypeSyntax(parseNodeData, type, consumeToken(barToken), parsePrimaryType()); + type = new UnionTypeSyntax(contextFlags, type, consumeToken(barToken), parsePrimaryType()); } } @@ -3832,14 +3816,14 @@ module TypeScript.Parser { break; } - type = new ArrayTypeSyntax(parseNodeData, type, consumeToken(_currentToken), eatToken(SyntaxKind.CloseBracketToken)); + type = new ArrayTypeSyntax(contextFlags, type, consumeToken(_currentToken), eatToken(SyntaxKind.CloseBracketToken)); } return type; } function parseTypeQuery(typeOfKeyword: ISyntaxToken): TypeQuerySyntax { - return new TypeQuerySyntax(parseNodeData, consumeToken(typeOfKeyword), parseName(/*allowIdentifierNames:*/ true)); + return new TypeQuerySyntax(contextFlags, consumeToken(typeOfKeyword), parseName(/*allowIdentifierNames:*/ true)); } function tryParseNonArrayType(): ITypeSyntax { @@ -3867,7 +3851,7 @@ module TypeScript.Parser { } function parseParenthesizedType(openParenToken: ISyntaxToken): ParenthesizedTypeSyntax { - return new ParenthesizedTypeSyntax(parseNodeData, consumeToken(openParenToken), parseType(), eatToken(SyntaxKind.CloseParenToken)); + return new ParenthesizedTypeSyntax(contextFlags, consumeToken(openParenToken), parseType(), eatToken(SyntaxKind.CloseParenToken)); } function tryParseNameOrGenericType(): ITypeSyntax { @@ -3887,7 +3871,7 @@ module TypeScript.Parser { var typeArgumentList = tryParseTypeArgumentList(/*inExpression:*/ false); return !typeArgumentList ? name - : new GenericTypeSyntax(parseNodeData, name, typeArgumentList); + : new GenericTypeSyntax(contextFlags, name, typeArgumentList); } function isFunctionType(): boolean { @@ -3955,19 +3939,19 @@ module TypeScript.Parser { function parseFunctionType(): FunctionTypeSyntax { // Function types only exist in the type space and not the expression space. So they // aren't in the [Yield] or [GeneratorParameter] context. - return new FunctionTypeSyntax(parseNodeData, + return new FunctionTypeSyntax(contextFlags, tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false), - parseParameterList(/*yield:*/ false, /*generatorParameter:*/ false), + parseParameterList(/*yieldAndGeneratorParameterContext:*/ false), eatToken(SyntaxKind.EqualsGreaterThanToken), parseType()); } function parseConstructorType(): ConstructorTypeSyntax { // Constructor types only exist in the type space and not the expression space. So they // aren't in the [Yield] or [GeneratorParameter] context. - return new ConstructorTypeSyntax(parseNodeData, + return new ConstructorTypeSyntax(contextFlags, eatToken(SyntaxKind.NewKeyword), tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false), - parseParameterList(/*yield:*/ false, /*generatorParameter:*/ false), + parseParameterList(/*yieldAndGeneratorParameterContext:*/ false), eatToken(SyntaxKind.EqualsGreaterThanToken), parseType()); } @@ -3987,7 +3971,7 @@ module TypeScript.Parser { } function eatSimpleParameter() { - return new ParameterSyntax(parseNodeData, + return new ParameterSyntax(contextFlags, /*dotDotDotToken:*/ undefined, /*modifiers:*/ [], eatIdentifierToken(), /*questionToken:*/ undefined, /*typeAnnotation:*/ undefined, /*equalsValueClause:*/ undefined); } @@ -4022,7 +4006,7 @@ module TypeScript.Parser { // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - var identifier = generatorParameterContext + var identifier = inGeneratorParameterContext() ? enterYieldContextAnd(eatIdentifierToken) : eatIdentifierToken(); @@ -4031,12 +4015,12 @@ module TypeScript.Parser { var equalsValueClause: EqualsValueClauseSyntax = undefined; if (isEqualsValueClause(/*inParameter*/ true)) { - equalsValueClause = generatorParameterContext + equalsValueClause = inGeneratorParameterContext() ? exitYieldContextAnd(parseEqualsValueClause) : parseEqualsValueClause(); } - return new ParameterSyntax(parseNodeData, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + return new ParameterSyntax(contextFlags, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); } function parseSyntaxList(currentListType: ListParsingState, processItems?: (items: any[]) => void): T[] { @@ -4413,7 +4397,7 @@ module TypeScript.Parser { } function isExpectedVariableDeclaration_VariableDeclaratorsTerminator(): boolean { - if (disallowInContext) { + if (inDisallowInContext()) { // This is the case when we're parsing variable declarations in a for/for-in statement. var tokenKind = currentToken().kind; diff --git a/src/services/syntax/syntaxElement.ts b/src/services/syntax/syntaxElement.ts index fe10dcb23f956..e14ecf33b69a4 100644 --- a/src/services/syntax/syntaxElement.ts +++ b/src/services/syntax/syntaxElement.ts @@ -17,40 +17,29 @@ module TypeScript { return undefined; } - export function parsedInStrictModeContext(node: ISyntaxNode): boolean { + export function parserContextFlags(node: ISyntaxNode): ParserContextFlags { var info = node.__data; if (info === undefined) { - return false; + return 0; } - return (info & SyntaxNodeConstants.ParsedInStrictModeContext) !== 0; + return info & ParserContextFlags.Mask; } - export function parsedInDisallowInContext(node: ISyntaxNode): boolean { - var info = node.__data; - if (info === undefined) { - return false; - } + export function parsedInStrictModeContext(node: ISyntaxNode): boolean { + return (parserContextFlags(node) & ParserContextFlags.StrictMode) !== 0; + } - return (info & SyntaxNodeConstants.ParsedInDisallowInContext) !== 0; + export function parsedInDisallowInContext(node: ISyntaxNode): boolean { + return (parserContextFlags(node) & ParserContextFlags.DisallowIn) !== 0; } export function parsedInYieldContext(node: ISyntaxNode): boolean { - var info = node.__data; - if (info === undefined) { - return false; - } - - return (info & SyntaxNodeConstants.ParsedInYieldContext) !== 0; + return (parserContextFlags(node) & ParserContextFlags.Yield) !== 0; } export function parsedInGeneratorParameterContext(node: ISyntaxNode): boolean { - var info = node.__data; - if (info === undefined) { - return false; - } - - return (info & SyntaxNodeConstants.ParsedInGeneratorParameterContext) !== 0; + return (parserContextFlags(node) & ParserContextFlags.GeneratorParameter) !== 0; } export function previousToken(token: ISyntaxToken): ISyntaxToken { diff --git a/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt new file mode 100644 index 0000000000000..ba7154a929808 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName10_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts(2,8): error TS1005: ';' expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts (1 errors) ==== + class C { + [e] = 1 + ~ +!!! error TS1005: ';' expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt new file mode 100644 index 0000000000000..3f96913c1d583 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName11_es6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,7): error TS1005: ';' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(2,8): error TS1109: Expression expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts (3 errors) ==== + class C { + [e](); + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1109: Expression expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt new file mode 100644 index 0000000000000..fefff058fe127 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName12_es6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,7): error TS1005: ';' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(2,10): error TS1005: '=>' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts (3 errors) ==== + class C { + [e]() { } + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1005: '=>' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt new file mode 100644 index 0000000000000..3f8c10fc6431d --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName13_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts(1,11): error TS1022: An index signature parameter must have a type annotation. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts (1 errors) ==== + var v: { [e]: number }; + ~ +!!! error TS1022: An index signature parameter must have a type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt new file mode 100644 index 0000000000000..7d6052b4179c4 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName14_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts(1,13): error TS1005: ';' expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts (1 errors) ==== + var v: { [e](): number }; + ~ +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt new file mode 100644 index 0000000000000..689df40f985c0 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName15_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts(1,32): error TS1022: An index signature parameter must have a type annotation. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts (1 errors) ==== + var v: { [e: number]: string; [e]: number }; + ~ +!!! error TS1022: An index signature parameter must have a type annotation. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt new file mode 100644 index 0000000000000..c3de61ddf079e --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName16_es6.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS1132: Enum member expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,3): error TS2364: Invalid left-hand side of assignment expression. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts(2,4): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts (4 errors) ==== + enum E { + [e] = 1 + ~ +!!! error TS1132: Enum member expected. + ~~~ +!!! error TS2364: Invalid left-hand side of assignment expression. + ~ +!!! error TS2304: Cannot find name 'e'. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt new file mode 100644 index 0000000000000..4b8caf1e62dce --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName17_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,15): error TS1003: Identifier expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,22): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts(1,16): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts (4 errors) ==== + var v = { set [e](v) { } } + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt new file mode 100644 index 0000000000000..8e409750b5c73 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName18_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts(1,13): error TS1005: ';' expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts (1 errors) ==== + var v: { [e]?(): number }; + ~ +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt new file mode 100644 index 0000000000000..1833deef7896d --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName19_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts(1,13): error TS1005: ';' expected. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts (1 errors) ==== + var v: { [e]? }; + ~ +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt new file mode 100644 index 0000000000000..260ff20dc3656 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName1_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,11): error TS1136: Property assignment expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,15): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts(1,12): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts (3 errors) ==== + var v = { [e] }; + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt new file mode 100644 index 0000000000000..f0a06ef84bcd2 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName2_es6.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,11): error TS1136: Property assignment expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,14): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,16): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,18): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts(1,12): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts (5 errors) ==== + var v = { [e]: 1 }; + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1134: Variable declaration expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt new file mode 100644 index 0000000000000..3f1e5d707a841 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName3_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,11): error TS1136: Property assignment expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,17): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,21): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts(1,12): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts (4 errors) ==== + var v = { [e]() { } }; + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt new file mode 100644 index 0000000000000..a1f22f611f95d --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName4_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,15): error TS1003: Identifier expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,21): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,25): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts(1,16): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts (4 errors) ==== + var v = { get [e]() { } }; + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt new file mode 100644 index 0000000000000..2ce2faaee6271 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName5_es6.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS1005: ':' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,28): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,32): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,18): error TS2304: Cannot find name 'get'. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts(1,23): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts (5 errors) ==== + var v = { public get [e]() { } }; + ~~~ +!!! error TS1005: ':' expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt new file mode 100644 index 0000000000000..ca6bce482958e --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName6_es6.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,11): error TS1136: Property assignment expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,14): error TS1005: ',' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,16): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,26): error TS1005: ';' expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,30): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,12): error TS2304: Cannot find name 'e'. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,20): error TS2304: Cannot find name 'e'. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts(1,24): error TS2304: Cannot find name 'e'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts (8 errors) ==== + var v = { [e]: 1, [e + e]: 2 }; + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1134: Variable declaration expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'e'. + ~ +!!! error TS2304: Cannot find name 'e'. + ~ +!!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt new file mode 100644 index 0000000000000..00be8f610e024 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName7_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts (1 errors) ==== + class C { + [e] + ~ +!!! error TS1022: An index signature parameter must have a type annotation. + } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt new file mode 100644 index 0000000000000..58386bbe17774 --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName8_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts(2,12): error TS1022: An index signature parameter must have a type annotation. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts (1 errors) ==== + class C { + public [e] + ~ +!!! error TS1022: An index signature parameter must have a type annotation. + } \ No newline at end of file diff --git a/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt b/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt new file mode 100644 index 0000000000000..0872f69aebe8f --- /dev/null +++ b/tests/baselines/reference/ComputedPropertyName9_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,5): error TS1022: An index signature parameter must have a type annotation. +tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts(2,9): error TS2304: Cannot find name 'Type'. + + +==== tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts (2 errors) ==== + class C { + [e]: Type + ~ +!!! error TS1022: An index signature parameter must have a type annotation. + ~~~~ +!!! error TS2304: Cannot find name 'Type'. + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js new file mode 100644 index 0000000000000..5169453396463 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -0,0 +1,8 @@ +//// [FunctionDeclaration10_es6.ts] +function * foo(a = yield => yield) { +} + +//// [FunctionDeclaration10_es6.js] +function foo(a) { + if (a === void 0) { a = function (yield) { return yield; }; } +} diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.types b/tests/baselines/reference/FunctionDeclaration10_es6.types new file mode 100644 index 0000000000000..973de97fab165 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration10_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts === +function * foo(a = yield => yield) { +>foo : (a?: (yield: any) => any) => void +>a : (yield: any) => any +>yield => yield : (yield: any) => any +>yield : any +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.js b/tests/baselines/reference/FunctionDeclaration11_es6.js new file mode 100644 index 0000000000000..ba497b3e529d7 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration11_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration11_es6.ts] +function * yield() { +} + +//// [FunctionDeclaration11_es6.js] +function yield() { +} diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.types b/tests/baselines/reference/FunctionDeclaration11_es6.types new file mode 100644 index 0000000000000..f57a385c3592a --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration11_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts === +function * yield() { +>yield : () => void +} diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt new file mode 100644 index 0000000000000..358ec5ea0414a --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1005: '(' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: '=' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,28): error TS1005: '=>' expected. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts (3 errors) ==== + var v = function * yield() { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt new file mode 100644 index 0000000000000..1f921475fd330 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration13_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (1 errors) ==== + function * foo() { + // Legal to use 'yield' in a type context. + var v: yield; + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.js b/tests/baselines/reference/FunctionDeclaration13_es6.js new file mode 100644 index 0000000000000..4c82b0375697c --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration13_es6.js @@ -0,0 +1,12 @@ +//// [FunctionDeclaration13_es6.ts] +function * foo() { + // Legal to use 'yield' in a type context. + var v: yield; +} + + +//// [FunctionDeclaration13_es6.js] +function foo() { + // Legal to use 'yield' in a type context. + var v; +} diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.js b/tests/baselines/reference/FunctionDeclaration1_es6.js new file mode 100644 index 0000000000000..262c7ea02fbb1 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration1_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration1_es6.ts] +function * foo() { +} + +//// [FunctionDeclaration1_es6.js] +function foo() { +} diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.types b/tests/baselines/reference/FunctionDeclaration1_es6.types new file mode 100644 index 0000000000000..69b26e5dd1007 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration1_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts === +function * foo() { +>foo : () => void +} diff --git a/tests/baselines/reference/FunctionDeclaration2_es6.js b/tests/baselines/reference/FunctionDeclaration2_es6.js new file mode 100644 index 0000000000000..dc73cad330f19 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration2_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration2_es6.ts] +function f(yield) { +} + +//// [FunctionDeclaration2_es6.js] +function f(yield) { +} diff --git a/tests/baselines/reference/FunctionDeclaration2_es6.types b/tests/baselines/reference/FunctionDeclaration2_es6.types new file mode 100644 index 0000000000000..f23d9cf6840eb --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration2_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration2_es6.ts === +function f(yield) { +>f : (yield: any) => void +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt new file mode 100644 index 0000000000000..409baef3a500e --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot be referenced in its initializer. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts (1 errors) ==== + function f(yield = yield) { + ~~~~~ +!!! error TS2372: Parameter 'yield' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.js b/tests/baselines/reference/FunctionDeclaration3_es6.js new file mode 100644 index 0000000000000..e1df936dd21fe --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3_es6.js @@ -0,0 +1,8 @@ +//// [FunctionDeclaration3_es6.ts] +function f(yield = yield) { +} + +//// [FunctionDeclaration3_es6.js] +function f(yield) { + if (yield === void 0) { yield = yield; } +} diff --git a/tests/baselines/reference/FunctionDeclaration4_es6.js b/tests/baselines/reference/FunctionDeclaration4_es6.js new file mode 100644 index 0000000000000..da6c695fcb9ea --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration4_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration4_es6.ts] +function yield() { +} + +//// [FunctionDeclaration4_es6.js] +function yield() { +} diff --git a/tests/baselines/reference/FunctionDeclaration4_es6.types b/tests/baselines/reference/FunctionDeclaration4_es6.types new file mode 100644 index 0000000000000..e4f102a8f706a --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration4_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration4_es6.ts === +function yield() { +>yield : () => void +} diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt new file mode 100644 index 0000000000000..9a8be9217959b --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration5_es6.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,19): error TS1005: ';' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (4 errors) ==== + function*foo(yield) { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt new file mode 100644 index 0000000000000..7d5eb768be697 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (1 errors) ==== + function*foo(a = yield) { + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.js b/tests/baselines/reference/FunctionDeclaration6_es6.js new file mode 100644 index 0000000000000..07b3ff52212a0 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6_es6.js @@ -0,0 +1,8 @@ +//// [FunctionDeclaration6_es6.ts] +function*foo(a = yield) { +} + +//// [FunctionDeclaration6_es6.js] +function foo(a) { + if (a === void 0) { a = yield; } +} diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt new file mode 100644 index 0000000000000..95ad904bdd99f --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (1 errors) ==== + function*bar() { + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.js b/tests/baselines/reference/FunctionDeclaration7_es6.js new file mode 100644 index 0000000000000..661e1668e0ff2 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7_es6.js @@ -0,0 +1,14 @@ +//// [FunctionDeclaration7_es6.ts] +function*bar() { + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { + } +} + +//// [FunctionDeclaration7_es6.js] +function bar() { + // 'yield' here is an identifier, and not a yield expression. + function foo(a) { + if (a === void 0) { a = yield; } + } +} diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt new file mode 100644 index 0000000000000..a30b8d8031089 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration8_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1136: Property assignment expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,18): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,24): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (4 errors) ==== + var v = { [yield]: foo } + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt new file mode 100644 index 0000000000000..b4cf83a7b6c6d --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration9_es6.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1136: Property assignment expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,20): error TS1005: ',' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ==== + function * foo() { + var v = { [yield]: foo } + ~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionExpression1_es6.js b/tests/baselines/reference/FunctionExpression1_es6.js new file mode 100644 index 0000000000000..7c8d82f4ca82f --- /dev/null +++ b/tests/baselines/reference/FunctionExpression1_es6.js @@ -0,0 +1,6 @@ +//// [FunctionExpression1_es6.ts] +var v = function * () { } + +//// [FunctionExpression1_es6.js] +var v = function () { +}; diff --git a/tests/baselines/reference/FunctionExpression1_es6.types b/tests/baselines/reference/FunctionExpression1_es6.types new file mode 100644 index 0000000000000..c857d53baba40 --- /dev/null +++ b/tests/baselines/reference/FunctionExpression1_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts === +var v = function * () { } +>v : () => void +>function * () { } : () => void + diff --git a/tests/baselines/reference/FunctionExpression2_es6.js b/tests/baselines/reference/FunctionExpression2_es6.js new file mode 100644 index 0000000000000..0a2468bcb8cd2 --- /dev/null +++ b/tests/baselines/reference/FunctionExpression2_es6.js @@ -0,0 +1,6 @@ +//// [FunctionExpression2_es6.ts] +var v = function * foo() { } + +//// [FunctionExpression2_es6.js] +var v = function foo() { +}; diff --git a/tests/baselines/reference/FunctionExpression2_es6.types b/tests/baselines/reference/FunctionExpression2_es6.types new file mode 100644 index 0000000000000..7bd9f0904356d --- /dev/null +++ b/tests/baselines/reference/FunctionExpression2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts === +var v = function * foo() { } +>v : () => void +>function * foo() { } : () => void +>foo : () => void + diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.js b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js new file mode 100644 index 0000000000000..a451dcfb3632d --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js @@ -0,0 +1,6 @@ +//// [FunctionPropertyAssignments1_es6.ts] +var v = { *foo() { } } + +//// [FunctionPropertyAssignments1_es6.js] +var v = { foo: function () { +} }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.types b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types new file mode 100644 index 0000000000000..2dfbf5cb6575a --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts === +var v = { *foo() { } } +>v : { foo: () => void; } +>{ *foo() { } } : { foo: () => void; } +>foo : () => void +>*foo() { } : () => void + diff --git a/tests/baselines/reference/FunctionPropertyAssignments2_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments2_es6.errors.txt new file mode 100644 index 0000000000000..f0287f12696f1 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments2_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts(1,12): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts (1 errors) ==== + var v = { *() { } } + ~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments3_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments3_es6.errors.txt new file mode 100644 index 0000000000000..b5873e807961b --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments3_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts(1,12): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts (1 errors) ==== + var v = { *{ } } + ~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments4_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments4_es6.errors.txt new file mode 100644 index 0000000000000..285341f04dc2d --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments4_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts(1,13): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts (1 errors) ==== + var v = { * } + ~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt new file mode 100644 index 0000000000000..961dabaa996ea --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1003: Identifier expected. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,22): error TS1005: ',' expected. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (4 errors) ==== + var v = { *[foo()]() { } } + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionPropertyAssignments6_es6.errors.txt b/tests/baselines/reference/FunctionPropertyAssignments6_es6.errors.txt new file mode 100644 index 0000000000000..a4e8450bd73e5 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments6_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts(1,12): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts (1 errors) ==== + var v = { *() { } } + ~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.js b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js new file mode 100644 index 0000000000000..86e7c9d418a8a --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration1_es6.ts] +class C { + *foo() { } +} + +//// [MemberFunctionDeclaration1_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.types b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types new file mode 100644 index 0000000000000..265d3fdb29135 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts === +class C { +>C : C + + *foo() { } +>foo : () => void +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.js b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js new file mode 100644 index 0000000000000..efd60844dc7fe --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration2_es6.ts] +class C { + public * foo() { } +} + +//// [MemberFunctionDeclaration2_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.types b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types new file mode 100644 index 0000000000000..e1e3f9d17e53d --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts === +class C { +>C : C + + public * foo() { } +>foo : () => void +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt new file mode 100644 index 0000000000000..b3a2de4eec66d --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,5): error TS1003: Identifier expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,10): error TS1005: ';' expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,13): error TS1005: '=>' expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (4 errors) ==== + class C { + *[foo]() { } + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1005: '=>' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration4_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration4_es6.errors.txt new file mode 100644 index 0000000000000..988527ccfd7a2 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration4_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts(2,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts (1 errors) ==== + class C { + *() { } + ~ +!!! error TS1003: Identifier expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration5_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration5_es6.errors.txt new file mode 100644 index 0000000000000..e27d6198104bf --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration5_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts(3,1): error TS1003: Identifier expected. + + +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts (1 errors) ==== + class C { + * + } + ~ +!!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration6_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration6_es6.errors.txt new file mode 100644 index 0000000000000..b79a61c886692 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration6_es6.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts(3,1): error TS1005: '(' expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts(2,5): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts (2 errors) ==== + class C { + *foo + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + ~ +!!! error TS1005: '(' expected. \ No newline at end of file diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.js b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js new file mode 100644 index 0000000000000..211713c6e14a2 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration7_es6.ts] +class C { + *foo() { } +} + +//// [MemberFunctionDeclaration7_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.types b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types new file mode 100644 index 0000000000000..e4c864b9422ad --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts === +class C { +>C : C + + *foo() { } +>foo : () => void +>T : T +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt b/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt new file mode 100644 index 0000000000000..1b216b72c8918 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,12): error TS1127: Invalid character. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,14): error TS1129: Statement expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,19): error TS1005: '(' expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(5,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(6,3): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(7,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,9): error TS2304: Cannot find name 'a'. +tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts(4,16): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts (8 errors) ==== + class C { + foo() { + // Make sure we don't think of *bar as the start of a generator method. + if (a) # * bar; + +!!! error TS1127: Invalid character. + ~ +!!! error TS1129: Statement expected. + ~ +!!! error TS1005: '(' expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + return bar; + ~~~~~~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + } + ~ +!!! error TS1128: Declaration or statement expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/TemplateExpression1.errors.txt b/tests/baselines/reference/TemplateExpression1.errors.txt new file mode 100644 index 0000000000000..bf57f5ef24ec5 --- /dev/null +++ b/tests/baselines/reference/TemplateExpression1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,19): error TS1158: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/TemplateExpression1.ts(1,17): error TS2304: Cannot find name 'a'. + + +==== tests/cases/conformance/es6/templates/TemplateExpression1.ts (2 errors) ==== + var v = `foo ${ a + +!!! error TS1158: Invalid template literal; expected '}' + ~ +!!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression10_es6.js b/tests/baselines/reference/YieldExpression10_es6.js new file mode 100644 index 0000000000000..f111e6e1bdf39 --- /dev/null +++ b/tests/baselines/reference/YieldExpression10_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression10_es6.ts] +var v = { * foo() { + yield(foo); + } +} + + +//// [YieldExpression10_es6.js] +var v = { foo: function () { + ; +} }; diff --git a/tests/baselines/reference/YieldExpression10_es6.types b/tests/baselines/reference/YieldExpression10_es6.types new file mode 100644 index 0000000000000..e0d3f84c6c865 --- /dev/null +++ b/tests/baselines/reference/YieldExpression10_es6.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts === +var v = { * foo() { +>v : { foo: () => void; } +>{ * foo() { yield(foo); }} : { foo: () => void; } +>foo : () => void +>* foo() { yield(foo); } : () => void + + yield(foo); + } +} + diff --git a/tests/baselines/reference/YieldExpression11_es6.js b/tests/baselines/reference/YieldExpression11_es6.js new file mode 100644 index 0000000000000..306cef3051e6c --- /dev/null +++ b/tests/baselines/reference/YieldExpression11_es6.js @@ -0,0 +1,16 @@ +//// [YieldExpression11_es6.ts] +class C { + *foo() { + yield(foo); + } +} + +//// [YieldExpression11_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + ; + }; + return C; +})(); diff --git a/tests/baselines/reference/YieldExpression11_es6.types b/tests/baselines/reference/YieldExpression11_es6.types new file mode 100644 index 0000000000000..cdb70b3af0dbb --- /dev/null +++ b/tests/baselines/reference/YieldExpression11_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts === +class C { +>C : C + + *foo() { +>foo : () => void + + yield(foo); + } +} diff --git a/tests/baselines/reference/YieldExpression12_es6.errors.txt b/tests/baselines/reference/YieldExpression12_es6.errors.txt new file mode 100644 index 0000000000000..10843421a3f4a --- /dev/null +++ b/tests/baselines/reference/YieldExpression12_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ==== + class C { + constructor() { + yield foo + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression13_es6.js b/tests/baselines/reference/YieldExpression13_es6.js new file mode 100644 index 0000000000000..328fc80dbdd0f --- /dev/null +++ b/tests/baselines/reference/YieldExpression13_es6.js @@ -0,0 +1,7 @@ +//// [YieldExpression13_es6.ts] +function* foo() { yield } + +//// [YieldExpression13_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression13_es6.types b/tests/baselines/reference/YieldExpression13_es6.types new file mode 100644 index 0000000000000..23a9fe6299a88 --- /dev/null +++ b/tests/baselines/reference/YieldExpression13_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts === +function* foo() { yield } +>foo : () => void + diff --git a/tests/baselines/reference/YieldExpression14_es6.errors.txt b/tests/baselines/reference/YieldExpression14_es6.errors.txt new file mode 100644 index 0000000000000..baeaf3ba30ed3 --- /dev/null +++ b/tests/baselines/reference/YieldExpression14_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ==== + class C { + foo() { + yield foo + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression15_es6.errors.txt b/tests/baselines/reference/YieldExpression15_es6.errors.txt new file mode 100644 index 0000000000000..5e548799f5d5b --- /dev/null +++ b/tests/baselines/reference/YieldExpression15_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ==== + var v = () => { + yield foo + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression16_es6.errors.txt b/tests/baselines/reference/YieldExpression16_es6.errors.txt new file mode 100644 index 0000000000000..e5a9b93eecea8 --- /dev/null +++ b/tests/baselines/reference/YieldExpression16_es6.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (1 errors) ==== + function* foo() { + function bar() { + yield foo; + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression17_es6.errors.txt b/tests/baselines/reference/YieldExpression17_es6.errors.txt new file mode 100644 index 0000000000000..38969a9c6fbb5 --- /dev/null +++ b/tests/baselines/reference/YieldExpression17_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (2 errors) ==== + var v = { get foo() { yield foo; } } + ~~~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~~~ +!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression18_es6.errors.txt b/tests/baselines/reference/YieldExpression18_es6.errors.txt new file mode 100644 index 0000000000000..3a67acdebcdff --- /dev/null +++ b/tests/baselines/reference/YieldExpression18_es6.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ==== + "use strict"; + yield(foo); + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression19_es6.js b/tests/baselines/reference/YieldExpression19_es6.js new file mode 100644 index 0000000000000..91643e09b0ed4 --- /dev/null +++ b/tests/baselines/reference/YieldExpression19_es6.js @@ -0,0 +1,17 @@ +//// [YieldExpression19_es6.ts] +function*foo() { + function bar() { + function* quux() { + yield(foo); + } + } +} + +//// [YieldExpression19_es6.js] +function foo() { + function bar() { + function quux() { + ; + } + } +} diff --git a/tests/baselines/reference/YieldExpression19_es6.types b/tests/baselines/reference/YieldExpression19_es6.types new file mode 100644 index 0000000000000..a8af884c98f1d --- /dev/null +++ b/tests/baselines/reference/YieldExpression19_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts === +function*foo() { +>foo : () => void + + function bar() { +>bar : () => void + + function* quux() { +>quux : () => void + + yield(foo); + } + } +} diff --git a/tests/baselines/reference/YieldExpression1_es6.errors.txt b/tests/baselines/reference/YieldExpression1_es6.errors.txt new file mode 100644 index 0000000000000..f8a13fe54099b --- /dev/null +++ b/tests/baselines/reference/YieldExpression1_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts (1 errors) ==== + yield; + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression1_es6.js b/tests/baselines/reference/YieldExpression1_es6.js new file mode 100644 index 0000000000000..cb5c097df2c2e --- /dev/null +++ b/tests/baselines/reference/YieldExpression1_es6.js @@ -0,0 +1,5 @@ +//// [YieldExpression1_es6.ts] +yield; + +//// [YieldExpression1_es6.js] +yield; diff --git a/tests/baselines/reference/YieldExpression2_es6.errors.txt b/tests/baselines/reference/YieldExpression2_es6.errors.txt new file mode 100644 index 0000000000000..553dab51fc20f --- /dev/null +++ b/tests/baselines/reference/YieldExpression2_es6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ==== + yield foo; + ~~~~~ +!!! error TS1163: 'yield' expression must be contained_within a generator declaration. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression3_es6.js b/tests/baselines/reference/YieldExpression3_es6.js new file mode 100644 index 0000000000000..cc3716587eae7 --- /dev/null +++ b/tests/baselines/reference/YieldExpression3_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression3_es6.ts] +function* foo() { + yield + yield +} + +//// [YieldExpression3_es6.js] +function foo() { + ; + ; +} diff --git a/tests/baselines/reference/YieldExpression3_es6.types b/tests/baselines/reference/YieldExpression3_es6.types new file mode 100644 index 0000000000000..f9ad4faffdb07 --- /dev/null +++ b/tests/baselines/reference/YieldExpression3_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts === +function* foo() { +>foo : () => void + + yield + yield +} diff --git a/tests/baselines/reference/YieldExpression4_es6.js b/tests/baselines/reference/YieldExpression4_es6.js new file mode 100644 index 0000000000000..84b11a03a2ce9 --- /dev/null +++ b/tests/baselines/reference/YieldExpression4_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression4_es6.ts] +function* foo() { + yield; + yield; +} + +//// [YieldExpression4_es6.js] +function foo() { + ; + ; +} diff --git a/tests/baselines/reference/YieldExpression4_es6.types b/tests/baselines/reference/YieldExpression4_es6.types new file mode 100644 index 0000000000000..083d145d06f18 --- /dev/null +++ b/tests/baselines/reference/YieldExpression4_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts === +function* foo() { +>foo : () => void + + yield; + yield; +} diff --git a/tests/baselines/reference/YieldExpression5_es6.errors.txt b/tests/baselines/reference/YieldExpression5_es6.errors.txt new file mode 100644 index 0000000000000..3ce8f20c985d2 --- /dev/null +++ b/tests/baselines/reference/YieldExpression5_es6.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts(3,1): error TS1109: Expression expected. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts (1 errors) ==== + function* foo() { + yield* + } + ~ +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression6_es6.js b/tests/baselines/reference/YieldExpression6_es6.js new file mode 100644 index 0000000000000..5024e9bbd4015 --- /dev/null +++ b/tests/baselines/reference/YieldExpression6_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression6_es6.ts] +function* foo() { + yield*foo +} + +//// [YieldExpression6_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression6_es6.types b/tests/baselines/reference/YieldExpression6_es6.types new file mode 100644 index 0000000000000..fd410d2c95919 --- /dev/null +++ b/tests/baselines/reference/YieldExpression6_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts === +function* foo() { +>foo : () => void + + yield*foo +} diff --git a/tests/baselines/reference/YieldExpression7_es6.js b/tests/baselines/reference/YieldExpression7_es6.js new file mode 100644 index 0000000000000..96ef5af107e19 --- /dev/null +++ b/tests/baselines/reference/YieldExpression7_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression7_es6.ts] +function* foo() { + yield foo +} + +//// [YieldExpression7_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression7_es6.types b/tests/baselines/reference/YieldExpression7_es6.types new file mode 100644 index 0000000000000..17e1a3b2bfb0d --- /dev/null +++ b/tests/baselines/reference/YieldExpression7_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts === +function* foo() { +>foo : () => void + + yield foo +} diff --git a/tests/baselines/reference/YieldExpression8_es6.errors.txt b/tests/baselines/reference/YieldExpression8_es6.errors.txt new file mode 100644 index 0000000000000..f4dd30b1a1947 --- /dev/null +++ b/tests/baselines/reference/YieldExpression8_es6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (1 errors) ==== + yield(foo); + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + function* foo() { + yield(foo); + } \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression8_es6.js b/tests/baselines/reference/YieldExpression8_es6.js new file mode 100644 index 0000000000000..190c2cc3da569 --- /dev/null +++ b/tests/baselines/reference/YieldExpression8_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression8_es6.ts] +yield(foo); +function* foo() { + yield(foo); +} + +//// [YieldExpression8_es6.js] +yield(foo); +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression9_es6.js b/tests/baselines/reference/YieldExpression9_es6.js new file mode 100644 index 0000000000000..978e0d455bddc --- /dev/null +++ b/tests/baselines/reference/YieldExpression9_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression9_es6.ts] +var v = function*() { + yield(foo); +} + +//// [YieldExpression9_es6.js] +var v = function () { + ; +}; diff --git a/tests/baselines/reference/YieldExpression9_es6.types b/tests/baselines/reference/YieldExpression9_es6.types new file mode 100644 index 0000000000000..a570d2f09a0a7 --- /dev/null +++ b/tests/baselines/reference/YieldExpression9_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts === +var v = function*() { +>v : () => void +>function*() { yield(foo);} : () => void + + yield(foo); +} diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt deleted file mode 100644 index 50b780ad3cb06..0000000000000 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1003: Identifier expected. -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,15): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS2304: Cannot find name 'yield'. - - -==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (4 errors) ==== - function* gen { - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'gen'. - // Once this is supported, the inner expression does not need to be parenthesized. - var x = yield `abc${ x }def`; - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - } - \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInYieldKeyword.js b/tests/baselines/reference/templateStringInYieldKeyword.js new file mode 100644 index 0000000000000..8e98b269cd009 --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.js @@ -0,0 +1,12 @@ +//// [templateStringInYieldKeyword.ts] +function* gen() { + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +} + + +//// [templateStringInYieldKeyword.js] +function gen() { + // Once this is supported, the inner expression does not need to be parenthesized. + var x = ; +} diff --git a/tests/baselines/reference/templateStringInYieldKeyword.types b/tests/baselines/reference/templateStringInYieldKeyword.types new file mode 100644 index 0000000000000..c3d49ddffb743 --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts === +function* gen() { +>gen : () => void + + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +>x : unknown +} + diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt index 3bf910f369051..28f33943732e9 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -1,29 +1,11 @@ -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,9): error TS1003: Identifier expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,26): error TS1158: Invalid template literal; expected '}' -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(5,1): error TS1160: Unterminated template literal. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,20): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,30): error TS2304: Cannot find name 'def'. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: '(' expected. -==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (7 errors) ==== +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (1 errors) ==== function* gen { - ~ -!!! error TS1003: Identifier expected. ~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'gen'. +!!! error TS1005: '(' expected. // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; - ~~ -!!! error TS1158: Invalid template literal; expected '}' - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - ~~~ -!!! error TS2304: Cannot find name 'def'. } - - -!!! error TS1160: Unterminated template literal. \ No newline at end of file + \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt deleted file mode 100644 index 4e62197e0315f..0000000000000 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS1003: Identifier expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,17): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,26): error TS1158: Invalid template literal; expected '}' -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(5,1): error TS1160: Unterminated template literal. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,11): error TS2304: Cannot find name 'gen'. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,20): error TS2304: Cannot find name 'yield'. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,30): error TS2304: Cannot find name 'def'. - - -==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (7 errors) ==== - function* gen() { - ~ -!!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ';' expected. - ~~~ -!!! error TS2304: Cannot find name 'gen'. - // Once this is supported, yield *must* be parenthesized. - var x = `abc${ yield 10 }def`; - ~~ -!!! error TS1158: Invalid template literal; expected '}' - ~~~~~ -!!! error TS2304: Cannot find name 'yield'. - ~~~ -!!! error TS2304: Cannot find name 'def'. - } - - -!!! error TS1160: Unterminated template literal. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js new file mode 100644 index 0000000000000..80021ecae2e90 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js @@ -0,0 +1,12 @@ +//// [templateStringWithEmbeddedYieldKeywordES6.ts] +function* gen() { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +} + + +//// [templateStringWithEmbeddedYieldKeywordES6.js] +function gen() { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${}def`; +} diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types new file mode 100644 index 0000000000000..c55b40148b164 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === +function* gen() { +>gen : () => void + + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +>x : string +} + diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts new file mode 100644 index 0000000000000..64f8b999003ac --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName10_es6.ts @@ -0,0 +1,3 @@ +class C { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts new file mode 100644 index 0000000000000..cfb1c736b404c --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName11_es6.ts @@ -0,0 +1,3 @@ +class C { + [e](); +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts new file mode 100644 index 0000000000000..7e030263fcc03 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName12_es6.ts @@ -0,0 +1,3 @@ +class C { + [e]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts new file mode 100644 index 0000000000000..2783955e8043f --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName13_es6.ts @@ -0,0 +1 @@ +var v: { [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts new file mode 100644 index 0000000000000..534b418854bfa --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName14_es6.ts @@ -0,0 +1 @@ +var v: { [e](): number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts new file mode 100644 index 0000000000000..7b9965e8177d0 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName15_es6.ts @@ -0,0 +1 @@ +var v: { [e: number]: string; [e]: number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts new file mode 100644 index 0000000000000..a088319bf9425 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName16_es6.ts @@ -0,0 +1,3 @@ +enum E { + [e] = 1 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts new file mode 100644 index 0000000000000..2d002e9ca43de --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName17_es6.ts @@ -0,0 +1 @@ +var v = { set [e](v) { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts new file mode 100644 index 0000000000000..0659070d643e5 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName18_es6.ts @@ -0,0 +1 @@ +var v: { [e]?(): number }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts new file mode 100644 index 0000000000000..b6c1756d097a2 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName19_es6.ts @@ -0,0 +1 @@ +var v: { [e]? }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts new file mode 100644 index 0000000000000..0703648cf0ba6 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName1_es6.ts @@ -0,0 +1 @@ +var v = { [e] }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts new file mode 100644 index 0000000000000..34c9d6d918a09 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName2_es6.ts @@ -0,0 +1 @@ +var v = { [e]: 1 }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts new file mode 100644 index 0000000000000..08ad781e2ba21 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName3_es6.ts @@ -0,0 +1 @@ +var v = { [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts new file mode 100644 index 0000000000000..d5a331ebb4c9c --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName4_es6.ts @@ -0,0 +1 @@ +var v = { get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts new file mode 100644 index 0000000000000..a254f65ee6735 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName5_es6.ts @@ -0,0 +1 @@ +var v = { public get [e]() { } }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts new file mode 100644 index 0000000000000..c09627a0d46a7 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName6_es6.ts @@ -0,0 +1 @@ +var v = { [e]: 1, [e + e]: 2 }; \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts new file mode 100644 index 0000000000000..b23944da7962b --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName7_es6.ts @@ -0,0 +1,3 @@ +class C { + [e] +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts new file mode 100644 index 0000000000000..18f1fd61276d5 --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName8_es6.ts @@ -0,0 +1,3 @@ +class C { + public [e] +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts new file mode 100644 index 0000000000000..18e290722aadc --- /dev/null +++ b/tests/cases/conformance/es6/computedPropertyNames/ComputedPropertyName9_es6.ts @@ -0,0 +1,3 @@ +class C { + [e]: Type +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts new file mode 100644 index 0000000000000..fa7a20f78ba65 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts @@ -0,0 +1,2 @@ +function * foo(a = yield => yield) { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts new file mode 100644 index 0000000000000..07b452678eb78 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts @@ -0,0 +1,2 @@ +function * yield() { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts new file mode 100644 index 0000000000000..ff08bd514afdf --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts @@ -0,0 +1 @@ +var v = function * yield() { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts new file mode 100644 index 0000000000000..e5e30dc4b0e22 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts @@ -0,0 +1,4 @@ +function * foo() { + // Legal to use 'yield' in a type context. + var v: yield; +} diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts new file mode 100644 index 0000000000000..650e619fc0099 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts @@ -0,0 +1,2 @@ +function * foo() { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration2_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration2_es6.ts new file mode 100644 index 0000000000000..136dd1f9b4352 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration2_es6.ts @@ -0,0 +1,2 @@ +function f(yield) { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts new file mode 100644 index 0000000000000..33324d8815803 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts @@ -0,0 +1,2 @@ +function f(yield = yield) { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration4_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration4_es6.ts new file mode 100644 index 0000000000000..fd9170a726a4a --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration4_es6.ts @@ -0,0 +1,2 @@ +function yield() { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts new file mode 100644 index 0000000000000..3e97edf26a683 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts @@ -0,0 +1,2 @@ +function*foo(yield) { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts new file mode 100644 index 0000000000000..144aae6b63c44 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts @@ -0,0 +1,2 @@ +function*foo(a = yield) { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts new file mode 100644 index 0000000000000..3cc50e85592ca --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts @@ -0,0 +1,5 @@ +function*bar() { + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts new file mode 100644 index 0000000000000..4b65f204babb1 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts @@ -0,0 +1 @@ +var v = { [yield]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts new file mode 100644 index 0000000000000..d30d6535d4b67 --- /dev/null +++ b/tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts @@ -0,0 +1,3 @@ +function * foo() { + var v = { [yield]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts b/tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts new file mode 100644 index 0000000000000..42ff543edf78c --- /dev/null +++ b/tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts @@ -0,0 +1 @@ +var v = function * () { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts b/tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts new file mode 100644 index 0000000000000..2669a3e386fdf --- /dev/null +++ b/tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts @@ -0,0 +1 @@ +var v = function * foo() { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts new file mode 100644 index 0000000000000..1d6cb9f92fb2a --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts @@ -0,0 +1 @@ +var v = { *foo() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts new file mode 100644 index 0000000000000..e58c7077a4954 --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts @@ -0,0 +1 @@ +var v = { *() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts new file mode 100644 index 0000000000000..ebcd542a2a0b3 --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts @@ -0,0 +1 @@ +var v = { *{ } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts new file mode 100644 index 0000000000000..3b23ea4fc9735 --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts @@ -0,0 +1 @@ +var v = { * } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts new file mode 100644 index 0000000000000..b1628dd2f2cbd --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts @@ -0,0 +1 @@ +var v = { *[foo()]() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts new file mode 100644 index 0000000000000..6bfae9ec77c82 --- /dev/null +++ b/tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts @@ -0,0 +1 @@ +var v = { *() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts new file mode 100644 index 0000000000000..3bb832ccf494f --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts @@ -0,0 +1,3 @@ +class C { + *foo() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts new file mode 100644 index 0000000000000..2174110723d7a --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts @@ -0,0 +1,3 @@ +class C { + public * foo() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts new file mode 100644 index 0000000000000..8db736f99bbfd --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts @@ -0,0 +1,3 @@ +class C { + *[foo]() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts new file mode 100644 index 0000000000000..0fa98ce98c4fa --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts @@ -0,0 +1,3 @@ +class C { + *() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts new file mode 100644 index 0000000000000..474316195f0af --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts @@ -0,0 +1,3 @@ +class C { + * +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts new file mode 100644 index 0000000000000..1efad0a784293 --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts @@ -0,0 +1,3 @@ +class C { + *foo +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts new file mode 100644 index 0000000000000..93f05494107c9 --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts @@ -0,0 +1,3 @@ +class C { + *foo() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts new file mode 100644 index 0000000000000..069d7339869e6 --- /dev/null +++ b/tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts @@ -0,0 +1,7 @@ +class C { + foo() { + // Make sure we don't think of *bar as the start of a generator method. + if (a) # * bar; + return bar; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/TemplateExpression1.ts b/tests/cases/conformance/es6/templates/TemplateExpression1.ts new file mode 100644 index 0000000000000..e6980c4c8e246 --- /dev/null +++ b/tests/cases/conformance/es6/templates/TemplateExpression1.ts @@ -0,0 +1 @@ +var v = `foo ${ a \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts b/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts index 4a80e452251b3..d020d7c76075d 100644 --- a/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts +++ b/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts @@ -1,4 +1,4 @@ -function* gen { +function* gen() { // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; } diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts new file mode 100644 index 0000000000000..b95174babdf97 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts @@ -0,0 +1,4 @@ +var v = { * foo() { + yield(foo); + } +} diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts new file mode 100644 index 0000000000000..7577e5ce46bab --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts @@ -0,0 +1,5 @@ +class C { + *foo() { + yield(foo); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts new file mode 100644 index 0000000000000..3ee6a46404975 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts @@ -0,0 +1,5 @@ +class C { + constructor() { + yield foo + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts new file mode 100644 index 0000000000000..2ac6f63146540 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts @@ -0,0 +1 @@ +function* foo() { yield } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts new file mode 100644 index 0000000000000..d545175c94a1a --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts @@ -0,0 +1,5 @@ +class C { + foo() { + yield foo + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts new file mode 100644 index 0000000000000..b2793208aaa6d --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts @@ -0,0 +1,3 @@ +var v = () => { + yield foo + } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts new file mode 100644 index 0000000000000..1933df26ecfe4 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts @@ -0,0 +1,5 @@ +function* foo() { + function bar() { + yield foo; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts new file mode 100644 index 0000000000000..7ef3a1fe35054 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts @@ -0,0 +1 @@ +var v = { get foo() { yield foo; } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts new file mode 100644 index 0000000000000..f91016aabf0e2 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts @@ -0,0 +1,2 @@ +"use strict"; +yield(foo); \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts new file mode 100644 index 0000000000000..0183d72ea61e8 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts @@ -0,0 +1,7 @@ +function*foo() { + function bar() { + function* quux() { + yield(foo); + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts new file mode 100644 index 0000000000000..bdbfe1e27a72b --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts @@ -0,0 +1 @@ +yield; \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts new file mode 100644 index 0000000000000..39bbe4e7eb0be --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts @@ -0,0 +1 @@ +yield foo; \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts new file mode 100644 index 0000000000000..04ae4b8d22375 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts @@ -0,0 +1,4 @@ +function* foo() { + yield + yield +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts new file mode 100644 index 0000000000000..cd2f970804802 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts @@ -0,0 +1,4 @@ +function* foo() { + yield; + yield; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts new file mode 100644 index 0000000000000..af4b3a84d2f2a --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts @@ -0,0 +1,3 @@ +function* foo() { + yield* +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts new file mode 100644 index 0000000000000..87d307dcda047 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts @@ -0,0 +1,3 @@ +function* foo() { + yield*foo +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts new file mode 100644 index 0000000000000..0db38fd498bc2 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts @@ -0,0 +1,3 @@ +function* foo() { + yield foo +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts new file mode 100644 index 0000000000000..b6b0830123926 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts @@ -0,0 +1,4 @@ +yield(foo); +function* foo() { + yield(foo); +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts b/tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts new file mode 100644 index 0000000000000..9119deae832af --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts @@ -0,0 +1,3 @@ +var v = function*() { + yield(foo); +} \ No newline at end of file