diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8ff6712ad30ac..46df691e090d2 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -825,6 +825,9 @@ namespace ts { case SyntaxKind.CallExpression: bindCallExpressionFlow(node as CallExpression); break; + case SyntaxKind.PipelineHackExpression: + bindPipelineHackExpressionFlow(node as PipelineHackExpression); + break; case SyntaxKind.NonNullExpression: bindNonNullExpressionFlow(node as NonNullExpression); break; @@ -1793,6 +1796,42 @@ namespace ts { } } + function bindPipelineHackExpressionFlow(node: PipelineHackExpression) { + if (!blockScopeContainer.locals) { + blockScopeContainer.locals = createSymbolTable(); + addToContainerChain(blockScopeContainer); + } + // const bindingName = InternalSymbolName.HackPipelineReference; + // const newSymbol = bindAnonymousDeclaration(node.dummyDeclaration, SymbolFlags.BlockScopedVariable, bindingName); + declareSymbol(blockScopeContainer.locals, /*parent*/ undefined, node.dummyDeclaration, SymbolFlags.BlockScopedVariable, SymbolFlags.None); + // const hashDeclaration = setTextRange(factory.createBindingElement(undefined, undefined, '#', node.arguments[0]), { pos: node.pos, end: node.pos }); + // setTextRange(hashDeclaration.name!, { pos: node.pos, end: node.pos }); + // (hashDeclaration as any).parent = node; + // declareSymbol(blockScopeContainer.locals, /*parent*/ undefined, hashDeclaration, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); + + + // bindBlockScopedDeclaration(hashDeclaration, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); + // // const obp = factory.createObjectBindingPattern([hashDeclaration]); + // setParent(hashDeclaration, obp); + // // // const result = createSymbol(SymbolFlags.BlockScopedVariable, '#' as __String); + // // // result.declarations = [hashDeclaration]; + // // // result.parent = node; + // setParent(obp, node); + // // const syn = factory.createSyntheticExpression(ObjectBindinPattern, false, hashDeclaration) + + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + bind(node.argument); + bind(node.expression); + // if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { + // const propertyAccess = node.expression; + // if (isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) { + // currentFlow = createFlowMutation(FlowFlags.ArrayMutation, currentFlow, node); + // } + // } + } + function getContainerFlags(node: Node): ContainerFlags { switch (node.kind) { case SyntaxKind.ClassExpression: @@ -1849,7 +1888,8 @@ namespace ts { case SyntaxKind.ForInStatement: case SyntaxKind.ForOfStatement: case SyntaxKind.CaseBlock: - return ContainerFlags.IsBlockScopedContainer; + case SyntaxKind.PipelineHackExpression: + return ContainerFlags.IsBlockScopedContainer | ContainerFlags.HasLocals; case SyntaxKind.Block: // do not treat blocks directly inside a function as a block-scoped-container. @@ -1933,6 +1973,7 @@ namespace ts { case SyntaxKind.ClassStaticBlockDeclaration: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.MappedType: + case SyntaxKind.PipelineHackExpression: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -2656,6 +2697,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: return bindFunctionExpression(node as FunctionExpression); + // case SyntaxKind.PipelineExpression: + // return bindPipelineExpression(node); case SyntaxKind.CallExpression: const assignmentKind = getAssignmentDeclarationKind(node as CallExpression); @@ -3368,6 +3411,11 @@ namespace ts { return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); } + // function bindPipelineExpression(node: PipelineExpression) { + // const bindingName = InternalSymbolName.HackPipelineReference; + // bindAnonymousDeclaration(node.dummyDeclaration, SymbolFlags.BlockScopedVariable, bindingName); + // } + function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { if (!file.isDeclarationFile && !(node.flags & NodeFlags.Ambient) && isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2e0f1ef628101..2bef2c4027d26 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -377,6 +377,7 @@ namespace ts { const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); const requireSymbol = createSymbol(SymbolFlags.Property, "require" as __String); + // const pipelinePlaceholderSymbol = createSymbol(SymbolFlags.Property, "#" as __String); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ let apparentArgumentCount: number | undefined; @@ -2085,6 +2086,12 @@ namespace ts { } } break; + // case SyntaxKind.PipelineExpression: + // if (meaning & SymbolFlags.BlockScopedVariable && name === "#") { + // result = pipelinePlaceholderSymbol; + // break loop; + // } + // break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -8157,6 +8164,9 @@ namespace ts { } } } + if (isIdentifier(name) && name.escapedText === "#") { + return name.escapedText; + } return declarationNameToString(name); } if (!declaration) { @@ -25135,6 +25145,12 @@ namespace ts { (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } + + const checkIfPipelineHackExpressionParent = (node: Node): boolean => + node.parent?.kind === SyntaxKind.PipelineHackExpression || (node.parent + ? checkIfPipelineHackExpressionParent(node.parent) + : false); + // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). @@ -25143,7 +25159,8 @@ namespace ts { isInTypeQuery(node) || node.parent.kind === SyntaxKind.ExportSpecifier) || node.parent.kind === SyntaxKind.NonNullExpression || declaration.kind === SyntaxKind.VariableDeclaration && (declaration as VariableDeclaration).exclamationToken || - declaration.flags & NodeFlags.Ambient; + declaration.flags & NodeFlags.Ambient || + (node.escapedText === "#" && checkIfPipelineHackExpressionParent(node)); const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration as VariableLikeDeclaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -29122,6 +29139,10 @@ namespace ts { let effectiveParameterCount = getParameterCount(signature); let effectiveMinimumArguments = getMinArgumentCount(signature); + if (isPipelineApplicationExpression(node)) { + return true; + } + else if (node.kind === SyntaxKind.TaggedTemplateExpression) { argCount = args.length; if (node.template.kind === SyntaxKind.TemplateExpression) { @@ -29653,7 +29674,9 @@ namespace ts { if (isJsxOpeningLikeElement(node)) { return node.attributes.properties.length > 0 || (isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : emptyArray; } - const args = node.arguments || emptyArray; + const args = isPipelineApplicationExpression(node) + ? [node.argument] + : node.arguments || emptyArray; const spreadIndex = getSpreadArgumentIndex(args); if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. @@ -30370,7 +30393,7 @@ namespace ts { } else { let relatedInformation: DiagnosticRelatedInformation | undefined; - if (node.arguments.length === 1) { + if (isPipelineApplicationExpression(node) || node.arguments.length === 1) { const text = getSourceFileOfNode(node).text; if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon); @@ -30405,6 +30428,85 @@ namespace ts { return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags); } + function resolvePipelineApplicationExpression(node: PipelineApplicationExpression, candidatesOutArray: Signature[] | undefined, checkMode: CheckMode): Signature { + let funcType = checkExpression(node.expression); + + funcType = checkNonNullTypeWithReporter( + funcType, + node.expression, + reportCannotInvokePossiblyNullOrUndefinedError + ); + + if (funcType === silentNeverType) { + return silentNeverSignature; + } + + const apparentType = getApparentType(funcType); + if (apparentType === errorType) { + // Another error has already been reported + return resolveErrorCall(node); + } + + // Technically, this signatures list may be incomplete. We are taking the apparent type, + // but we are not including call signatures that may have been added to the Object or + // Function interface, since they have none by default. This is a bit of a leap of faith + // that the user will not add any. + const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + const numConstructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct).length; + + // TS 1.0 Spec: 4.12 + // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual + // types are provided for the argument expressions, and the result is always of type Any. + if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { + // The unknownType indicates that an error already occurred (and was reported). No + // need to report another error in this case. + // if (funcType !== errorType && node.typeArguments) { + // error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); + // } + return resolveUntypedCall(node); + } + // If FuncExpr's apparent type(section 3.8.1) is a function type, the call is a typed function call. + // TypeScript employs overload resolution in typed function calls in order to support functions + // with multiple call signatures. + if (!callSignatures.length) { + if (numConstructSignatures) { + error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + } + else { + let relatedInformation: DiagnosticRelatedInformation | undefined; + const text = getSourceFileOfNode(node).text; + if (isLineBreak(text.charCodeAt(skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { + relatedInformation = createDiagnosticForNode(node.expression, Diagnostics.Are_you_missing_a_semicolon); + } + invocationError(node.expression, apparentType, SignatureKind.Call, relatedInformation); + } + return resolveErrorCall(node); + } + // When a call to a generic function is an argument to an outer call to a generic function for which + // inference is in process, we have a choice to make. If the inner call relies on inferences made from + // its contextual type to its return type, deferring the inner call processing allows the best possible + // contextual type to accumulate. But if the outer call relies on inferences made from the return type of + // the inner call, the inner call should be processed early. There's no sure way to know which choice is + // right (only a full unification algorithm can determine that), so we resort to the following heuristic: + // If no type arguments are specified in the inner call and at least one call signature is generic and + // returns a function type, we choose to defer processing. This narrowly permits function composition + // operators to flow inferences through return types, but otherwise processes calls right away. We + // use the resolvingSignature singleton to indicate that we deferred processing. This result will be + // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // from which we never make inferences). + if (checkMode & CheckMode.SkipGenericFunctions && callSignatures.some(isGenericFunctionReturningFunction)) { + skippedGenericFunction(node, checkMode); + return resolvingSignature; + } + // If the function is explicitly marked with `@class`, then it must be constructed. + if (callSignatures.some(sig => isInJSFile(sig.declaration) && !!getJSDocClassTag(sig.declaration!))) { + error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); + return resolveErrorCall(node); + } + + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, SignatureFlags.None); + } + function isGenericFunctionReturningFunction(signature: Signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); } @@ -30862,6 +30964,8 @@ namespace ts { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSelfClosingElement: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); + case SyntaxKind.PipelineApplicationExpression: + return resolvePipelineApplicationExpression(node, candidatesOutArray, checkMode); } throw Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -31112,6 +31216,64 @@ namespace ts { } } + /** + * Syntactically and semantically checks a pipeline expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ + function checkPipelineHackExpression(node: PipelineHackExpression, checkMode?: CheckMode): Type { + checkExpression(node.argument, checkMode); + return checkExpression(node.expression, checkMode); + } + + function checkPipelineApplicationExpression(node: PipelineApplicationExpression, checkMode?: CheckMode): Type { + // if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); + + const signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); + if (signature === resolvingSignature) { + // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that + // returns a function type. We defer checking and return nonInferrableType. + return nonInferrableType; + } + + if (node.expression.kind === SyntaxKind.SuperKeyword) { + return voidType; + } + + // In JavaScript files, calls to any identifier 'require' are treated as external module imports + if (isInJSFile(node) && isCommonJsRequire(node)) { + return resolveExternalModuleTypeByLiteral(node.argument as StringLiteral); + } + + const returnType = getReturnTypeOfSignature(signature); + // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property + // as a fresh unique symbol literal type. + if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { + return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent)); + } + if (node.parent.kind === SyntaxKind.ExpressionStatement && + returnType.flags & TypeFlags.Void && getTypePredicateOfSignature(signature)) { + if (!isDottedName(node.expression)) { + error(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + // else if (!getEffectsSignature(node)) { + // const diagnostic = error(node.expression, Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + // getTypeOfDottedName(node.expression, diagnostic); + // } + } + + if (isInJSFile(node)) { + const jsSymbol = getSymbolOfExpando(node, /* allowDeclaration */ true); + if (jsSymbol && !!jsSymbol.exports?.size) { + const jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, emptyArray, emptyArray, emptyArray); + jsAssignmentType.objectFlags |= ObjectFlags.JSLiteral; + return getIntersectionType([returnType, jsAssignmentType]); + } + } + + return returnType; + } + function isSymbolOrSymbolForCall(node: Node) { if (!isCallExpression(node)) return false; let left = node.expression; @@ -34064,6 +34226,10 @@ namespace ts { // falls through case SyntaxKind.NewExpression: return checkCallExpression(node as CallExpression, checkMode); + case SyntaxKind.PipelineHackExpression: + return checkPipelineHackExpression(node as PipelineHackExpression, checkMode); + case SyntaxKind.PipelineApplicationExpression: + return checkPipelineApplicationExpression(node as PipelineApplicationExpression, checkMode); case SyntaxKind.TaggedTemplateExpression: return checkTaggedTemplateExpression(node as TaggedTemplateExpression); case SyntaxKind.ParenthesizedExpression: @@ -40684,6 +40850,9 @@ namespace ts { copySymbol(location.symbol, meaning); } break; + case SyntaxKind.PipelineHackExpression: + // copySymbol(pipelinePlaceholderSymbol, meaning); + break; } if (introducesArgumentsExoticObject(location)) { diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index cbe3aa339e12a..cd7da0b0a510e 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -222,6 +222,10 @@ namespace ts { updateNonNullChain, createMetaProperty, updateMetaProperty, + createPipelineHackExpression, + updatePipelineHackExpression, + createPipelineApplicationExpression, + updatePipelineApplicationExpression, createTemplateSpan, updateTemplateSpan, createSemicolonClassElement, @@ -3144,6 +3148,52 @@ namespace ts { : node; } + // @api + function createPipelineHackExpression(expression: Expression, argument: Expression): PipelineHackExpression { + const node = createBaseExpression(SyntaxKind.PipelineHackExpression); + node.argument = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(argument); + node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); + node.dummyDeclaration = createVariableDeclaration("#", /*exclamationToken*/ undefined, /*type*/ undefined, node.argument); + setParent((node.dummyDeclaration as any).name, node.dummyDeclaration); + setParent(node.dummyDeclaration, node); + setTextRange(node.dummyDeclaration, node.argument); + setTextRange((node.dummyDeclaration as any).name, node.argument); + setNodeFlags(node.dummyDeclaration, NodeFlags.Const); + node.transformFlags |= + propagateChildFlags(node.argument) | + propagateChildFlags(node.expression) | + TransformFlags.ContainsPipeline; + return node; + } + + function createPipelineApplicationExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression { + const node = createBaseExpression(SyntaxKind.PipelineApplicationExpression); + node.argument = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(argument); + node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); + node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);; + node.transformFlags |= + propagateChildFlags(node.argument) | + propagateChildFlags(node.expression) | + TransformFlags.ContainsPipeline; + return node; + } + + // @api + function updatePipelineHackExpression(node: PipelineHackExpression, expression: Expression, argument: Expression): PipelineHackExpression { + return node.expression !== expression + || node.argument !== argument + ? update(createPipelineHackExpression(expression, argument), node) + : node; + } + + function updatePipelineApplicationExpression(node: PipelineApplicationExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression { + return node.expression !== expression + || node.argument !== argument + || node.typeArguments !== typeArguments + ? update(createPipelineApplicationExpression(expression, typeArguments, argument), node) + : node; + } + // // Misc // diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6bb5d0aec31b9..2283c1f711bcc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -242,6 +242,15 @@ namespace ts { visitNode(cbNode, (node as CallExpression).questionDotToken) || visitNodes(cbNode, cbNodes, (node as CallExpression).typeArguments) || visitNodes(cbNode, cbNodes, (node as CallExpression).arguments); + case SyntaxKind.PipelineHackExpression: + return visitNode(cbNode, (node as PipelineHackExpression).argument) || + visitNode(cbNode, (node as PipelineHackExpression).barGreaterThanToken) || + visitNode(cbNode, (node as PipelineHackExpression).expression); + case SyntaxKind.PipelineApplicationExpression: + return visitNode(cbNode, (node as PipelineApplicationExpression).argument) || + visitNode(cbNode, (node as PipelineApplicationExpression).barGreaterThanToken) || + visitNode(cbNode, (node as PipelineApplicationExpression).expression) || + visitNodes(cbNode, cbNodes, (node as PipelineApplicationExpression).typeArguments) ; case SyntaxKind.TaggedTemplateExpression: return visitNode(cbNode, (node as TaggedTemplateExpression).tag) || visitNode(cbNode, (node as TaggedTemplateExpression).questionDotToken) || @@ -4190,7 +4199,7 @@ namespace ts { // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. const pos = getNodePos(); - const expr = parseBinaryExpressionOrHigher(OperatorPrecedence.Lowest); + const expr = parseBinaryExpressionOrHigher(/*precedence*/ 1); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single @@ -4595,7 +4604,38 @@ namespace ts { return node; } - function parseConditionalExpressionRest(leftOperand: Expression, pos: number): Expression { + function parsePipelineHackExpression(leftOperand: Expression): Expression { + return finishNode( + factory.createPipelineHackExpression( + parseBinaryExpressionOrHigher(/*precedence*/ 1), + leftOperand + ), + leftOperand.pos + ); + } + + function parsePipelineApplicationExpression(leftOperand: Expression): Expression { + return finishNode( + factory.createPipelineApplicationExpression( + parseBinaryExpressionOrHigher(/*precedence*/ 1), + /*typeArguments*/ undefined, + leftOperand + ), + leftOperand.pos + ); + } + + function parseConditionalExpressionRest(startLeftOperand: Expression, pos: number): Expression { + let leftOperand = startLeftOperand; + while (token() === SyntaxKind.BarGreaterThanToken || token() === SyntaxKind.BarGreaterThanGreaterThanToken) { + if (parseOptionalToken(SyntaxKind.BarGreaterThanToken)) { + leftOperand = parsePipelineHackExpression(leftOperand); + } + if (parseOptionalToken(SyntaxKind.BarGreaterThanGreaterThanToken)) { + leftOperand = parsePipelineApplicationExpression(leftOperand); + } + } + // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (!questionToken) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 6cac0cb1936d1..4d87aaca6f2ea 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -202,6 +202,8 @@ namespace ts { "~": SyntaxKind.TildeToken, "&&": SyntaxKind.AmpersandAmpersandToken, "||": SyntaxKind.BarBarToken, + "|>": SyntaxKind.BarGreaterThanToken, + "|>>": SyntaxKind.BarGreaterThanGreaterThanToken, "?": SyntaxKind.QuestionToken, "??": SyntaxKind.QuestionQuestionToken, "?.": SyntaxKind.QuestionDotToken, @@ -2011,6 +2013,12 @@ namespace ts { if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.BarEqualsToken; } + if (text.charCodeAt(pos + 1) === CharacterCodes.greaterThan) { + if (text.charCodeAt(pos + 2) === CharacterCodes.greaterThan) { + return pos += 3, token = SyntaxKind.BarGreaterThanGreaterThanToken; + } + return pos += 2, token = SyntaxKind.BarGreaterThanToken; + } pos++; return token = SyntaxKind.BarToken; case CharacterCodes.closeBrace: @@ -2052,12 +2060,24 @@ namespace ts { if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; scanIdentifier(codePointAt(text, pos), languageVersion); + return token = SyntaxKind.PrivateIdentifier; } else { tokenValue = String.fromCharCode(codePointAt(text, pos)); - error(Diagnostics.Invalid_character, pos++, charSize(ch)); + if (/*isInsidePipelineHack*/ false) { + error(Diagnostics.Invalid_character /* Hack placeholder token outside pipeline. */); + return token = SyntaxKind.PrivateIdentifier; + } + else if ((pos >= 1) && text.charCodeAt(pos - 1) === CharacterCodes.dot) { + error(Diagnostics.Invalid_character, pos++, charSize(ch)); + return token = SyntaxKind.PrivateIdentifier; + } + else { + // Pipeline topic + pos++; + return token = SyntaxKind.Identifier; + } } - return token = SyntaxKind.PrivateIdentifier; default: const identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 7207d8a60d75b..9e18a279e50ae 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -49,6 +49,7 @@ namespace ts { transformers.push(transformTypeScript); transformers.push(transformClassFields); + transformers.push(transformPipeline); if (getJSXTransformEnabled(compilerOptions)) { transformers.push(transformJsx); diff --git a/src/compiler/transformers/pipeline.ts b/src/compiler/transformers/pipeline.ts new file mode 100644 index 0000000000000..efe68ef87c0bb --- /dev/null +++ b/src/compiler/transformers/pipeline.ts @@ -0,0 +1,61 @@ +/*@internal*/ +namespace ts { + export const transformPipeline: TransformerFactory = + (context: TransformationContext) => { + const { + factory, + } = context; + return sourceFile => { + const createPipelineVisitor = (currentTokenIdentifier?: Identifier) => + (node: Node): Node => { + + if (node.transformFlags & TransformFlags.ContainsPipeline) { + if (isPipelineHackExpression(node)) { + const placeholderTemp = factory.createUniqueName("pipelineHackPlaceholder"); + context.hoistVariableDeclaration(placeholderTemp); + + return factory.createParenthesizedExpression( + factory.createCommaListExpression([ + factory.createAssignment( + placeholderTemp, + visitNode( + node.argument, + createPipelineVisitor(currentTokenIdentifier), + isExpression + ) + ), + visitNode( + node.expression, + createPipelineVisitor(placeholderTemp), + isExpression + ) + ]) + ); + } + + if (isPipelineApplicationExpression(node)) { + const call = factory.createCallExpression( + visitNode(node.expression, createPipelineVisitor(currentTokenIdentifier)), + /*typeArguments*/ undefined, + [visitNode(node.argument, createPipelineVisitor(currentTokenIdentifier))] + ); + setSourceMapRange(call, node); + setCommentRange(call, node); + return call; + } + + return visitEachChild(node, createPipelineVisitor(currentTokenIdentifier), context); + }; + + if (currentTokenIdentifier) { + if (node.kind === SyntaxKind.Identifier && (node as Identifier).escapedText === "#") { + return currentTokenIdentifier as Node; + } + return visitEachChild(node, createPipelineVisitor(currentTokenIdentifier), context); + } + return node; + }; + return visitNode(sourceFile, createPipelineVisitor()); + }; + }; +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 8561db1c633ef..07c5886ae1971 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -516,6 +516,12 @@ namespace ts { case SyntaxKind.CallExpression: return visitCallExpression(node as CallExpression); + case SyntaxKind.PipelineHackExpression: + return visitPipelineHackExpression(node as PipelineHackExpression); + + case SyntaxKind.PipelineApplicationExpression: + return visitPipelineApplicationExpression(node as PipelineApplicationExpression); + case SyntaxKind.NewExpression: return visitNewExpression(node as NewExpression); @@ -2266,6 +2272,21 @@ namespace ts { visitNodes(node.arguments, visitor, isExpression)); } + function visitPipelineHackExpression(node: PipelineHackExpression) { + return factory.updatePipelineHackExpression( + node, + visitNode(node.expression, visitor, isExpression), + visitNode(node.argument, visitor, isExpression)); + } + + function visitPipelineApplicationExpression(node: PipelineApplicationExpression) { + return factory.updatePipelineApplicationExpression( + node, + visitNode(node.expression, visitor, isExpression), + /*typeArguments*/ undefined, + visitNode(node.argument, visitor, isExpression)); + } + function visitNewExpression(node: NewExpression) { return factory.updateNewExpression( node, diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index c5db068d120c1..c175384d7a224 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -49,6 +49,7 @@ "transformers/taggedTemplate.ts", "transformers/ts.ts", "transformers/classFields.ts", + "transformers/pipeline.ts", "transformers/es2017.ts", "transformers/es2018.ts", "transformers/es2019.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b5424879454f6..29350269ac316 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -64,6 +64,8 @@ namespace ts { EqualsEqualsEqualsToken, ExclamationEqualsEqualsToken, EqualsGreaterThanToken, + BarGreaterThanToken, + BarGreaterThanGreaterThanToken, PlusToken, MinusToken, AsteriskToken, @@ -249,6 +251,8 @@ namespace ts { PropertyAccessExpression, ElementAccessExpression, CallExpression, + PipelineHackExpression, + PipelineApplicationExpression, NewExpression, TaggedTemplateExpression, TypeAssertionExpression, @@ -503,6 +507,8 @@ namespace ts { | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken + | SyntaxKind.BarGreaterThanToken + | SyntaxKind.BarGreaterThanGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken @@ -540,6 +546,7 @@ namespace ts { | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken + | SyntaxKind.HashToken ; export type KeywordSyntaxKind = @@ -1036,7 +1043,10 @@ namespace ts { export type EqualsGreaterThanToken = PunctuationToken; export type PlusToken = PunctuationToken; export type MinusToken = PunctuationToken; + export type BarGreaterThanToken = PunctuationToken; + export type BarGreaterThanGreaterThanToken = PunctuationToken; export type QuestionDotToken = PunctuationToken; + export type HashToken = PunctuationToken; // Keywords export interface KeywordToken extends Token { @@ -1973,6 +1983,12 @@ namespace ts { | LogicalOperator ; + export type PipelineOperatorOrHigher + = LogicalOperatorOrHigher + | SyntaxKind.BarGreaterThanToken + | SyntaxKind.BarGreaterThanGreaterThanToken + ; + // see: https://tc39.github.io/ecma262/#prod-AssignmentOperator export type CompoundAssignmentOperator = | SyntaxKind.PlusEqualsToken @@ -2002,6 +2018,7 @@ namespace ts { export type AssignmentOperatorOrHigher = | SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher + | PipelineOperatorOrHigher | AssignmentOperator ; @@ -2364,6 +2381,22 @@ namespace ts { readonly arguments: NodeArray; } + export interface PipelineHackExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineHackExpression; + readonly expression: Expression; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + readonly dummyDeclaration: Declaration; + } + + export interface PipelineApplicationExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineApplicationExpression; + readonly expression: Expression; + readonly typeArguments?: NodeArray; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + } + export interface CallChain extends CallExpression { _optionalChainBrand: any; } @@ -2470,6 +2503,7 @@ namespace ts { | NewExpression | TaggedTemplateExpression | Decorator + | PipelineApplicationExpression | JsxOpeningLikeElement ; @@ -5027,6 +5061,7 @@ namespace ts { ExportEquals = "export=", // Export assignment symbol Default = "default", // Default export symbol (technically not wholly internal, but included here for usability) This = "this", + HackPipelineReference = "#", } /** @@ -6754,6 +6789,9 @@ namespace ts { ContainsPossibleTopLevelAwait = 1 << 24, ContainsLexicalSuper = 1 << 25, ContainsUpdateExpressionForIdentifier = 1 << 26, + // ContainsPartialApplication = 1 << 27, // Reserved. + ContainsPipeline = 1 << 28, + // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. // It is a good reminder of how much room we have left @@ -7363,6 +7401,10 @@ namespace ts { updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain; createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty; updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty; + createPipelineHackExpression(expression: Expression, argument: Expression): PipelineHackExpression; + updatePipelineHackExpression(node: PipelineHackExpression, expression: Expression, argument: Expression): PipelineHackExpression; + createPipelineApplicationExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; + updatePipelineApplicationExpression(node: PipelineApplicationExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; // // Misc diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a24f61a93fa02..8f6979486eb1e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1918,6 +1918,8 @@ namespace ts { case SyntaxKind.ElementAccessExpression: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: + case SyntaxKind.PipelineHackExpression: + case SyntaxKind.PipelineApplicationExpression: case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.AsExpression: case SyntaxKind.TypeAssertionExpression: @@ -3741,6 +3743,9 @@ namespace ts { export function getBinaryOperatorPrecedence(kind: SyntaxKind): OperatorPrecedence { switch (kind) { + case SyntaxKind.BarGreaterThanToken: + case SyntaxKind.BarGreaterThanGreaterThanToken: + return 1; case SyntaxKind.QuestionQuestionToken: return OperatorPrecedence.Coalesce; case SyntaxKind.BarBarToken: diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 8f834e5e45971..8c82c9e141aa1 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -1022,6 +1022,14 @@ namespace ts { return skipOuterExpressions(node, OuterExpressionKinds.PartiallyEmittedExpressions); } + export function isPipelineHackExpression(node: Node): node is PipelineHackExpression { + return node.kind === SyntaxKind.PipelineHackExpression; + } + + export function isPipelineApplicationExpression(node: Node): node is PipelineApplicationExpression { + return node.kind === SyntaxKind.PipelineApplicationExpression; + } + export function isNonNullChain(node: Node): node is NonNullChain { return isNonNullExpression(node) && !!(node.flags & NodeFlags.OptionalChain); } @@ -1508,6 +1516,8 @@ namespace ts { case SyntaxKind.ElementAccessExpression: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: + case SyntaxKind.PipelineHackExpression: + case SyntaxKind.PipelineApplicationExpression: case SyntaxKind.JsxElement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxFragment: diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 5651ac043d325..23160b0d04c4b 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -720,6 +720,19 @@ namespace ts { nodesVisitor(node.typeArguments, visitor, isTypeNode), nodesVisitor(node.arguments, visitor, isExpression)); + case SyntaxKind.PipelineHackExpression: + Debug.type(node); + return factory.updatePipelineHackExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.argument, visitor, isExpression)); + + case SyntaxKind.PipelineApplicationExpression: + Debug.type(node); + return factory.updatePipelineApplicationExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodeVisitor(node.argument, visitor, isExpression)); + case SyntaxKind.NewExpression: Debug.type(node); return factory.updateNewExpression(node, diff --git a/src/harness/harnessUtils.ts b/src/harness/harnessUtils.ts index cfc6f59f30050..ca60ec13a5bd5 100644 --- a/src/harness/harnessUtils.ts +++ b/src/harness/harnessUtils.ts @@ -122,7 +122,7 @@ namespace Utils { for (const childName in node) { if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator" || // for now ignore jsdoc comments - childName === "jsDocComment" || childName === "checkJsDirective" || childName === "commonJsModuleIndicator") { + childName === "jsDocComment" || childName === "checkJsDirective" || childName === "commonJsModuleIndicator" || childName === "dummyDeclaration") { continue; } const child = (node as any)[childName]; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index aebc52b2fb0f8..64d8f1f64a92c 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -163,12 +163,12 @@ namespace ts.FindAllReferences { } } - export function toContextSpan(textSpan: TextSpan, sourceFile: SourceFile, context?: ContextNode): { contextSpan: TextSpan } | undefined { + export function toContextSpan(textSpan: TextSpan, sourceFile: SourceFile, context?: ContextNode, forceContext = false): { contextSpan: TextSpan } | undefined { if (!context) return undefined; const contextSpan = isContextWithStartAndEndNode(context) ? getTextSpan(context.start, sourceFile, context.end) : getTextSpan(context, sourceFile); - return contextSpan.start !== textSpan.start || contextSpan.length !== textSpan.length ? + return forceContext || contextSpan.start !== textSpan.start || contextSpan.length !== textSpan.length ? { contextSpan } : undefined; } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 9ae8dda40f84c..46a5d932d9546 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -347,10 +347,8 @@ namespace ts.GoToDefinition { /** Creates a DefinitionInfo directly from the name of a declaration. */ function createDefinitionInfoFromName(checker: TypeChecker, declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string, textSpan?: TextSpan): DefinitionInfo { const sourceFile = declaration.getSourceFile(); - if (!textSpan) { - const name = getNameOfDeclaration(declaration) || declaration; - textSpan = createTextSpanFromNode(name, sourceFile); - } + const name = getNameOfDeclaration(declaration) || declaration; + textSpan ||= createTextSpanFromNode(name, sourceFile); return { fileName: sourceFile.fileName, textSpan, @@ -361,7 +359,8 @@ namespace ts.GoToDefinition { ...FindAllReferences.toContextSpan( textSpan, sourceFile, - FindAllReferences.getContextNode(declaration) + FindAllReferences.getContextNode(declaration), + /*forceContext*/isIdentifier(name) && name.escapedText === "#" ), isLocal: !isDefinitionVisible(checker, declaration) }; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 752f6b892bb4a..f7602c6d05c76 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -142,339 +142,343 @@ declare namespace ts { EqualsEqualsEqualsToken = 36, ExclamationEqualsEqualsToken = 37, EqualsGreaterThanToken = 38, - PlusToken = 39, - MinusToken = 40, - AsteriskToken = 41, - AsteriskAsteriskToken = 42, - SlashToken = 43, - PercentToken = 44, - PlusPlusToken = 45, - MinusMinusToken = 46, - LessThanLessThanToken = 47, - GreaterThanGreaterThanToken = 48, - GreaterThanGreaterThanGreaterThanToken = 49, - AmpersandToken = 50, - BarToken = 51, - CaretToken = 52, - ExclamationToken = 53, - TildeToken = 54, - AmpersandAmpersandToken = 55, - BarBarToken = 56, - QuestionToken = 57, - ColonToken = 58, - AtToken = 59, - QuestionQuestionToken = 60, + BarGreaterThanToken = 39, + BarGreaterThanGreaterThanToken = 40, + PlusToken = 41, + MinusToken = 42, + AsteriskToken = 43, + AsteriskAsteriskToken = 44, + SlashToken = 45, + PercentToken = 46, + PlusPlusToken = 47, + MinusMinusToken = 48, + LessThanLessThanToken = 49, + GreaterThanGreaterThanToken = 50, + GreaterThanGreaterThanGreaterThanToken = 51, + AmpersandToken = 52, + BarToken = 53, + CaretToken = 54, + ExclamationToken = 55, + TildeToken = 56, + AmpersandAmpersandToken = 57, + BarBarToken = 58, + QuestionToken = 59, + ColonToken = 60, + AtToken = 61, + QuestionQuestionToken = 62, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 61, + BacktickToken = 63, /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ - HashToken = 62, - EqualsToken = 63, - PlusEqualsToken = 64, - MinusEqualsToken = 65, - AsteriskEqualsToken = 66, - AsteriskAsteriskEqualsToken = 67, - SlashEqualsToken = 68, - PercentEqualsToken = 69, - LessThanLessThanEqualsToken = 70, - GreaterThanGreaterThanEqualsToken = 71, - GreaterThanGreaterThanGreaterThanEqualsToken = 72, - AmpersandEqualsToken = 73, - BarEqualsToken = 74, - BarBarEqualsToken = 75, - AmpersandAmpersandEqualsToken = 76, - QuestionQuestionEqualsToken = 77, - CaretEqualsToken = 78, - Identifier = 79, - PrivateIdentifier = 80, - BreakKeyword = 81, - CaseKeyword = 82, - CatchKeyword = 83, - ClassKeyword = 84, - ConstKeyword = 85, - ContinueKeyword = 86, - DebuggerKeyword = 87, - DefaultKeyword = 88, - DeleteKeyword = 89, - DoKeyword = 90, - ElseKeyword = 91, - EnumKeyword = 92, - ExportKeyword = 93, - ExtendsKeyword = 94, - FalseKeyword = 95, - FinallyKeyword = 96, - ForKeyword = 97, - FunctionKeyword = 98, - IfKeyword = 99, - ImportKeyword = 100, - InKeyword = 101, - InstanceOfKeyword = 102, - NewKeyword = 103, - NullKeyword = 104, - ReturnKeyword = 105, - SuperKeyword = 106, - SwitchKeyword = 107, - ThisKeyword = 108, - ThrowKeyword = 109, - TrueKeyword = 110, - TryKeyword = 111, - TypeOfKeyword = 112, - VarKeyword = 113, - VoidKeyword = 114, - WhileKeyword = 115, - WithKeyword = 116, - ImplementsKeyword = 117, - InterfaceKeyword = 118, - LetKeyword = 119, - PackageKeyword = 120, - PrivateKeyword = 121, - ProtectedKeyword = 122, - PublicKeyword = 123, - StaticKeyword = 124, - YieldKeyword = 125, - AbstractKeyword = 126, - AsKeyword = 127, - AssertsKeyword = 128, - AssertKeyword = 129, - AnyKeyword = 130, - AsyncKeyword = 131, - AwaitKeyword = 132, - BooleanKeyword = 133, - ConstructorKeyword = 134, - DeclareKeyword = 135, - GetKeyword = 136, - InferKeyword = 137, - IntrinsicKeyword = 138, - IsKeyword = 139, - KeyOfKeyword = 140, - ModuleKeyword = 141, - NamespaceKeyword = 142, - NeverKeyword = 143, - ReadonlyKeyword = 144, - RequireKeyword = 145, - NumberKeyword = 146, - ObjectKeyword = 147, - SetKeyword = 148, - StringKeyword = 149, - SymbolKeyword = 150, - TypeKeyword = 151, - UndefinedKeyword = 152, - UniqueKeyword = 153, - UnknownKeyword = 154, - FromKeyword = 155, - GlobalKeyword = 156, - BigIntKeyword = 157, - OverrideKeyword = 158, - OfKeyword = 159, - QualifiedName = 160, - ComputedPropertyName = 161, - TypeParameter = 162, - Parameter = 163, - Decorator = 164, - PropertySignature = 165, - PropertyDeclaration = 166, - MethodSignature = 167, - MethodDeclaration = 168, - ClassStaticBlockDeclaration = 169, - Constructor = 170, - GetAccessor = 171, - SetAccessor = 172, - CallSignature = 173, - ConstructSignature = 174, - IndexSignature = 175, - TypePredicate = 176, - TypeReference = 177, - FunctionType = 178, - ConstructorType = 179, - TypeQuery = 180, - TypeLiteral = 181, - ArrayType = 182, - TupleType = 183, - OptionalType = 184, - RestType = 185, - UnionType = 186, - IntersectionType = 187, - ConditionalType = 188, - InferType = 189, - ParenthesizedType = 190, - ThisType = 191, - TypeOperator = 192, - IndexedAccessType = 193, - MappedType = 194, - LiteralType = 195, - NamedTupleMember = 196, - TemplateLiteralType = 197, - TemplateLiteralTypeSpan = 198, - ImportType = 199, - ObjectBindingPattern = 200, - ArrayBindingPattern = 201, - BindingElement = 202, - ArrayLiteralExpression = 203, - ObjectLiteralExpression = 204, - PropertyAccessExpression = 205, - ElementAccessExpression = 206, - CallExpression = 207, - NewExpression = 208, - TaggedTemplateExpression = 209, - TypeAssertionExpression = 210, - ParenthesizedExpression = 211, - FunctionExpression = 212, - ArrowFunction = 213, - DeleteExpression = 214, - TypeOfExpression = 215, - VoidExpression = 216, - AwaitExpression = 217, - PrefixUnaryExpression = 218, - PostfixUnaryExpression = 219, - BinaryExpression = 220, - ConditionalExpression = 221, - TemplateExpression = 222, - YieldExpression = 223, - SpreadElement = 224, - ClassExpression = 225, - OmittedExpression = 226, - ExpressionWithTypeArguments = 227, - AsExpression = 228, - NonNullExpression = 229, - MetaProperty = 230, - SyntheticExpression = 231, - TemplateSpan = 232, - SemicolonClassElement = 233, - Block = 234, - EmptyStatement = 235, - VariableStatement = 236, - ExpressionStatement = 237, - IfStatement = 238, - DoStatement = 239, - WhileStatement = 240, - ForStatement = 241, - ForInStatement = 242, - ForOfStatement = 243, - ContinueStatement = 244, - BreakStatement = 245, - ReturnStatement = 246, - WithStatement = 247, - SwitchStatement = 248, - LabeledStatement = 249, - ThrowStatement = 250, - TryStatement = 251, - DebuggerStatement = 252, - VariableDeclaration = 253, - VariableDeclarationList = 254, - FunctionDeclaration = 255, - ClassDeclaration = 256, - InterfaceDeclaration = 257, - TypeAliasDeclaration = 258, - EnumDeclaration = 259, - ModuleDeclaration = 260, - ModuleBlock = 261, - CaseBlock = 262, - NamespaceExportDeclaration = 263, - ImportEqualsDeclaration = 264, - ImportDeclaration = 265, - ImportClause = 266, - NamespaceImport = 267, - NamedImports = 268, - ImportSpecifier = 269, - ExportAssignment = 270, - ExportDeclaration = 271, - NamedExports = 272, - NamespaceExport = 273, - ExportSpecifier = 274, - MissingDeclaration = 275, - ExternalModuleReference = 276, - JsxElement = 277, - JsxSelfClosingElement = 278, - JsxOpeningElement = 279, - JsxClosingElement = 280, - JsxFragment = 281, - JsxOpeningFragment = 282, - JsxClosingFragment = 283, - JsxAttribute = 284, - JsxAttributes = 285, - JsxSpreadAttribute = 286, - JsxExpression = 287, - CaseClause = 288, - DefaultClause = 289, - HeritageClause = 290, - CatchClause = 291, - AssertClause = 292, - AssertEntry = 293, - PropertyAssignment = 294, - ShorthandPropertyAssignment = 295, - SpreadAssignment = 296, - EnumMember = 297, - UnparsedPrologue = 298, - UnparsedPrepend = 299, - UnparsedText = 300, - UnparsedInternalText = 301, - UnparsedSyntheticReference = 302, - SourceFile = 303, - Bundle = 304, - UnparsedSource = 305, - InputFiles = 306, - JSDocTypeExpression = 307, - JSDocNameReference = 308, - JSDocMemberName = 309, - JSDocAllType = 310, - JSDocUnknownType = 311, - JSDocNullableType = 312, - JSDocNonNullableType = 313, - JSDocOptionalType = 314, - JSDocFunctionType = 315, - JSDocVariadicType = 316, - JSDocNamepathType = 317, - JSDocComment = 318, - JSDocText = 319, - JSDocTypeLiteral = 320, - JSDocSignature = 321, - JSDocLink = 322, - JSDocLinkCode = 323, - JSDocLinkPlain = 324, - JSDocTag = 325, - JSDocAugmentsTag = 326, - JSDocImplementsTag = 327, - JSDocAuthorTag = 328, - JSDocDeprecatedTag = 329, - JSDocClassTag = 330, - JSDocPublicTag = 331, - JSDocPrivateTag = 332, - JSDocProtectedTag = 333, - JSDocReadonlyTag = 334, - JSDocOverrideTag = 335, - JSDocCallbackTag = 336, - JSDocEnumTag = 337, - JSDocParameterTag = 338, - JSDocReturnTag = 339, - JSDocThisTag = 340, - JSDocTypeTag = 341, - JSDocTemplateTag = 342, - JSDocTypedefTag = 343, - JSDocSeeTag = 344, - JSDocPropertyTag = 345, - SyntaxList = 346, - NotEmittedStatement = 347, - PartiallyEmittedExpression = 348, - CommaListExpression = 349, - MergeDeclarationMarker = 350, - EndOfDeclarationMarker = 351, - SyntheticReferenceExpression = 352, - Count = 353, - FirstAssignment = 63, - LastAssignment = 78, - FirstCompoundAssignment = 64, - LastCompoundAssignment = 78, - FirstReservedWord = 81, - LastReservedWord = 116, - FirstKeyword = 81, - LastKeyword = 159, - FirstFutureReservedWord = 117, - LastFutureReservedWord = 125, - FirstTypeNode = 176, - LastTypeNode = 199, + HashToken = 64, + EqualsToken = 65, + PlusEqualsToken = 66, + MinusEqualsToken = 67, + AsteriskEqualsToken = 68, + AsteriskAsteriskEqualsToken = 69, + SlashEqualsToken = 70, + PercentEqualsToken = 71, + LessThanLessThanEqualsToken = 72, + GreaterThanGreaterThanEqualsToken = 73, + GreaterThanGreaterThanGreaterThanEqualsToken = 74, + AmpersandEqualsToken = 75, + BarEqualsToken = 76, + BarBarEqualsToken = 77, + AmpersandAmpersandEqualsToken = 78, + QuestionQuestionEqualsToken = 79, + CaretEqualsToken = 80, + Identifier = 81, + PrivateIdentifier = 82, + BreakKeyword = 83, + CaseKeyword = 84, + CatchKeyword = 85, + ClassKeyword = 86, + ConstKeyword = 87, + ContinueKeyword = 88, + DebuggerKeyword = 89, + DefaultKeyword = 90, + DeleteKeyword = 91, + DoKeyword = 92, + ElseKeyword = 93, + EnumKeyword = 94, + ExportKeyword = 95, + ExtendsKeyword = 96, + FalseKeyword = 97, + FinallyKeyword = 98, + ForKeyword = 99, + FunctionKeyword = 100, + IfKeyword = 101, + ImportKeyword = 102, + InKeyword = 103, + InstanceOfKeyword = 104, + NewKeyword = 105, + NullKeyword = 106, + ReturnKeyword = 107, + SuperKeyword = 108, + SwitchKeyword = 109, + ThisKeyword = 110, + ThrowKeyword = 111, + TrueKeyword = 112, + TryKeyword = 113, + TypeOfKeyword = 114, + VarKeyword = 115, + VoidKeyword = 116, + WhileKeyword = 117, + WithKeyword = 118, + ImplementsKeyword = 119, + InterfaceKeyword = 120, + LetKeyword = 121, + PackageKeyword = 122, + PrivateKeyword = 123, + ProtectedKeyword = 124, + PublicKeyword = 125, + StaticKeyword = 126, + YieldKeyword = 127, + AbstractKeyword = 128, + AsKeyword = 129, + AssertsKeyword = 130, + AssertKeyword = 131, + AnyKeyword = 132, + AsyncKeyword = 133, + AwaitKeyword = 134, + BooleanKeyword = 135, + ConstructorKeyword = 136, + DeclareKeyword = 137, + GetKeyword = 138, + InferKeyword = 139, + IntrinsicKeyword = 140, + IsKeyword = 141, + KeyOfKeyword = 142, + ModuleKeyword = 143, + NamespaceKeyword = 144, + NeverKeyword = 145, + ReadonlyKeyword = 146, + RequireKeyword = 147, + NumberKeyword = 148, + ObjectKeyword = 149, + SetKeyword = 150, + StringKeyword = 151, + SymbolKeyword = 152, + TypeKeyword = 153, + UndefinedKeyword = 154, + UniqueKeyword = 155, + UnknownKeyword = 156, + FromKeyword = 157, + GlobalKeyword = 158, + BigIntKeyword = 159, + OverrideKeyword = 160, + OfKeyword = 161, + QualifiedName = 162, + ComputedPropertyName = 163, + TypeParameter = 164, + Parameter = 165, + Decorator = 166, + PropertySignature = 167, + PropertyDeclaration = 168, + MethodSignature = 169, + MethodDeclaration = 170, + ClassStaticBlockDeclaration = 171, + Constructor = 172, + GetAccessor = 173, + SetAccessor = 174, + CallSignature = 175, + ConstructSignature = 176, + IndexSignature = 177, + TypePredicate = 178, + TypeReference = 179, + FunctionType = 180, + ConstructorType = 181, + TypeQuery = 182, + TypeLiteral = 183, + ArrayType = 184, + TupleType = 185, + OptionalType = 186, + RestType = 187, + UnionType = 188, + IntersectionType = 189, + ConditionalType = 190, + InferType = 191, + ParenthesizedType = 192, + ThisType = 193, + TypeOperator = 194, + IndexedAccessType = 195, + MappedType = 196, + LiteralType = 197, + NamedTupleMember = 198, + TemplateLiteralType = 199, + TemplateLiteralTypeSpan = 200, + ImportType = 201, + ObjectBindingPattern = 202, + ArrayBindingPattern = 203, + BindingElement = 204, + ArrayLiteralExpression = 205, + ObjectLiteralExpression = 206, + PropertyAccessExpression = 207, + ElementAccessExpression = 208, + CallExpression = 209, + PipelineHackExpression = 210, + PipelineApplicationExpression = 211, + NewExpression = 212, + TaggedTemplateExpression = 213, + TypeAssertionExpression = 214, + ParenthesizedExpression = 215, + FunctionExpression = 216, + ArrowFunction = 217, + DeleteExpression = 218, + TypeOfExpression = 219, + VoidExpression = 220, + AwaitExpression = 221, + PrefixUnaryExpression = 222, + PostfixUnaryExpression = 223, + BinaryExpression = 224, + ConditionalExpression = 225, + TemplateExpression = 226, + YieldExpression = 227, + SpreadElement = 228, + ClassExpression = 229, + OmittedExpression = 230, + ExpressionWithTypeArguments = 231, + AsExpression = 232, + NonNullExpression = 233, + MetaProperty = 234, + SyntheticExpression = 235, + TemplateSpan = 236, + SemicolonClassElement = 237, + Block = 238, + EmptyStatement = 239, + VariableStatement = 240, + ExpressionStatement = 241, + IfStatement = 242, + DoStatement = 243, + WhileStatement = 244, + ForStatement = 245, + ForInStatement = 246, + ForOfStatement = 247, + ContinueStatement = 248, + BreakStatement = 249, + ReturnStatement = 250, + WithStatement = 251, + SwitchStatement = 252, + LabeledStatement = 253, + ThrowStatement = 254, + TryStatement = 255, + DebuggerStatement = 256, + VariableDeclaration = 257, + VariableDeclarationList = 258, + FunctionDeclaration = 259, + ClassDeclaration = 260, + InterfaceDeclaration = 261, + TypeAliasDeclaration = 262, + EnumDeclaration = 263, + ModuleDeclaration = 264, + ModuleBlock = 265, + CaseBlock = 266, + NamespaceExportDeclaration = 267, + ImportEqualsDeclaration = 268, + ImportDeclaration = 269, + ImportClause = 270, + NamespaceImport = 271, + NamedImports = 272, + ImportSpecifier = 273, + ExportAssignment = 274, + ExportDeclaration = 275, + NamedExports = 276, + NamespaceExport = 277, + ExportSpecifier = 278, + MissingDeclaration = 279, + ExternalModuleReference = 280, + JsxElement = 281, + JsxSelfClosingElement = 282, + JsxOpeningElement = 283, + JsxClosingElement = 284, + JsxFragment = 285, + JsxOpeningFragment = 286, + JsxClosingFragment = 287, + JsxAttribute = 288, + JsxAttributes = 289, + JsxSpreadAttribute = 290, + JsxExpression = 291, + CaseClause = 292, + DefaultClause = 293, + HeritageClause = 294, + CatchClause = 295, + AssertClause = 296, + AssertEntry = 297, + PropertyAssignment = 298, + ShorthandPropertyAssignment = 299, + SpreadAssignment = 300, + EnumMember = 301, + UnparsedPrologue = 302, + UnparsedPrepend = 303, + UnparsedText = 304, + UnparsedInternalText = 305, + UnparsedSyntheticReference = 306, + SourceFile = 307, + Bundle = 308, + UnparsedSource = 309, + InputFiles = 310, + JSDocTypeExpression = 311, + JSDocNameReference = 312, + JSDocMemberName = 313, + JSDocAllType = 314, + JSDocUnknownType = 315, + JSDocNullableType = 316, + JSDocNonNullableType = 317, + JSDocOptionalType = 318, + JSDocFunctionType = 319, + JSDocVariadicType = 320, + JSDocNamepathType = 321, + JSDocComment = 322, + JSDocText = 323, + JSDocTypeLiteral = 324, + JSDocSignature = 325, + JSDocLink = 326, + JSDocLinkCode = 327, + JSDocLinkPlain = 328, + JSDocTag = 329, + JSDocAugmentsTag = 330, + JSDocImplementsTag = 331, + JSDocAuthorTag = 332, + JSDocDeprecatedTag = 333, + JSDocClassTag = 334, + JSDocPublicTag = 335, + JSDocPrivateTag = 336, + JSDocProtectedTag = 337, + JSDocReadonlyTag = 338, + JSDocOverrideTag = 339, + JSDocCallbackTag = 340, + JSDocEnumTag = 341, + JSDocParameterTag = 342, + JSDocReturnTag = 343, + JSDocThisTag = 344, + JSDocTypeTag = 345, + JSDocTemplateTag = 346, + JSDocTypedefTag = 347, + JSDocSeeTag = 348, + JSDocPropertyTag = 349, + SyntaxList = 350, + NotEmittedStatement = 351, + PartiallyEmittedExpression = 352, + CommaListExpression = 353, + MergeDeclarationMarker = 354, + EndOfDeclarationMarker = 355, + SyntheticReferenceExpression = 356, + Count = 357, + FirstAssignment = 65, + LastAssignment = 80, + FirstCompoundAssignment = 66, + LastCompoundAssignment = 80, + FirstReservedWord = 83, + LastReservedWord = 118, + FirstKeyword = 83, + LastKeyword = 161, + FirstFutureReservedWord = 119, + LastFutureReservedWord = 127, + FirstTypeNode = 178, + LastTypeNode = 201, FirstPunctuation = 18, - LastPunctuation = 78, + LastPunctuation = 80, FirstToken = 0, - LastToken = 159, + LastToken = 161, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -482,19 +486,19 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 78, - FirstStatement = 236, - LastStatement = 252, - FirstNode = 160, - FirstJSDocNode = 307, - LastJSDocNode = 345, - FirstJSDocTagNode = 325, - LastJSDocTagNode = 345, + LastBinaryOperator = 80, + FirstStatement = 240, + LastStatement = 256, + FirstNode = 162, + FirstJSDocNode = 311, + LastJSDocNode = 349, + FirstJSDocTagNode = 329, + LastJSDocTagNode = 349, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.BarGreaterThanToken | SyntaxKind.BarGreaterThanGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.HashToken; export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; @@ -596,7 +600,10 @@ declare namespace ts { export type EqualsGreaterThanToken = PunctuationToken; export type PlusToken = PunctuationToken; export type MinusToken = PunctuationToken; + export type BarGreaterThanToken = PunctuationToken; + export type BarGreaterThanGreaterThanToken = PunctuationToken; export type QuestionDotToken = PunctuationToken; + export type HashToken = PunctuationToken; export interface KeywordToken extends Token { } export type AssertsKeyword = KeywordToken; @@ -1096,9 +1103,10 @@ declare namespace ts { export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type PipelineOperatorOrHigher = LogicalOperatorOrHigher | SyntaxKind.BarGreaterThanToken | SyntaxKind.BarGreaterThanGreaterThanToken; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.QuestionQuestionEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | PipelineOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type LogicalOrCoalescingAssignmentOperator = SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionEqualsToken; export type BinaryOperatorToken = Token; @@ -1275,6 +1283,20 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly arguments: NodeArray; } + export interface PipelineHackExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineHackExpression; + readonly expression: Expression; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + readonly dummyDeclaration: Declaration; + } + export interface PipelineApplicationExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineApplicationExpression; + readonly expression: Expression; + readonly typeArguments?: NodeArray; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + } export interface CallChain extends CallExpression { _optionalChainBrand: any; } @@ -1302,7 +1324,7 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly template: TemplateLiteral; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | PipelineApplicationExpression | JsxOpeningLikeElement; export interface AsExpression extends Expression { readonly kind: SyntaxKind.AsExpression; readonly expression: Expression; @@ -2536,7 +2558,8 @@ declare namespace ts { Resolving = "__resolving__", ExportEquals = "export=", Default = "default", - This = "this" + This = "this", + HackPipelineReference = "#" } /** * This represents a string whose leading underscore have been escaped by adding extra leading underscores. @@ -3507,6 +3530,10 @@ declare namespace ts { updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain; createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty; updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty; + createPipelineHackExpression(expression: Expression, argument: Expression): PipelineHackExpression; + updatePipelineHackExpression(node: PipelineHackExpression, expression: Expression, argument: Expression): PipelineHackExpression; + createPipelineApplicationExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; + updatePipelineApplicationExpression(node: PipelineApplicationExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; createSemicolonClassElement(): SemicolonClassElement; @@ -4380,6 +4407,8 @@ declare namespace ts { function isConstTypeReference(node: Node): boolean; function skipPartiallyEmittedExpressions(node: Expression): Expression; function skipPartiallyEmittedExpressions(node: Node): Node; + function isPipelineHackExpression(node: Node): node is PipelineHackExpression; + function isPipelineApplicationExpression(node: Node): node is PipelineApplicationExpression; function isNonNullChain(node: Node): node is NonNullChain; function isBreakOrContinueStatement(node: Node): node is BreakOrContinueStatement; function isNamedExportBindings(node: Node): node is NamedExportBindings; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index a9d7e9c449b80..4beb759276b71 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -142,339 +142,343 @@ declare namespace ts { EqualsEqualsEqualsToken = 36, ExclamationEqualsEqualsToken = 37, EqualsGreaterThanToken = 38, - PlusToken = 39, - MinusToken = 40, - AsteriskToken = 41, - AsteriskAsteriskToken = 42, - SlashToken = 43, - PercentToken = 44, - PlusPlusToken = 45, - MinusMinusToken = 46, - LessThanLessThanToken = 47, - GreaterThanGreaterThanToken = 48, - GreaterThanGreaterThanGreaterThanToken = 49, - AmpersandToken = 50, - BarToken = 51, - CaretToken = 52, - ExclamationToken = 53, - TildeToken = 54, - AmpersandAmpersandToken = 55, - BarBarToken = 56, - QuestionToken = 57, - ColonToken = 58, - AtToken = 59, - QuestionQuestionToken = 60, + BarGreaterThanToken = 39, + BarGreaterThanGreaterThanToken = 40, + PlusToken = 41, + MinusToken = 42, + AsteriskToken = 43, + AsteriskAsteriskToken = 44, + SlashToken = 45, + PercentToken = 46, + PlusPlusToken = 47, + MinusMinusToken = 48, + LessThanLessThanToken = 49, + GreaterThanGreaterThanToken = 50, + GreaterThanGreaterThanGreaterThanToken = 51, + AmpersandToken = 52, + BarToken = 53, + CaretToken = 54, + ExclamationToken = 55, + TildeToken = 56, + AmpersandAmpersandToken = 57, + BarBarToken = 58, + QuestionToken = 59, + ColonToken = 60, + AtToken = 61, + QuestionQuestionToken = 62, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 61, + BacktickToken = 63, /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ - HashToken = 62, - EqualsToken = 63, - PlusEqualsToken = 64, - MinusEqualsToken = 65, - AsteriskEqualsToken = 66, - AsteriskAsteriskEqualsToken = 67, - SlashEqualsToken = 68, - PercentEqualsToken = 69, - LessThanLessThanEqualsToken = 70, - GreaterThanGreaterThanEqualsToken = 71, - GreaterThanGreaterThanGreaterThanEqualsToken = 72, - AmpersandEqualsToken = 73, - BarEqualsToken = 74, - BarBarEqualsToken = 75, - AmpersandAmpersandEqualsToken = 76, - QuestionQuestionEqualsToken = 77, - CaretEqualsToken = 78, - Identifier = 79, - PrivateIdentifier = 80, - BreakKeyword = 81, - CaseKeyword = 82, - CatchKeyword = 83, - ClassKeyword = 84, - ConstKeyword = 85, - ContinueKeyword = 86, - DebuggerKeyword = 87, - DefaultKeyword = 88, - DeleteKeyword = 89, - DoKeyword = 90, - ElseKeyword = 91, - EnumKeyword = 92, - ExportKeyword = 93, - ExtendsKeyword = 94, - FalseKeyword = 95, - FinallyKeyword = 96, - ForKeyword = 97, - FunctionKeyword = 98, - IfKeyword = 99, - ImportKeyword = 100, - InKeyword = 101, - InstanceOfKeyword = 102, - NewKeyword = 103, - NullKeyword = 104, - ReturnKeyword = 105, - SuperKeyword = 106, - SwitchKeyword = 107, - ThisKeyword = 108, - ThrowKeyword = 109, - TrueKeyword = 110, - TryKeyword = 111, - TypeOfKeyword = 112, - VarKeyword = 113, - VoidKeyword = 114, - WhileKeyword = 115, - WithKeyword = 116, - ImplementsKeyword = 117, - InterfaceKeyword = 118, - LetKeyword = 119, - PackageKeyword = 120, - PrivateKeyword = 121, - ProtectedKeyword = 122, - PublicKeyword = 123, - StaticKeyword = 124, - YieldKeyword = 125, - AbstractKeyword = 126, - AsKeyword = 127, - AssertsKeyword = 128, - AssertKeyword = 129, - AnyKeyword = 130, - AsyncKeyword = 131, - AwaitKeyword = 132, - BooleanKeyword = 133, - ConstructorKeyword = 134, - DeclareKeyword = 135, - GetKeyword = 136, - InferKeyword = 137, - IntrinsicKeyword = 138, - IsKeyword = 139, - KeyOfKeyword = 140, - ModuleKeyword = 141, - NamespaceKeyword = 142, - NeverKeyword = 143, - ReadonlyKeyword = 144, - RequireKeyword = 145, - NumberKeyword = 146, - ObjectKeyword = 147, - SetKeyword = 148, - StringKeyword = 149, - SymbolKeyword = 150, - TypeKeyword = 151, - UndefinedKeyword = 152, - UniqueKeyword = 153, - UnknownKeyword = 154, - FromKeyword = 155, - GlobalKeyword = 156, - BigIntKeyword = 157, - OverrideKeyword = 158, - OfKeyword = 159, - QualifiedName = 160, - ComputedPropertyName = 161, - TypeParameter = 162, - Parameter = 163, - Decorator = 164, - PropertySignature = 165, - PropertyDeclaration = 166, - MethodSignature = 167, - MethodDeclaration = 168, - ClassStaticBlockDeclaration = 169, - Constructor = 170, - GetAccessor = 171, - SetAccessor = 172, - CallSignature = 173, - ConstructSignature = 174, - IndexSignature = 175, - TypePredicate = 176, - TypeReference = 177, - FunctionType = 178, - ConstructorType = 179, - TypeQuery = 180, - TypeLiteral = 181, - ArrayType = 182, - TupleType = 183, - OptionalType = 184, - RestType = 185, - UnionType = 186, - IntersectionType = 187, - ConditionalType = 188, - InferType = 189, - ParenthesizedType = 190, - ThisType = 191, - TypeOperator = 192, - IndexedAccessType = 193, - MappedType = 194, - LiteralType = 195, - NamedTupleMember = 196, - TemplateLiteralType = 197, - TemplateLiteralTypeSpan = 198, - ImportType = 199, - ObjectBindingPattern = 200, - ArrayBindingPattern = 201, - BindingElement = 202, - ArrayLiteralExpression = 203, - ObjectLiteralExpression = 204, - PropertyAccessExpression = 205, - ElementAccessExpression = 206, - CallExpression = 207, - NewExpression = 208, - TaggedTemplateExpression = 209, - TypeAssertionExpression = 210, - ParenthesizedExpression = 211, - FunctionExpression = 212, - ArrowFunction = 213, - DeleteExpression = 214, - TypeOfExpression = 215, - VoidExpression = 216, - AwaitExpression = 217, - PrefixUnaryExpression = 218, - PostfixUnaryExpression = 219, - BinaryExpression = 220, - ConditionalExpression = 221, - TemplateExpression = 222, - YieldExpression = 223, - SpreadElement = 224, - ClassExpression = 225, - OmittedExpression = 226, - ExpressionWithTypeArguments = 227, - AsExpression = 228, - NonNullExpression = 229, - MetaProperty = 230, - SyntheticExpression = 231, - TemplateSpan = 232, - SemicolonClassElement = 233, - Block = 234, - EmptyStatement = 235, - VariableStatement = 236, - ExpressionStatement = 237, - IfStatement = 238, - DoStatement = 239, - WhileStatement = 240, - ForStatement = 241, - ForInStatement = 242, - ForOfStatement = 243, - ContinueStatement = 244, - BreakStatement = 245, - ReturnStatement = 246, - WithStatement = 247, - SwitchStatement = 248, - LabeledStatement = 249, - ThrowStatement = 250, - TryStatement = 251, - DebuggerStatement = 252, - VariableDeclaration = 253, - VariableDeclarationList = 254, - FunctionDeclaration = 255, - ClassDeclaration = 256, - InterfaceDeclaration = 257, - TypeAliasDeclaration = 258, - EnumDeclaration = 259, - ModuleDeclaration = 260, - ModuleBlock = 261, - CaseBlock = 262, - NamespaceExportDeclaration = 263, - ImportEqualsDeclaration = 264, - ImportDeclaration = 265, - ImportClause = 266, - NamespaceImport = 267, - NamedImports = 268, - ImportSpecifier = 269, - ExportAssignment = 270, - ExportDeclaration = 271, - NamedExports = 272, - NamespaceExport = 273, - ExportSpecifier = 274, - MissingDeclaration = 275, - ExternalModuleReference = 276, - JsxElement = 277, - JsxSelfClosingElement = 278, - JsxOpeningElement = 279, - JsxClosingElement = 280, - JsxFragment = 281, - JsxOpeningFragment = 282, - JsxClosingFragment = 283, - JsxAttribute = 284, - JsxAttributes = 285, - JsxSpreadAttribute = 286, - JsxExpression = 287, - CaseClause = 288, - DefaultClause = 289, - HeritageClause = 290, - CatchClause = 291, - AssertClause = 292, - AssertEntry = 293, - PropertyAssignment = 294, - ShorthandPropertyAssignment = 295, - SpreadAssignment = 296, - EnumMember = 297, - UnparsedPrologue = 298, - UnparsedPrepend = 299, - UnparsedText = 300, - UnparsedInternalText = 301, - UnparsedSyntheticReference = 302, - SourceFile = 303, - Bundle = 304, - UnparsedSource = 305, - InputFiles = 306, - JSDocTypeExpression = 307, - JSDocNameReference = 308, - JSDocMemberName = 309, - JSDocAllType = 310, - JSDocUnknownType = 311, - JSDocNullableType = 312, - JSDocNonNullableType = 313, - JSDocOptionalType = 314, - JSDocFunctionType = 315, - JSDocVariadicType = 316, - JSDocNamepathType = 317, - JSDocComment = 318, - JSDocText = 319, - JSDocTypeLiteral = 320, - JSDocSignature = 321, - JSDocLink = 322, - JSDocLinkCode = 323, - JSDocLinkPlain = 324, - JSDocTag = 325, - JSDocAugmentsTag = 326, - JSDocImplementsTag = 327, - JSDocAuthorTag = 328, - JSDocDeprecatedTag = 329, - JSDocClassTag = 330, - JSDocPublicTag = 331, - JSDocPrivateTag = 332, - JSDocProtectedTag = 333, - JSDocReadonlyTag = 334, - JSDocOverrideTag = 335, - JSDocCallbackTag = 336, - JSDocEnumTag = 337, - JSDocParameterTag = 338, - JSDocReturnTag = 339, - JSDocThisTag = 340, - JSDocTypeTag = 341, - JSDocTemplateTag = 342, - JSDocTypedefTag = 343, - JSDocSeeTag = 344, - JSDocPropertyTag = 345, - SyntaxList = 346, - NotEmittedStatement = 347, - PartiallyEmittedExpression = 348, - CommaListExpression = 349, - MergeDeclarationMarker = 350, - EndOfDeclarationMarker = 351, - SyntheticReferenceExpression = 352, - Count = 353, - FirstAssignment = 63, - LastAssignment = 78, - FirstCompoundAssignment = 64, - LastCompoundAssignment = 78, - FirstReservedWord = 81, - LastReservedWord = 116, - FirstKeyword = 81, - LastKeyword = 159, - FirstFutureReservedWord = 117, - LastFutureReservedWord = 125, - FirstTypeNode = 176, - LastTypeNode = 199, + HashToken = 64, + EqualsToken = 65, + PlusEqualsToken = 66, + MinusEqualsToken = 67, + AsteriskEqualsToken = 68, + AsteriskAsteriskEqualsToken = 69, + SlashEqualsToken = 70, + PercentEqualsToken = 71, + LessThanLessThanEqualsToken = 72, + GreaterThanGreaterThanEqualsToken = 73, + GreaterThanGreaterThanGreaterThanEqualsToken = 74, + AmpersandEqualsToken = 75, + BarEqualsToken = 76, + BarBarEqualsToken = 77, + AmpersandAmpersandEqualsToken = 78, + QuestionQuestionEqualsToken = 79, + CaretEqualsToken = 80, + Identifier = 81, + PrivateIdentifier = 82, + BreakKeyword = 83, + CaseKeyword = 84, + CatchKeyword = 85, + ClassKeyword = 86, + ConstKeyword = 87, + ContinueKeyword = 88, + DebuggerKeyword = 89, + DefaultKeyword = 90, + DeleteKeyword = 91, + DoKeyword = 92, + ElseKeyword = 93, + EnumKeyword = 94, + ExportKeyword = 95, + ExtendsKeyword = 96, + FalseKeyword = 97, + FinallyKeyword = 98, + ForKeyword = 99, + FunctionKeyword = 100, + IfKeyword = 101, + ImportKeyword = 102, + InKeyword = 103, + InstanceOfKeyword = 104, + NewKeyword = 105, + NullKeyword = 106, + ReturnKeyword = 107, + SuperKeyword = 108, + SwitchKeyword = 109, + ThisKeyword = 110, + ThrowKeyword = 111, + TrueKeyword = 112, + TryKeyword = 113, + TypeOfKeyword = 114, + VarKeyword = 115, + VoidKeyword = 116, + WhileKeyword = 117, + WithKeyword = 118, + ImplementsKeyword = 119, + InterfaceKeyword = 120, + LetKeyword = 121, + PackageKeyword = 122, + PrivateKeyword = 123, + ProtectedKeyword = 124, + PublicKeyword = 125, + StaticKeyword = 126, + YieldKeyword = 127, + AbstractKeyword = 128, + AsKeyword = 129, + AssertsKeyword = 130, + AssertKeyword = 131, + AnyKeyword = 132, + AsyncKeyword = 133, + AwaitKeyword = 134, + BooleanKeyword = 135, + ConstructorKeyword = 136, + DeclareKeyword = 137, + GetKeyword = 138, + InferKeyword = 139, + IntrinsicKeyword = 140, + IsKeyword = 141, + KeyOfKeyword = 142, + ModuleKeyword = 143, + NamespaceKeyword = 144, + NeverKeyword = 145, + ReadonlyKeyword = 146, + RequireKeyword = 147, + NumberKeyword = 148, + ObjectKeyword = 149, + SetKeyword = 150, + StringKeyword = 151, + SymbolKeyword = 152, + TypeKeyword = 153, + UndefinedKeyword = 154, + UniqueKeyword = 155, + UnknownKeyword = 156, + FromKeyword = 157, + GlobalKeyword = 158, + BigIntKeyword = 159, + OverrideKeyword = 160, + OfKeyword = 161, + QualifiedName = 162, + ComputedPropertyName = 163, + TypeParameter = 164, + Parameter = 165, + Decorator = 166, + PropertySignature = 167, + PropertyDeclaration = 168, + MethodSignature = 169, + MethodDeclaration = 170, + ClassStaticBlockDeclaration = 171, + Constructor = 172, + GetAccessor = 173, + SetAccessor = 174, + CallSignature = 175, + ConstructSignature = 176, + IndexSignature = 177, + TypePredicate = 178, + TypeReference = 179, + FunctionType = 180, + ConstructorType = 181, + TypeQuery = 182, + TypeLiteral = 183, + ArrayType = 184, + TupleType = 185, + OptionalType = 186, + RestType = 187, + UnionType = 188, + IntersectionType = 189, + ConditionalType = 190, + InferType = 191, + ParenthesizedType = 192, + ThisType = 193, + TypeOperator = 194, + IndexedAccessType = 195, + MappedType = 196, + LiteralType = 197, + NamedTupleMember = 198, + TemplateLiteralType = 199, + TemplateLiteralTypeSpan = 200, + ImportType = 201, + ObjectBindingPattern = 202, + ArrayBindingPattern = 203, + BindingElement = 204, + ArrayLiteralExpression = 205, + ObjectLiteralExpression = 206, + PropertyAccessExpression = 207, + ElementAccessExpression = 208, + CallExpression = 209, + PipelineHackExpression = 210, + PipelineApplicationExpression = 211, + NewExpression = 212, + TaggedTemplateExpression = 213, + TypeAssertionExpression = 214, + ParenthesizedExpression = 215, + FunctionExpression = 216, + ArrowFunction = 217, + DeleteExpression = 218, + TypeOfExpression = 219, + VoidExpression = 220, + AwaitExpression = 221, + PrefixUnaryExpression = 222, + PostfixUnaryExpression = 223, + BinaryExpression = 224, + ConditionalExpression = 225, + TemplateExpression = 226, + YieldExpression = 227, + SpreadElement = 228, + ClassExpression = 229, + OmittedExpression = 230, + ExpressionWithTypeArguments = 231, + AsExpression = 232, + NonNullExpression = 233, + MetaProperty = 234, + SyntheticExpression = 235, + TemplateSpan = 236, + SemicolonClassElement = 237, + Block = 238, + EmptyStatement = 239, + VariableStatement = 240, + ExpressionStatement = 241, + IfStatement = 242, + DoStatement = 243, + WhileStatement = 244, + ForStatement = 245, + ForInStatement = 246, + ForOfStatement = 247, + ContinueStatement = 248, + BreakStatement = 249, + ReturnStatement = 250, + WithStatement = 251, + SwitchStatement = 252, + LabeledStatement = 253, + ThrowStatement = 254, + TryStatement = 255, + DebuggerStatement = 256, + VariableDeclaration = 257, + VariableDeclarationList = 258, + FunctionDeclaration = 259, + ClassDeclaration = 260, + InterfaceDeclaration = 261, + TypeAliasDeclaration = 262, + EnumDeclaration = 263, + ModuleDeclaration = 264, + ModuleBlock = 265, + CaseBlock = 266, + NamespaceExportDeclaration = 267, + ImportEqualsDeclaration = 268, + ImportDeclaration = 269, + ImportClause = 270, + NamespaceImport = 271, + NamedImports = 272, + ImportSpecifier = 273, + ExportAssignment = 274, + ExportDeclaration = 275, + NamedExports = 276, + NamespaceExport = 277, + ExportSpecifier = 278, + MissingDeclaration = 279, + ExternalModuleReference = 280, + JsxElement = 281, + JsxSelfClosingElement = 282, + JsxOpeningElement = 283, + JsxClosingElement = 284, + JsxFragment = 285, + JsxOpeningFragment = 286, + JsxClosingFragment = 287, + JsxAttribute = 288, + JsxAttributes = 289, + JsxSpreadAttribute = 290, + JsxExpression = 291, + CaseClause = 292, + DefaultClause = 293, + HeritageClause = 294, + CatchClause = 295, + AssertClause = 296, + AssertEntry = 297, + PropertyAssignment = 298, + ShorthandPropertyAssignment = 299, + SpreadAssignment = 300, + EnumMember = 301, + UnparsedPrologue = 302, + UnparsedPrepend = 303, + UnparsedText = 304, + UnparsedInternalText = 305, + UnparsedSyntheticReference = 306, + SourceFile = 307, + Bundle = 308, + UnparsedSource = 309, + InputFiles = 310, + JSDocTypeExpression = 311, + JSDocNameReference = 312, + JSDocMemberName = 313, + JSDocAllType = 314, + JSDocUnknownType = 315, + JSDocNullableType = 316, + JSDocNonNullableType = 317, + JSDocOptionalType = 318, + JSDocFunctionType = 319, + JSDocVariadicType = 320, + JSDocNamepathType = 321, + JSDocComment = 322, + JSDocText = 323, + JSDocTypeLiteral = 324, + JSDocSignature = 325, + JSDocLink = 326, + JSDocLinkCode = 327, + JSDocLinkPlain = 328, + JSDocTag = 329, + JSDocAugmentsTag = 330, + JSDocImplementsTag = 331, + JSDocAuthorTag = 332, + JSDocDeprecatedTag = 333, + JSDocClassTag = 334, + JSDocPublicTag = 335, + JSDocPrivateTag = 336, + JSDocProtectedTag = 337, + JSDocReadonlyTag = 338, + JSDocOverrideTag = 339, + JSDocCallbackTag = 340, + JSDocEnumTag = 341, + JSDocParameterTag = 342, + JSDocReturnTag = 343, + JSDocThisTag = 344, + JSDocTypeTag = 345, + JSDocTemplateTag = 346, + JSDocTypedefTag = 347, + JSDocSeeTag = 348, + JSDocPropertyTag = 349, + SyntaxList = 350, + NotEmittedStatement = 351, + PartiallyEmittedExpression = 352, + CommaListExpression = 353, + MergeDeclarationMarker = 354, + EndOfDeclarationMarker = 355, + SyntheticReferenceExpression = 356, + Count = 357, + FirstAssignment = 65, + LastAssignment = 80, + FirstCompoundAssignment = 66, + LastCompoundAssignment = 80, + FirstReservedWord = 83, + LastReservedWord = 118, + FirstKeyword = 83, + LastKeyword = 161, + FirstFutureReservedWord = 119, + LastFutureReservedWord = 127, + FirstTypeNode = 178, + LastTypeNode = 201, FirstPunctuation = 18, - LastPunctuation = 78, + LastPunctuation = 80, FirstToken = 0, - LastToken = 159, + LastToken = 161, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -482,19 +486,19 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 78, - FirstStatement = 236, - LastStatement = 252, - FirstNode = 160, - FirstJSDocNode = 307, - LastJSDocNode = 345, - FirstJSDocTagNode = 325, - LastJSDocTagNode = 345, + LastBinaryOperator = 80, + FirstStatement = 240, + LastStatement = 256, + FirstNode = 162, + FirstJSDocNode = 311, + LastJSDocNode = 349, + FirstJSDocTagNode = 329, + LastJSDocTagNode = 349, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.BarGreaterThanToken | SyntaxKind.BarGreaterThanGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.HashToken; export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; @@ -596,7 +600,10 @@ declare namespace ts { export type EqualsGreaterThanToken = PunctuationToken; export type PlusToken = PunctuationToken; export type MinusToken = PunctuationToken; + export type BarGreaterThanToken = PunctuationToken; + export type BarGreaterThanGreaterThanToken = PunctuationToken; export type QuestionDotToken = PunctuationToken; + export type HashToken = PunctuationToken; export interface KeywordToken extends Token { } export type AssertsKeyword = KeywordToken; @@ -1096,9 +1103,10 @@ declare namespace ts { export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type PipelineOperatorOrHigher = LogicalOperatorOrHigher | SyntaxKind.BarGreaterThanToken | SyntaxKind.BarGreaterThanGreaterThanToken; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.QuestionQuestionEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | PipelineOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type LogicalOrCoalescingAssignmentOperator = SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionEqualsToken; export type BinaryOperatorToken = Token; @@ -1275,6 +1283,20 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly arguments: NodeArray; } + export interface PipelineHackExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineHackExpression; + readonly expression: Expression; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + readonly dummyDeclaration: Declaration; + } + export interface PipelineApplicationExpression extends LeftHandSideExpression, Declaration { + readonly kind: SyntaxKind.PipelineApplicationExpression; + readonly expression: Expression; + readonly typeArguments?: NodeArray; + readonly argument: Expression; + readonly barGreaterThanToken: BarGreaterThanToken; + } export interface CallChain extends CallExpression { _optionalChainBrand: any; } @@ -1302,7 +1324,7 @@ declare namespace ts { readonly typeArguments?: NodeArray; readonly template: TemplateLiteral; } - export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | PipelineApplicationExpression | JsxOpeningLikeElement; export interface AsExpression extends Expression { readonly kind: SyntaxKind.AsExpression; readonly expression: Expression; @@ -2536,7 +2558,8 @@ declare namespace ts { Resolving = "__resolving__", ExportEquals = "export=", Default = "default", - This = "this" + This = "this", + HackPipelineReference = "#" } /** * This represents a string whose leading underscore have been escaped by adding extra leading underscores. @@ -3507,6 +3530,10 @@ declare namespace ts { updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain; createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty; updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty; + createPipelineHackExpression(expression: Expression, argument: Expression): PipelineHackExpression; + updatePipelineHackExpression(node: PipelineHackExpression, expression: Expression, argument: Expression): PipelineHackExpression; + createPipelineApplicationExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; + updatePipelineApplicationExpression(node: PipelineApplicationExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argument: Expression): PipelineApplicationExpression; createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; createSemicolonClassElement(): SemicolonClassElement; @@ -4380,6 +4407,8 @@ declare namespace ts { function isConstTypeReference(node: Node): boolean; function skipPartiallyEmittedExpressions(node: Expression): Expression; function skipPartiallyEmittedExpressions(node: Node): Node; + function isPipelineHackExpression(node: Node): node is PipelineHackExpression; + function isPipelineApplicationExpression(node: Node): node is PipelineApplicationExpression; function isNonNullChain(node: Node): node is NonNullChain; function isBreakOrContinueStatement(node: Node): node is BreakOrContinueStatement; function isNamedExportBindings(node: Node): node is NamedExportBindings; diff --git a/tests/baselines/reference/pipeline.js b/tests/baselines/reference/pipeline.js new file mode 100644 index 0000000000000..83503dcca820a --- /dev/null +++ b/tests/baselines/reference/pipeline.js @@ -0,0 +1,40 @@ +//// [pipeline.ts] +const uried = 'Foobar' |> encodeURI(#); + +const squared = 3 |> ((n: number) => n * n)(#); + +const makeAdder = (addNum: number) => + (addTo: number) => addTo + addNum; + +const added = 2 |> (1 |> makeAdder(#)); + +const zeroOrOne = () => (Math.floor(Math.random() * 2)) % 2; +const ternaryFunctions = 11 |> + (zeroOrOne() === 0 + ? (x: number) => x - 1 + : (x: number) => x + 1 + )(#); + +('a' as string) |> console.log(#); +'b' as string |> console.log(#); +const c = 'c' |> ((s: string) => s)(#); + +const nestedPipelines = 1 |> (# |> #); + + +//// [pipeline.js] +var pipelineHackPlaceholder_1, pipelineHackPlaceholder_2, pipelineHackPlaceholder_3, pipelineHackPlaceholder_4, pipelineHackPlaceholder_5, pipelineHackPlaceholder_6, pipelineHackPlaceholder_7, pipelineHackPlaceholder_8, pipelineHackPlaceholder_9, pipelineHackPlaceholder_10; +var uried = (pipelineHackPlaceholder_1 = 'Foobar', encodeURI(pipelineHackPlaceholder_1)); +var squared = ((pipelineHackPlaceholder_2 = 3, (function (n) { return n * n; })(pipelineHackPlaceholder_2))); +var makeAdder = function (addNum) { + return function (addTo) { return addTo + addNum; }; +}; +var added = (pipelineHackPlaceholder_3 = 2, ((pipelineHackPlaceholder_4 = 1, makeAdder(pipelineHackPlaceholder_4)))); +var zeroOrOne = function () { return (Math.floor(Math.random() * 2)) % 2; }; +var ternaryFunctions = ((pipelineHackPlaceholder_5 = 11, (zeroOrOne() === 0 + ? function (x) { return x - 1; } + : function (x) { return x + 1; })(pipelineHackPlaceholder_5))); +(pipelineHackPlaceholder_6 = 'a', console.log(pipelineHackPlaceholder_6)); +(pipelineHackPlaceholder_7 = 'b', console.log(pipelineHackPlaceholder_7)); +var c = ((pipelineHackPlaceholder_8 = 'c', (function (s) { return s; })(pipelineHackPlaceholder_8))); +var nestedPipelines = (pipelineHackPlaceholder_9 = 1, ((pipelineHackPlaceholder_10 = pipelineHackPlaceholder_9, pipelineHackPlaceholder_10))); diff --git a/tests/baselines/reference/pipeline.symbols b/tests/baselines/reference/pipeline.symbols new file mode 100644 index 0000000000000..3142f96c2a996 --- /dev/null +++ b/tests/baselines/reference/pipeline.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/pipeline/pipeline.ts === +const uried = 'Foobar' |> encodeURI(#); +>uried : Symbol(uried, Decl(pipeline.ts, 0, 5)) +>encodeURI : Symbol(encodeURI, Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipeline.ts, 0, 13)) + +const squared = 3 |> ((n: number) => n * n)(#); +>squared : Symbol(squared, Decl(pipeline.ts, 2, 5)) +>n : Symbol(n, Decl(pipeline.ts, 2, 23)) +>n : Symbol(n, Decl(pipeline.ts, 2, 23)) +>n : Symbol(n, Decl(pipeline.ts, 2, 23)) +># : Symbol(#, Decl(pipeline.ts, 2, 15)) + +const makeAdder = (addNum: number) => +>makeAdder : Symbol(makeAdder, Decl(pipeline.ts, 4, 5)) +>addNum : Symbol(addNum, Decl(pipeline.ts, 4, 19)) + + (addTo: number) => addTo + addNum; +>addTo : Symbol(addTo, Decl(pipeline.ts, 5, 2)) +>addTo : Symbol(addTo, Decl(pipeline.ts, 5, 2)) +>addNum : Symbol(addNum, Decl(pipeline.ts, 4, 19)) + +const added = 2 |> (1 |> makeAdder(#)); +>added : Symbol(added, Decl(pipeline.ts, 7, 5)) +>makeAdder : Symbol(makeAdder, Decl(pipeline.ts, 4, 5)) +># : Symbol(#, Decl(pipeline.ts, 7, 20)) + +const zeroOrOne = () => (Math.floor(Math.random() * 2)) % 2; +>zeroOrOne : Symbol(zeroOrOne, Decl(pipeline.ts, 9, 5)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + +const ternaryFunctions = 11 |> +>ternaryFunctions : Symbol(ternaryFunctions, Decl(pipeline.ts, 10, 5)) + + (zeroOrOne() === 0 +>zeroOrOne : Symbol(zeroOrOne, Decl(pipeline.ts, 9, 5)) + + ? (x: number) => x - 1 +>x : Symbol(x, Decl(pipeline.ts, 12, 5)) +>x : Symbol(x, Decl(pipeline.ts, 12, 5)) + + : (x: number) => x + 1 +>x : Symbol(x, Decl(pipeline.ts, 13, 5)) +>x : Symbol(x, Decl(pipeline.ts, 13, 5)) + + )(#); +># : Symbol(#, Decl(pipeline.ts, 10, 24)) + +('a' as string) |> console.log(#); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +># : Symbol(#, Decl(pipeline.ts, 14, 6)) + +'b' as string |> console.log(#); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +># : Symbol(#, Decl(pipeline.ts, 16, 34)) + +const c = 'c' |> ((s: string) => s)(#); +>c : Symbol(c, Decl(pipeline.ts, 18, 5)) +>s : Symbol(s, Decl(pipeline.ts, 18, 19)) +>s : Symbol(s, Decl(pipeline.ts, 18, 19)) +># : Symbol(#, Decl(pipeline.ts, 18, 9)) + +const nestedPipelines = 1 |> (# |> #); +>nestedPipelines : Symbol(nestedPipelines, Decl(pipeline.ts, 20, 5)) +># : Symbol(#, Decl(pipeline.ts, 20, 30)) +># : Symbol(#, Decl(pipeline.ts, 20, 30)) + diff --git a/tests/baselines/reference/pipeline.types b/tests/baselines/reference/pipeline.types new file mode 100644 index 0000000000000..cfaf6ce1af98d --- /dev/null +++ b/tests/baselines/reference/pipeline.types @@ -0,0 +1,134 @@ +=== tests/cases/conformance/pipeline/pipeline.ts === +const uried = 'Foobar' |> encodeURI(#); +>uried : string +>'Foobar' |> encodeURI(#) : string +>'Foobar' : "Foobar" +>encodeURI(#) : string +>encodeURI : (uri: string) => string +># : "Foobar" + +const squared = 3 |> ((n: number) => n * n)(#); +>squared : number +>3 |> ((n: number) => n * n)(#) : number +>3 : 3 +>((n: number) => n * n)(#) : number +>((n: number) => n * n) : (n: number) => number +>(n: number) => n * n : (n: number) => number +>n : number +>n * n : number +>n : number +>n : number +># : 3 + +const makeAdder = (addNum: number) => +>makeAdder : (addNum: number) => (addTo: number) => number +>(addNum: number) => (addTo: number) => addTo + addNum : (addNum: number) => (addTo: number) => number +>addNum : number + + (addTo: number) => addTo + addNum; +>(addTo: number) => addTo + addNum : (addTo: number) => number +>addTo : number +>addTo + addNum : number +>addTo : number +>addNum : number + +const added = 2 |> (1 |> makeAdder(#)); +>added : (addTo: number) => number +>2 |> (1 |> makeAdder(#)) : (addTo: number) => number +>2 : 2 +>(1 |> makeAdder(#)) : (addTo: number) => number +>1 |> makeAdder(#) : (addTo: number) => number +>1 : 1 +>makeAdder(#) : (addTo: number) => number +>makeAdder : (addNum: number) => (addTo: number) => number +># : 1 + +const zeroOrOne = () => (Math.floor(Math.random() * 2)) % 2; +>zeroOrOne : () => number +>() => (Math.floor(Math.random() * 2)) % 2 : () => number +>(Math.floor(Math.random() * 2)) % 2 : number +>(Math.floor(Math.random() * 2)) : number +>Math.floor(Math.random() * 2) : number +>Math.floor : (x: number) => number +>Math : Math +>floor : (x: number) => number +>Math.random() * 2 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>2 : 2 +>2 : 2 + +const ternaryFunctions = 11 |> +>ternaryFunctions : number +>11 |> (zeroOrOne() === 0 ? (x: number) => x - 1 : (x: number) => x + 1 )(#) : number +>11 : 11 + + (zeroOrOne() === 0 +>(zeroOrOne() === 0 ? (x: number) => x - 1 : (x: number) => x + 1 )(#) : number +>(zeroOrOne() === 0 ? (x: number) => x - 1 : (x: number) => x + 1 ) : (x: number) => number +>zeroOrOne() === 0 ? (x: number) => x - 1 : (x: number) => x + 1 : (x: number) => number +>zeroOrOne() === 0 : boolean +>zeroOrOne() : number +>zeroOrOne : () => number +>0 : 0 + + ? (x: number) => x - 1 +>(x: number) => x - 1 : (x: number) => number +>x : number +>x - 1 : number +>x : number +>1 : 1 + + : (x: number) => x + 1 +>(x: number) => x + 1 : (x: number) => number +>x : number +>x + 1 : number +>x : number +>1 : 1 + + )(#); +># : 11 + +('a' as string) |> console.log(#); +>('a' as string) |> console.log(#) : void +>('a' as string) : string +>'a' as string : string +>'a' : "a" +>console.log(#) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +># : string + +'b' as string |> console.log(#); +>'b' as string |> console.log(#) : void +>'b' as string : string +>'b' : "b" +>console.log(#) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +># : string + +const c = 'c' |> ((s: string) => s)(#); +>c : string +>'c' |> ((s: string) => s)(#) : string +>'c' : "c" +>((s: string) => s)(#) : string +>((s: string) => s) : (s: string) => string +>(s: string) => s : (s: string) => string +>s : string +>s : string +># : "c" + +const nestedPipelines = 1 |> (# |> #); +>nestedPipelines : any +>1 |> (# |> #) : any +>1 : 1 +>(# |> #) : any +># |> # : any +># : any +># : any + diff --git a/tests/baselines/reference/pipelineDecoratorFunction.js b/tests/baselines/reference/pipelineDecoratorFunction.js new file mode 100644 index 0000000000000..d1dac703e17fe --- /dev/null +++ b/tests/baselines/reference/pipelineDecoratorFunction.js @@ -0,0 +1,58 @@ +//// [pipelineDecoratorFunction.ts] +function greets (person) { + person.greet = () => `${person.name} says hi!`; + return person; +} +function ages (age) { + return function (person) { + person.age = age; + person.birthday = function () { person.age += 1; }; + return person; + } +} +function programs (favLang) { + return function (person) { + person.favLang = favLang; + person.program = () => `${person.name} starts to write ${person.favLang}!`; + return person; + } +} + +function Person (name, age) { + return { name: name } |> greets(#) |> ages(age)(#); +} +function Programmer (name, age) { + return { name: name } + |> greets(#) + |> ages(age) + |> programs('javascript')(#); +} + + +//// [pipelineDecoratorFunction.js] +function greets(person) { + person.greet = function () { return "".concat(person.name, " says hi!"); }; + return person; +} +function ages(age) { + return function (person) { + person.age = age; + person.birthday = function () { person.age += 1; }; + return person; + }; +} +function programs(favLang) { + return function (person) { + person.favLang = favLang; + person.program = function () { return "".concat(person.name, " starts to write ").concat(person.favLang, "!"); }; + return person; + }; +} +function Person(name, age) { + var pipelineHackPlaceholder_1, pipelineHackPlaceholder_2; + return (pipelineHackPlaceholder_1 = (pipelineHackPlaceholder_2 = { name: name }, greets(pipelineHackPlaceholder_2)), ages(age)(pipelineHackPlaceholder_1)); +} +function Programmer(name, age) { + var pipelineHackPlaceholder_3, pipelineHackPlaceholder_4, pipelineHackPlaceholder_5; + return (pipelineHackPlaceholder_3 = (pipelineHackPlaceholder_4 = (pipelineHackPlaceholder_5 = { name: name }, greets(pipelineHackPlaceholder_5)), ages(age)), programs('javascript')(pipelineHackPlaceholder_3)); +} diff --git a/tests/baselines/reference/pipelineDecoratorFunction.symbols b/tests/baselines/reference/pipelineDecoratorFunction.symbols new file mode 100644 index 0000000000000..c57d9f19becf0 --- /dev/null +++ b/tests/baselines/reference/pipelineDecoratorFunction.symbols @@ -0,0 +1,88 @@ +=== tests/cases/conformance/pipeline/pipelineDecoratorFunction.ts === +function greets (person) { +>greets : Symbol(greets, Decl(pipelineDecoratorFunction.ts, 0, 0)) +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 0, 17)) + + person.greet = () => `${person.name} says hi!`; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 0, 17)) +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 0, 17)) + + return person; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 0, 17)) +} +function ages (age) { +>ages : Symbol(ages, Decl(pipelineDecoratorFunction.ts, 3, 1)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 4, 15)) + + return function (person) { +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 5, 18)) + + person.age = age; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 5, 18)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 4, 15)) + + person.birthday = function () { person.age += 1; }; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 5, 18)) +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 5, 18)) + + return person; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 5, 18)) + } +} +function programs (favLang) { +>programs : Symbol(programs, Decl(pipelineDecoratorFunction.ts, 10, 1)) +>favLang : Symbol(favLang, Decl(pipelineDecoratorFunction.ts, 11, 19)) + + return function (person) { +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) + + person.favLang = favLang; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) +>favLang : Symbol(favLang, Decl(pipelineDecoratorFunction.ts, 11, 19)) + + person.program = () => `${person.name} starts to write ${person.favLang}!`; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) + + return person; +>person : Symbol(person, Decl(pipelineDecoratorFunction.ts, 12, 18)) + } +} + +function Person (name, age) { +>Person : Symbol(Person, Decl(pipelineDecoratorFunction.ts, 17, 1)) +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 19, 17)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 19, 22)) + + return { name: name } |> greets(#) |> ages(age)(#); +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 20, 9)) +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 19, 17)) +>greets : Symbol(greets, Decl(pipelineDecoratorFunction.ts, 0, 0)) +># : Symbol(#, Decl(pipelineDecoratorFunction.ts, 20, 7)) +>ages : Symbol(ages, Decl(pipelineDecoratorFunction.ts, 3, 1)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 19, 22)) +># : Symbol(#, Decl(pipelineDecoratorFunction.ts, 20, 7)) +} +function Programmer (name, age) { +>Programmer : Symbol(Programmer, Decl(pipelineDecoratorFunction.ts, 21, 1)) +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 22, 21)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 22, 26)) + + return { name: name } +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 23, 9)) +>name : Symbol(name, Decl(pipelineDecoratorFunction.ts, 22, 21)) + + |> greets(#) +>greets : Symbol(greets, Decl(pipelineDecoratorFunction.ts, 0, 0)) +># : Symbol(#, Decl(pipelineDecoratorFunction.ts, 23, 7)) + + |> ages(age) +>ages : Symbol(ages, Decl(pipelineDecoratorFunction.ts, 3, 1)) +>age : Symbol(age, Decl(pipelineDecoratorFunction.ts, 22, 26)) + + |> programs('javascript')(#); +>programs : Symbol(programs, Decl(pipelineDecoratorFunction.ts, 10, 1)) +># : Symbol(#, Decl(pipelineDecoratorFunction.ts, 23, 7)) +} + diff --git a/tests/baselines/reference/pipelineDecoratorFunction.types b/tests/baselines/reference/pipelineDecoratorFunction.types new file mode 100644 index 0000000000000..f35bd1bcff881 --- /dev/null +++ b/tests/baselines/reference/pipelineDecoratorFunction.types @@ -0,0 +1,135 @@ +=== tests/cases/conformance/pipeline/pipelineDecoratorFunction.ts === +function greets (person) { +>greets : (person: any) => any +>person : any + + person.greet = () => `${person.name} says hi!`; +>person.greet = () => `${person.name} says hi!` : () => string +>person.greet : any +>person : any +>greet : any +>() => `${person.name} says hi!` : () => string +>`${person.name} says hi!` : string +>person.name : any +>person : any +>name : any + + return person; +>person : any +} +function ages (age) { +>ages : (age: any) => (person: any) => any +>age : any + + return function (person) { +>function (person) { person.age = age; person.birthday = function () { person.age += 1; }; return person; } : (person: any) => any +>person : any + + person.age = age; +>person.age = age : any +>person.age : any +>person : any +>age : any +>age : any + + person.birthday = function () { person.age += 1; }; +>person.birthday = function () { person.age += 1; } : () => void +>person.birthday : any +>person : any +>birthday : any +>function () { person.age += 1; } : () => void +>person.age += 1 : any +>person.age : any +>person : any +>age : any +>1 : 1 + + return person; +>person : any + } +} +function programs (favLang) { +>programs : (favLang: any) => (person: any) => any +>favLang : any + + return function (person) { +>function (person) { person.favLang = favLang; person.program = () => `${person.name} starts to write ${person.favLang}!`; return person; } : (person: any) => any +>person : any + + person.favLang = favLang; +>person.favLang = favLang : any +>person.favLang : any +>person : any +>favLang : any +>favLang : any + + person.program = () => `${person.name} starts to write ${person.favLang}!`; +>person.program = () => `${person.name} starts to write ${person.favLang}!` : () => string +>person.program : any +>person : any +>program : any +>() => `${person.name} starts to write ${person.favLang}!` : () => string +>`${person.name} starts to write ${person.favLang}!` : string +>person.name : any +>person : any +>name : any +>person.favLang : any +>person : any +>favLang : any + + return person; +>person : any + } +} + +function Person (name, age) { +>Person : (name: any, age: any) => any +>name : any +>age : any + + return { name: name } |> greets(#) |> ages(age)(#); +>{ name: name } |> greets(#) |> ages(age)(#) : any +>{ name: name } |> greets(#) : any +>{ name: name } : { name: any; } +>name : any +>name : any +>greets(#) : any +>greets : (person: any) => any +># : { name: any; } +>ages(age)(#) : any +>ages(age) : (person: any) => any +>ages : (age: any) => (person: any) => any +>age : any +># : any +} +function Programmer (name, age) { +>Programmer : (name: any, age: any) => any +>name : any +>age : any + + return { name: name } +>{ name: name } |> greets(#) |> ages(age) |> programs('javascript')(#) : any +>{ name: name } |> greets(#) |> ages(age) : (person: any) => any +>{ name: name } |> greets(#) : any +>{ name: name } : { name: any; } +>name : any +>name : any + + |> greets(#) +>greets(#) : any +>greets : (person: any) => any +># : { name: any; } + + |> ages(age) +>ages(age) : (person: any) => any +>ages : (age: any) => (person: any) => any +>age : any + + |> programs('javascript')(#); +>programs('javascript')(#) : any +>programs('javascript') : (person: any) => any +>programs : (favLang: any) => (person: any) => any +>'javascript' : "javascript" +># : (person: any) => any +} + diff --git a/tests/baselines/reference/pipelineHackAndPApp.js b/tests/baselines/reference/pipelineHackAndPApp.js new file mode 100644 index 0000000000000..1322deae6e7e6 --- /dev/null +++ b/tests/baselines/reference/pipelineHackAndPApp.js @@ -0,0 +1,13 @@ +//// [pipelineHackAndPApp.ts] +(1.1 + 2.6) |> (# |>> Math.round); + +(3) |> (3 |>> ((o) => Math.pow(o, #))); + +5.7 |>> ((a) => a |> # * 100); + + +//// [pipelineHackAndPApp.js] +var pipelineHackPlaceholder_1, pipelineHackPlaceholder_2; +(pipelineHackPlaceholder_1 = (1.1 + 2.6), (Math.round(pipelineHackPlaceholder_1))); +(pipelineHackPlaceholder_2 = (3), ((function (o) { return Math.pow(o, pipelineHackPlaceholder_2); })(3))); +(function (a) { var pipelineHackPlaceholder_3; return (pipelineHackPlaceholder_3 = a, pipelineHackPlaceholder_3 * 100); })(5.7); diff --git a/tests/baselines/reference/pipelineHackAndPApp.symbols b/tests/baselines/reference/pipelineHackAndPApp.symbols new file mode 100644 index 0000000000000..554677291aa9c --- /dev/null +++ b/tests/baselines/reference/pipelineHackAndPApp.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/pipeline/pipelineHackAndPApp.ts === +(1.1 + 2.6) |> (# |>> Math.round); +># : Symbol(#, Decl(pipelineHackAndPApp.ts, 0, 0)) +>Math.round : Symbol(Math.round, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>round : Symbol(Math.round, Decl(lib.es5.d.ts, --, --)) + +(3) |> (3 |>> ((o) => Math.pow(o, #))); +>o : Symbol(o, Decl(pipelineHackAndPApp.ts, 2, 16)) +>Math.pow : Symbol(Math.pow, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>pow : Symbol(Math.pow, Decl(lib.es5.d.ts, --, --)) +>o : Symbol(o, Decl(pipelineHackAndPApp.ts, 2, 16)) +># : Symbol(#, Decl(pipelineHackAndPApp.ts, 0, 34)) + +5.7 |>> ((a) => a |> # * 100); +>a : Symbol(a, Decl(pipelineHackAndPApp.ts, 4, 10)) +>a : Symbol(a, Decl(pipelineHackAndPApp.ts, 4, 10)) +># : Symbol(#, Decl(pipelineHackAndPApp.ts, 4, 15)) + diff --git a/tests/baselines/reference/pipelineHackAndPApp.types b/tests/baselines/reference/pipelineHackAndPApp.types new file mode 100644 index 0000000000000..de65119bfffd1 --- /dev/null +++ b/tests/baselines/reference/pipelineHackAndPApp.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/pipeline/pipelineHackAndPApp.ts === +(1.1 + 2.6) |> (# |>> Math.round); +>(1.1 + 2.6) |> (# |>> Math.round) : number +>(1.1 + 2.6) : number +>1.1 + 2.6 : number +>1.1 : 1.1 +>2.6 : 2.6 +>(# |>> Math.round) : number +># |>> Math.round : number +># : number +>Math.round : (x: number) => number +>Math : Math +>round : (x: number) => number + +(3) |> (3 |>> ((o) => Math.pow(o, #))); +>(3) |> (3 |>> ((o) => Math.pow(o, #))) : number +>(3) : 3 +>3 : 3 +>(3 |>> ((o) => Math.pow(o, #))) : number +>3 |>> ((o) => Math.pow(o, #)) : number +>3 : 3 +>((o) => Math.pow(o, #)) : (o: any) => number +>(o) => Math.pow(o, #) : (o: any) => number +>o : any +>Math.pow(o, #) : number +>Math.pow : (x: number, y: number) => number +>Math : Math +>pow : (x: number, y: number) => number +>o : any +># : 3 + +5.7 |>> ((a) => a |> # * 100); +>5.7 |>> ((a) => a |> # * 100) : number +>5.7 : 5.7 +>((a) => a |> # * 100) : (a: any) => number +>(a) => a |> # * 100 : (a: any) => number +>a : any +>a |> # * 100 : number +>a : any +># * 100 : number +># : any +>100 : 100 + diff --git a/tests/baselines/reference/pipelineTopic.js b/tests/baselines/reference/pipelineTopic.js new file mode 100644 index 0000000000000..9cf2bca28cb9b --- /dev/null +++ b/tests/baselines/reference/pipelineTopic.js @@ -0,0 +1,21 @@ +//// [pipelineTopic.ts] +const increment = (a: number) => a + 1; +const add = (a: number, b: number) => a + b; + +const result = ['a','bb','ccc'] + |> #.map(s => s |> #.length) + |> #.map(a => a * 2 ) + |> #.filter(a => a > 5) + |> #.reduce((sum, a) => a+sum, 0) + |> increment(#) + |> add(#, 3) + +const added = 3 |> #+#+#+#+#; + + +//// [pipelineTopic.js] +var pipelineHackPlaceholder_1, pipelineHackPlaceholder_2, pipelineHackPlaceholder_3, pipelineHackPlaceholder_4, pipelineHackPlaceholder_5, pipelineHackPlaceholder_6, pipelineHackPlaceholder_7; +var increment = function (a) { return a + 1; }; +var add = function (a, b) { return a + b; }; +var result = (pipelineHackPlaceholder_1 = (pipelineHackPlaceholder_2 = (pipelineHackPlaceholder_3 = (pipelineHackPlaceholder_4 = (pipelineHackPlaceholder_5 = (pipelineHackPlaceholder_6 = ['a', 'bb', 'ccc'], pipelineHackPlaceholder_6.map(function (s) { var pipelineHackPlaceholder_8; return (pipelineHackPlaceholder_8 = s, pipelineHackPlaceholder_8.length); })), pipelineHackPlaceholder_5.map(function (a) { return a * 2; })), pipelineHackPlaceholder_4.filter(function (a) { return a > 5; })), pipelineHackPlaceholder_3.reduce(function (sum, a) { return a + sum; }, 0)), increment(pipelineHackPlaceholder_2)), add(pipelineHackPlaceholder_1, 3)); +var added = (pipelineHackPlaceholder_7 = 3, pipelineHackPlaceholder_7 + pipelineHackPlaceholder_7 + pipelineHackPlaceholder_7 + pipelineHackPlaceholder_7 + pipelineHackPlaceholder_7); diff --git a/tests/baselines/reference/pipelineTopic.symbols b/tests/baselines/reference/pipelineTopic.symbols new file mode 100644 index 0000000000000..0db236a915983 --- /dev/null +++ b/tests/baselines/reference/pipelineTopic.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/pipeline/pipelineTopic.ts === +const increment = (a: number) => a + 1; +>increment : Symbol(increment, Decl(pipelineTopic.ts, 0, 5)) +>a : Symbol(a, Decl(pipelineTopic.ts, 0, 19)) +>a : Symbol(a, Decl(pipelineTopic.ts, 0, 19)) + +const add = (a: number, b: number) => a + b; +>add : Symbol(add, Decl(pipelineTopic.ts, 1, 5)) +>a : Symbol(a, Decl(pipelineTopic.ts, 1, 13)) +>b : Symbol(b, Decl(pipelineTopic.ts, 1, 23)) +>a : Symbol(a, Decl(pipelineTopic.ts, 1, 13)) +>b : Symbol(b, Decl(pipelineTopic.ts, 1, 23)) + +const result = ['a','bb','ccc'] +>result : Symbol(result, Decl(pipelineTopic.ts, 3, 5)) + + |> #.map(s => s |> #.length) +>#.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(pipelineTopic.ts, 4, 13)) +>s : Symbol(s, Decl(pipelineTopic.ts, 4, 13)) +>#.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipelineTopic.ts, 4, 17)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + |> #.map(a => a * 2 ) +>#.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(pipelineTopic.ts, 5, 13)) +>a : Symbol(a, Decl(pipelineTopic.ts, 5, 13)) + + |> #.filter(a => a > 5) +>#.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(pipelineTopic.ts, 6, 16)) +>a : Symbol(a, Decl(pipelineTopic.ts, 6, 16)) + + |> #.reduce((sum, a) => a+sum, 0) +>#.reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) +>reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>sum : Symbol(sum, Decl(pipelineTopic.ts, 7, 17)) +>a : Symbol(a, Decl(pipelineTopic.ts, 7, 21)) +>a : Symbol(a, Decl(pipelineTopic.ts, 7, 21)) +>sum : Symbol(sum, Decl(pipelineTopic.ts, 7, 17)) + + |> increment(#) +>increment : Symbol(increment, Decl(pipelineTopic.ts, 0, 5)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) + + |> add(#, 3) +>add : Symbol(add, Decl(pipelineTopic.ts, 1, 5)) +># : Symbol(#, Decl(pipelineTopic.ts, 3, 14)) + +const added = 3 |> #+#+#+#+#; +>added : Symbol(added, Decl(pipelineTopic.ts, 11, 5)) +># : Symbol(#, Decl(pipelineTopic.ts, 11, 13)) +># : Symbol(#, Decl(pipelineTopic.ts, 11, 13)) +># : Symbol(#, Decl(pipelineTopic.ts, 11, 13)) +># : Symbol(#, Decl(pipelineTopic.ts, 11, 13)) +># : Symbol(#, Decl(pipelineTopic.ts, 11, 13)) + diff --git a/tests/baselines/reference/pipelineTopic.types b/tests/baselines/reference/pipelineTopic.types new file mode 100644 index 0000000000000..8e6d385feda7c --- /dev/null +++ b/tests/baselines/reference/pipelineTopic.types @@ -0,0 +1,104 @@ +=== tests/cases/conformance/pipeline/pipelineTopic.ts === +const increment = (a: number) => a + 1; +>increment : (a: number) => number +>(a: number) => a + 1 : (a: number) => number +>a : number +>a + 1 : number +>a : number +>1 : 1 + +const add = (a: number, b: number) => a + b; +>add : (a: number, b: number) => number +>(a: number, b: number) => a + b : (a: number, b: number) => number +>a : number +>b : number +>a + b : number +>a : number +>b : number + +const result = ['a','bb','ccc'] +>result : number +>['a','bb','ccc'] |> #.map(s => s |> #.length) |> #.map(a => a * 2 ) |> #.filter(a => a > 5) |> #.reduce((sum, a) => a+sum, 0) |> increment(#) |> add(#, 3) : number +>['a','bb','ccc'] |> #.map(s => s |> #.length) |> #.map(a => a * 2 ) |> #.filter(a => a > 5) |> #.reduce((sum, a) => a+sum, 0) |> increment(#) : number +>['a','bb','ccc'] |> #.map(s => s |> #.length) |> #.map(a => a * 2 ) |> #.filter(a => a > 5) |> #.reduce((sum, a) => a+sum, 0) : number +>['a','bb','ccc'] |> #.map(s => s |> #.length) |> #.map(a => a * 2 ) |> #.filter(a => a > 5) : number[] +>['a','bb','ccc'] |> #.map(s => s |> #.length) |> #.map(a => a * 2 ) : number[] +>['a','bb','ccc'] |> #.map(s => s |> #.length) : number[] +>['a','bb','ccc'] : string[] +>'a' : "a" +>'bb' : "bb" +>'ccc' : "ccc" + + |> #.map(s => s |> #.length) +>#.map(s => s |> #.length) : number[] +>#.map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +># : string[] +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>s => s |> #.length : (s: string) => number +>s : string +>s |> #.length : number +>s : string +>#.length : number +># : string +>length : number + + |> #.map(a => a * 2 ) +>#.map(a => a * 2 ) : number[] +>#.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +># : number[] +>map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] +>a => a * 2 : (a: number) => number +>a : number +>a * 2 : number +>a : number +>2 : 2 + + |> #.filter(a => a > 5) +>#.filter(a => a > 5) : number[] +>#.filter : { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; } +># : number[] +>filter : { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; } +>a => a > 5 : (a: number) => boolean +>a : number +>a > 5 : boolean +>a : number +>5 : 5 + + |> #.reduce((sum, a) => a+sum, 0) +>#.reduce((sum, a) => a+sum, 0) : number +>#.reduce : { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } +># : number[] +>reduce : { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; } +>(sum, a) => a+sum : (sum: number, a: number) => number +>sum : number +>a : number +>a+sum : number +>a : number +>sum : number +>0 : 0 + + |> increment(#) +>increment(#) : number +>increment : (a: number) => number +># : number + + |> add(#, 3) +>add(#, 3) : number +>add : (a: number, b: number) => number +># : number +>3 : 3 + +const added = 3 |> #+#+#+#+#; +>added : number +>3 |> #+#+#+#+# : number +>3 : 3 +>#+#+#+#+# : number +>#+#+#+# : number +>#+#+# : number +>#+# : number +># : 3 +># : 3 +># : 3 +># : 3 +># : 3 + diff --git a/tests/baselines/reference/privateNameHashCharName.errors.txt b/tests/baselines/reference/privateNameHashCharName.errors.txt index 8fdc42b4348ac..ff0f4c9ac52c2 100644 --- a/tests/baselines/reference/privateNameHashCharName.errors.txt +++ b/tests/baselines/reference/privateNameHashCharName.errors.txt @@ -1,22 +1,22 @@ -tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts(1,1): error TS1127: Invalid character. -tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts(4,5): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts(1,1): error TS2304: Cannot find name '#'. tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts(7,14): error TS1127: Invalid character. +tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts(7,14): error TS2339: Property '#' does not exist on type 'C'. ==== tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts (3 errors) ==== # ~ -!!! error TS1127: Invalid character. +!!! error TS2304: Cannot find name '#'. class C { # - ~ -!!! error TS1127: Invalid character. m() { this.# ~ !!! error TS1127: Invalid character. + ~ +!!! error TS2339: Property '#' does not exist on type 'C'. } } \ No newline at end of file diff --git a/tests/baselines/reference/privateNameHashCharName.js b/tests/baselines/reference/privateNameHashCharName.js index fcc0dead80b42..68f015312adc5 100644 --- a/tests/baselines/reference/privateNameHashCharName.js +++ b/tests/baselines/reference/privateNameHashCharName.js @@ -11,19 +11,9 @@ class C { //// [privateNameHashCharName.js] -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -}; -var _C_; #; class C { - constructor() { - _C_.set(this, void 0); - } m() { - __classPrivateFieldGet(this, _C_, "f"); + this.; } } -_C_ = new WeakMap(); diff --git a/tests/baselines/reference/privateNameHashCharName.symbols b/tests/baselines/reference/privateNameHashCharName.symbols index 5cb018c50da0d..ade195f2f3329 100644 --- a/tests/baselines/reference/privateNameHashCharName.symbols +++ b/tests/baselines/reference/privateNameHashCharName.symbols @@ -11,7 +11,6 @@ class C { >m : Symbol(C.m, Decl(privateNameHashCharName.ts, 3, 5)) this.# ->this.# : Symbol(C[#], Decl(privateNameHashCharName.ts, 2, 9)) >this : Symbol(C, Decl(privateNameHashCharName.ts, 0, 1)) } } diff --git a/tests/baselines/reference/privateNameHashCharName.types b/tests/baselines/reference/privateNameHashCharName.types index 520e51ee43495..f321b7bcda4e7 100644 --- a/tests/baselines/reference/privateNameHashCharName.types +++ b/tests/baselines/reference/privateNameHashCharName.types @@ -1,5 +1,6 @@ === tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts === # +># : any class C { >C : C diff --git a/tests/cases/conformance/pipeline/pipeline.ts b/tests/cases/conformance/pipeline/pipeline.ts new file mode 100644 index 0000000000000..a555c12e03033 --- /dev/null +++ b/tests/cases/conformance/pipeline/pipeline.ts @@ -0,0 +1,21 @@ +const uried = 'Foobar' |> encodeURI(#); + +const squared = 3 |> ((n: number) => n * n)(#); + +const makeAdder = (addNum: number) => + (addTo: number) => addTo + addNum; + +const added = 2 |> (1 |> makeAdder(#)); + +const zeroOrOne = () => (Math.floor(Math.random() * 2)) % 2; +const ternaryFunctions = 11 |> + (zeroOrOne() === 0 + ? (x: number) => x - 1 + : (x: number) => x + 1 + )(#); + +('a' as string) |> console.log(#); +'b' as string |> console.log(#); +const c = 'c' |> ((s: string) => s)(#); + +const nestedPipelines = 1 |> (# |> #); diff --git a/tests/cases/conformance/pipeline/pipelineDecoratorFunction.ts b/tests/cases/conformance/pipeline/pipelineDecoratorFunction.ts new file mode 100644 index 0000000000000..62ab101118c84 --- /dev/null +++ b/tests/cases/conformance/pipeline/pipelineDecoratorFunction.ts @@ -0,0 +1,28 @@ +function greets (person) { + person.greet = () => `${person.name} says hi!`; + return person; +} +function ages (age) { + return function (person) { + person.age = age; + person.birthday = function () { person.age += 1; }; + return person; + } +} +function programs (favLang) { + return function (person) { + person.favLang = favLang; + person.program = () => `${person.name} starts to write ${person.favLang}!`; + return person; + } +} + +function Person (name, age) { + return { name: name } |> greets(#) |> ages(age)(#); +} +function Programmer (name, age) { + return { name: name } + |> greets(#) + |> ages(age) + |> programs('javascript')(#); +} diff --git a/tests/cases/conformance/pipeline/pipelineHackAndPApp.ts b/tests/cases/conformance/pipeline/pipelineHackAndPApp.ts new file mode 100644 index 0000000000000..816e0a007a887 --- /dev/null +++ b/tests/cases/conformance/pipeline/pipelineHackAndPApp.ts @@ -0,0 +1,5 @@ +(1.1 + 2.6) |> (# |>> Math.round); + +(3) |> (3 |>> ((o) => Math.pow(o, #))); + +5.7 |>> ((a) => a |> # * 100); diff --git a/tests/cases/conformance/pipeline/pipelineTopic.ts b/tests/cases/conformance/pipeline/pipelineTopic.ts new file mode 100644 index 0000000000000..b3c945a66d6cf --- /dev/null +++ b/tests/cases/conformance/pipeline/pipelineTopic.ts @@ -0,0 +1,12 @@ +const increment = (a: number) => a + 1; +const add = (a: number, b: number) => a + b; + +const result = ['a','bb','ccc'] + |> #.map(s => s |> #.length) + |> #.map(a => a * 2 ) + |> #.filter(a => a > 5) + |> #.reduce((sum, a) => a+sum, 0) + |> increment(#) + |> add(#, 3) + +const added = 3 |> #+#+#+#+#;