From 98f19767d71f3acb149798a191cd05c911f3d9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 21:56:50 +0200 Subject: [PATCH 1/6] Port "add jsx fragments to callLikeExpression" Co-authored-by: Isabel Duan --- internal/ast/utilities.go | 14 +- internal/checker/checker.go | 22 +- internal/checker/jsx.go | 280 ++++++++++++------ internal/checker/types.go | 1 + .../expandoContextualTypes.errors.txt | 28 ++ ...actoryAndJsxFragmentFactoryNull.errors.txt | 10 + ...yAndJsxFragmentFactoryNull.errors.txt.diff | 14 + ...ctReferenceErrors(jsx=preserve).errors.txt | 13 + ...erenceErrors(jsx=preserve).errors.txt.diff | 17 ++ ...ferenceErrors(jsx=react-native).errors.txt | 13 + ...ceErrors(jsx=react-native).errors.txt.diff | 17 ++ ...tFactoryReference(jsx=preserve).errors.txt | 12 + ...oryReference(jsx=preserve).errors.txt.diff | 16 + ...mentFactoryReference(jsx=react).errors.txt | 5 +- ...actoryReference(jsx=react).errors.txt.diff | 21 -- ...FactoryReference(jsx=react-jsx).errors.txt | 5 +- ...ryReference(jsx=react-jsx).errors.txt.diff | 14 +- ...toryReference(jsx=react-jsxdev).errors.txt | 5 +- ...eference(jsx=react-jsxdev).errors.txt.diff | 14 +- ...toryReference(jsx=react-native).errors.txt | 12 + ...eference(jsx=react-native).errors.txt.diff | 16 + .../compiler/jsxFragmentWrongType.errors.txt | 11 +- .../jsxFragmentWrongType.errors.txt.diff | 31 +- ...ExpressionNoTypeAssertionInJsx2.errors.txt | 5 +- ...ExpressionNoTypeAssertionInJsx4.errors.txt | 5 +- ...ssionNoTypeAssertionInJsx4.errors.txt.diff | 24 ++ .../inlineJsxAndJsxFragPragma.errors.txt | 15 +- .../inlineJsxAndJsxFragPragma.errors.txt.diff | 59 ++++ ...gPragmaOverridesCompilerOptions.errors.txt | 49 +++ ...maOverridesCompilerOptions.errors.txt.diff | 53 ++++ ...neJsxFactoryWithFragmentIsError.errors.txt | 5 +- ...FactoryWithFragmentIsError.errors.txt.diff | 23 -- .../intraExpressionInferencesJsx.errors.txt | 115 +++++++ ...traExpressionInferencesJsx.errors.txt.diff | 119 ++++++++ ...formCustomImport(jsx=react-jsx).errors.txt | 5 +- ...ustomImport(jsx=react-jsx).errors.txt.diff | 20 ++ ...mCustomImport(jsx=react-jsxdev).errors.txt | 5 +- ...omImport(jsx=react-jsxdev).errors.txt.diff | 20 ++ ...stomImportPragma(jsx=react-jsx).errors.txt | 5 +- ...mportPragma(jsx=react-jsx).errors.txt.diff | 24 ++ ...mImportPragma(jsx=react-jsxdev).errors.txt | 5 +- ...rtPragma(jsx=react-jsxdev).errors.txt.diff | 24 ++ ...ssionNoTypeAssertionInJsx2.errors.txt.diff | 20 ++ 43 files changed, 1005 insertions(+), 186 deletions(-) create mode 100644 testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 8df59ec51d..6f3ce9ec6b 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -2773,9 +2773,19 @@ func GetLanguageVariant(scriptKind core.ScriptKind) core.LanguageVariant { func IsCallLikeExpression(node *Node) bool { switch node.Kind { - case KindJsxOpeningElement, KindJsxSelfClosingElement, KindCallExpression, KindNewExpression, + case KindJsxOpeningElement, KindJsxSelfClosingElement, KindJsxOpeningFragment, KindCallExpression, KindNewExpression, KindTaggedTemplateExpression, KindDecorator: return true + case KindBinaryExpression: + return node.AsBinaryExpression().OperatorToken.Kind == KindInstanceOfKeyword + } + return false +} + +func IsJsxCallLike(node *Node) bool { + switch node.Kind { + case KindJsxOpeningElement, KindJsxSelfClosingElement, KindJsxOpeningFragment: + return true } return false } @@ -3421,6 +3431,8 @@ func GetInvokedExpression(node *Node) *Node { return node.TagName() case KindBinaryExpression: return node.AsBinaryExpression().Right + case KindJsxOpeningFragment: + return node default: return node.Expression() } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 74fbd0f01a..91a108a8bd 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -701,6 +701,7 @@ type Checker struct { permissiveMapper *TypeMapper emptyObjectType *Type emptyJsxObjectType *Type + emptyFreshJsxObjectType *Type emptyTypeLiteralType *Type unknownEmptyObjectType *Type unknownUnionType *Type @@ -967,6 +968,7 @@ func NewChecker(program Program) *Checker { c.permissiveMapper = newFunctionTypeMapper(c.permissiveMapperWorker) c.emptyObjectType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) c.emptyJsxObjectType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) + c.emptyFreshJsxObjectType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) c.emptyTypeLiteralType = c.newAnonymousType(c.newSymbol(ast.SymbolFlagsTypeLiteral, ast.InternalSymbolNameType), nil, nil, nil, nil) c.unknownEmptyObjectType = c.newAnonymousType(nil /*symbol*/, nil, nil, nil, nil) c.unknownUnionType = c.createUnknownUnionType() @@ -8046,7 +8048,7 @@ func (c *Checker) resolveSignature(node *ast.Node, candidatesOutArray *[]*Signat return c.resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) case ast.KindDecorator: return c.resolveDecorator(node, candidatesOutArray, checkMode) - case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: + case ast.KindJsxOpeningFragment, ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement: return c.resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) case ast.KindBinaryExpression: return c.resolveInstanceofExpression(node, candidatesOutArray, checkMode) @@ -8424,7 +8426,7 @@ func (c *Checker) resolveCall(node *ast.Node, signatures []*Signature, candidate reportErrors := !c.isInferencePartiallyBlocked && candidatesOutArray == nil var s CallState s.node = node - if !isDecorator && !isInstanceof && !isSuperCall(node) { + if !isDecorator && !isInstanceof && !isSuperCall(node) && !ast.IsJsxOpeningFragment(node) { s.typeArguments = node.TypeArguments() // We already perform checking on the type arguments on the class declaration itself. if isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.Expression().Kind != ast.KindSuperKeyword { @@ -8518,7 +8520,7 @@ func (c *Checker) resolveCall(node *ast.Node, signatures []*Signature, candidate if headMessage == nil && isInstanceof { headMessage = diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method } - c.reportCallResolutionErrors(&s, signatures, headMessage) + c.reportCallResolutionErrors(node, &s, signatures, headMessage) } return result } @@ -8700,6 +8702,9 @@ func (c *Checker) getImplementationSignature(signature *Signature) *Signature { } func (c *Checker) hasCorrectArity(node *ast.Node, args []*ast.Node, signature *Signature, signatureHelpTrailingComma bool) bool { + if ast.IsJsxOpeningFragment(node) { + return true + } var argCount int callIsIncomplete := false // In incomplete call we want to be lenient when we have too few arguments @@ -8845,8 +8850,8 @@ func (c *Checker) checkTypeArguments(signature *Signature, typeArgumentNodes []* } func (c *Checker) isSignatureApplicable(node *ast.Node, args []*ast.Node, signature *Signature, relation *Relation, checkMode CheckMode, reportErrors bool, inferenceContext *InferenceContext, diagnosticOutput *[]*ast.Diagnostic) bool { - if ast.IsJsxOpeningLikeElement(node) { - return c.checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, diagnosticOutput) + if ast.IsJsxCallLike(node) { + return c.checkApplicableSignatureForJsxCallLikeElement(node, signature, relation, checkMode, reportErrors, diagnosticOutput) } thisType := c.getThisTypeOfSignature(signature) if thisType != nil && thisType != c.voidType && !(ast.IsNewExpression(node) || ast.IsCallExpression(node) && isSuperProperty(node.Expression())) { @@ -9240,7 +9245,7 @@ func (c *Checker) tryGetRestTypeOfSignature(signature *Signature) *Type { return c.getIndexTypeOfType(restType, c.numberType) } -func (c *Checker) reportCallResolutionErrors(s *CallState, signatures []*Signature, headMessage *diagnostics.Message) { +func (c *Checker) reportCallResolutionErrors(node *ast.Node, s *CallState, signatures []*Signature, headMessage *diagnostics.Message) { switch { case len(s.candidatesForArgumentError) != 0: last := s.candidatesForArgumentError[len(s.candidatesForArgumentError)-1] @@ -9264,7 +9269,7 @@ func (c *Checker) reportCallResolutionErrors(s *CallState, signatures []*Signatu c.diagnostics.Add(c.getArgumentArityError(s.node, []*Signature{s.candidateForArgumentArityError}, s.args, headMessage)) case s.candidateForTypeArgumentError != nil: c.checkTypeArguments(s.candidateForTypeArgumentError, s.node.TypeArguments(), true /*reportErrors*/, headMessage) - default: + case !ast.IsJsxOpeningFragment(node): signaturesWithCorrectTypeArgumentArity := core.Filter(signatures, func(sig *Signature) bool { return c.hasCorrectTypeArgumentArity(sig, s.typeArguments) }) @@ -28199,6 +28204,9 @@ func (c *Checker) getContextualImportAttributeType(node *ast.Node) *Type { // Returns the effective arguments for an expression that works like a function invocation. func (c *Checker) getEffectiveCallArguments(node *ast.Node) []*ast.Node { switch { + case ast.IsJsxOpeningFragment(node): + // This attributes Type does not include a children property yet, the same way a fragment created with does not at this stage + return []*ast.Node{c.createSyntheticExpression(node, c.emptyFreshJsxObjectType, false, nil)} case ast.IsTaggedTemplateExpression(node): template := node.AsTaggedTemplateExpression().Template firstArg := c.createSyntheticExpression(template, c.getGlobalTemplateStringsArrayType(), false, nil) diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 507e5063e4..91cb6dba83 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -61,6 +61,12 @@ var JsxNames = struct { LibraryManagedAttributes: "LibraryManagedAttributes", } +var ReactNames = struct { + Fragment string +}{ + Fragment: "Fragment", +} + func (c *Checker) checkJsxElement(node *ast.Node, checkMode CheckMode) *Type { c.checkNodeDeferred(node) return c.getJsxElementTypeAt(node) @@ -125,9 +131,9 @@ func (c *Checker) checkJsxOpeningLikeElementOrOpeningFragment(node *ast.Node) { } c.checkJsxPreconditions(node) c.markJsxAliasReferenced(node) + sig := c.getResolvedSignature(node, nil, CheckModeNormal) + c.checkDeprecatedSignature(sig, node) if isNodeOpeningLikeElement { - sig := c.getResolvedSignature(node, nil, CheckModeNormal) - c.checkDeprecatedSignature(sig, node) elementTypeConstraint := c.getJsxElementTypeTypeAt(node) if elementTypeConstraint != nil { tagName := node.TagName() @@ -475,19 +481,60 @@ func (c *Checker) getSuggestedSymbolForNonexistentJSXAttribute(name string, cont return c.getSpellingSuggestionForName(name, properties, ast.SymbolFlagsValue) } +func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { + // An opening fragment is required in order for `getJsxNamespace` to give the fragment factory + links := c.sourceFileLinks.Get(ast.GetSourceFileOfNode(node)) + if links.jsxFragmentType != nil { + return links.jsxFragmentType + } + jsxFragmentFactoryName := c.getJsxNamespace(node) + jsxFactorySymbol := c.getJsxNamespaceContainerForImplicitImport(node) + if jsxFactorySymbol == nil { + jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, ast.SymbolFlagsValue, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) + } + if jsxFactorySymbol == nil { + links.jsxFragmentType = c.errorType + return links.jsxFragmentType + } + if jsxFactorySymbol.Name == ReactNames.Fragment { + links.jsxFragmentType = c.getTypeOfSymbol(jsxFactorySymbol) + return links.jsxFragmentType + } + resolvedAlias := jsxFactorySymbol + if jsxFactorySymbol.Flags&ast.SymbolFlagsAlias != 0 { + resolvedAlias = c.resolveAlias(jsxFactorySymbol) + } + if jsxFactorySymbol != nil { + reactExports := c.getExportsOfSymbol(resolvedAlias) + typeSymbol := c.getSymbol(reactExports, ReactNames.Fragment, ast.SymbolFlagsBlockScopedVariable) + if typeSymbol != nil { + links.jsxFragmentType = c.getTypeOfSymbol(typeSymbol) + } else { + links.jsxFragmentType = c.errorType + } + } + return links.jsxFragmentType +} + func (c *Checker) resolveJsxOpeningLikeElement(node *ast.Node, candidatesOutArray *[]*Signature, checkMode CheckMode) *Signature { - if isJsxIntrinsicTagName(node.TagName()) { - result := c.getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) - fakeSignature := c.createSignatureForJSXIntrinsic(node, result) - c.checkTypeAssignableToAndOptionallyElaborate(c.checkExpressionWithContextualType(node.Attributes(), c.getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), nil /*inferenceContext*/, CheckModeNormal), result, node.TagName(), node.Attributes(), nil, nil) - typeArguments := node.TypeArguments() - if len(typeArguments) != 0 { - c.checkSourceElements(typeArguments) - c.diagnostics.Add(ast.NewDiagnostic(ast.GetSourceFileOfNode(node), node.TypeArgumentList().Loc, diagnostics.Expected_0_type_arguments_but_got_1, 0, len(typeArguments))) + isJsxOpenFragment := ast.IsJsxOpeningFragment(node) + var exprTypes *Type + if !isJsxOpenFragment { + if isJsxIntrinsicTagName(node.TagName()) { + result := c.getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) + fakeSignature := c.createSignatureForJSXIntrinsic(node, result) + c.checkTypeAssignableToAndOptionallyElaborate(c.checkExpressionWithContextualType(node.Attributes(), c.getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), nil /*inferenceContext*/, CheckModeNormal), result, node.TagName(), node.Attributes(), nil, nil) + typeArguments := node.TypeArguments() + if len(typeArguments) != 0 { + c.checkSourceElements(typeArguments) + c.diagnostics.Add(ast.NewDiagnostic(ast.GetSourceFileOfNode(node), node.TypeArgumentList().Loc, diagnostics.Expected_0_type_arguments_but_got_1, 0, len(typeArguments))) + } + return fakeSignature } - return fakeSignature + exprTypes = c.checkExpression(node.TagName()) + } else { + exprTypes = c.getJSXFragmentType(node) } - exprTypes := c.checkExpression(node.TagName()) apparentType := c.getApparentType(exprTypes) if c.isErrorType(apparentType) { return c.resolveErrorCall(node) @@ -498,7 +545,11 @@ func (c *Checker) resolveJsxOpeningLikeElement(node *ast.Node, candidatesOutArra } if len(signatures) == 0 { // We found no signatures at all, which is an error - c.error(node.TagName(), diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, scanner.GetTextOfNode(node.TagName())) + if isJsxOpenFragment { + c.error(node, diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, scanner.GetTextOfNode(node)) + } else { + c.error(node.TagName(), diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, scanner.GetTextOfNode(node.TagName())) + } return c.resolveErrorCall(node) } return c.resolveCall(node, signatures, candidatesOutArray, checkMode, SignatureFlagsNone, nil) @@ -508,17 +559,23 @@ func (c *Checker) resolveJsxOpeningLikeElement(node *ast.Node, candidatesOutArra // @param node a JSX opening-like element we are trying to figure its call signature // @param signature a candidate signature we are trying whether it is a call signature // @param relation a relationship to check parameter and argument type -func (c *Checker) checkApplicableSignatureForJsxOpeningLikeElement(node *ast.Node, signature *Signature, relation *Relation, checkMode CheckMode, reportErrors bool, diagnosticOutput *[]*ast.Diagnostic) bool { +func (c *Checker) checkApplicableSignatureForJsxCallLikeElement(node *ast.Node, signature *Signature, relation *Relation, checkMode CheckMode, reportErrors bool, diagnosticOutput *[]*ast.Diagnostic) bool { // Stateless function components can have maximum of three arguments: "props", "context", and "updater". // However "context" and "updater" are implicit and can't be specify by users. Only the first parameter, props, // can be specified by users through attributes property. paramType := c.getEffectiveFirstArgumentForJsxSignature(signature, node) - attributesType := c.checkExpressionWithContextualType(node.Attributes(), paramType, nil /*inferenceContext*/, checkMode) + var attributesType *Type + if ast.IsJsxOpeningFragment(node) { + attributesType = c.createJsxAttributesTypeFromAttributesProperty(node, CheckModeNormal) + } else { + attributesType = c.checkExpressionWithContextualType(node.Attributes(), paramType, nil /*inferenceContext*/, checkMode) + } var checkAttributesType *Type checkTagNameDoesNotExpectTooManyArguments := func() bool { if c.getJsxNamespaceContainerForImplicitImport(node) != nil { return true // factory is implicitly jsx/jsxdev - assume it fits the bill, since we don't strongly look for the jsx/jsxs/jsxDEV factory APIs anywhere else (at least not yet) } + // We assume fragments have the correct arity since the node does not have attributes var tagType *Type if (ast.IsJsxOpeningElement(node) || ast.IsJsxSelfClosingElement(node)) && !(isJsxIntrinsicTagName(node.TagName()) || ast.IsJsxNamespacedName(node.TagName())) { tagType = c.checkExpression(node.TagName()) @@ -580,10 +637,12 @@ func (c *Checker) checkApplicableSignatureForJsxOpeningLikeElement(node *ast.Nod return true // some signature accepts the number of arguments the function component provides } if reportErrors { - diag := NewDiagnosticForNode(node.TagName(), diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, entityNameToString(node.TagName()), absoluteMinArgCount, entityNameToString(factory), maxParamCount) - tagNameSymbol := c.getSymbolAtLocation(node.TagName(), false) + tagName := node.TagName() + // We will not report errors in this function for fragments, since we do not check them in this function + diag := NewDiagnosticForNode(tagName, diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, entityNameToString(tagName), absoluteMinArgCount, entityNameToString(factory), maxParamCount) + tagNameSymbol := c.getSymbolAtLocation(tagName, false) if tagNameSymbol != nil && tagNameSymbol.ValueDeclaration != nil { - diag.AddRelatedInfo(NewDiagnosticForNode(tagNameSymbol.ValueDeclaration, diagnostics.X_0_is_declared_here, entityNameToString(node.TagName()))) + diag.AddRelatedInfo(NewDiagnosticForNode(tagNameSymbol.ValueDeclaration, diagnostics.X_0_is_declared_here, entityNameToString(tagName))) } c.reportDiagnostic(diag, diagnosticOutput) } @@ -599,9 +658,17 @@ func (c *Checker) checkApplicableSignatureForJsxOpeningLikeElement(node *ast.Nod } var errorNode *ast.Node if reportErrors { - errorNode = node.TagName() + if ast.IsJsxOpeningFragment(node) { + errorNode = node + } else { + errorNode = node.TagName() + } + } + var attributes *ast.Node + if !ast.IsJsxOpeningFragment(node) { + attributes = node.Attributes() } - return c.checkTypeRelatedToAndOptionallyElaborate(checkAttributesType, paramType, relation, errorNode, node.Attributes(), nil, diagnosticOutput) + return c.checkTypeRelatedToAndOptionallyElaborate(checkAttributesType, paramType, relation, errorNode, attributes, nil, diagnosticOutput) } // Get attributes type of the JSX opening-like element. The result is from resolving "attributes" property of the opening-like element. @@ -612,13 +679,13 @@ func (c *Checker) checkApplicableSignatureForJsxOpeningLikeElement(node *ast.Nod // @remarks Because this function calls getSpreadType, it needs to use the same checks as checkObjectLiteral, // which also calls getSpreadType. func (c *Checker) createJsxAttributesTypeFromAttributesProperty(openingLikeElement *ast.Node, checkMode CheckMode) *Type { - attributes := openingLikeElement.Attributes() - contextualType := c.getContextualType(attributes, ContextFlagsNone) var allAttributesTable ast.SymbolTable if c.strictNullChecks { allAttributesTable = make(ast.SymbolTable) } attributesTable := make(ast.SymbolTable) + var attributesSymbol *ast.Symbol + attributeParent := openingLikeElement spread := c.emptyJsxObjectType var hasSpreadAnyType bool var typeToIntersect *Type @@ -626,96 +693,120 @@ func (c *Checker) createJsxAttributesTypeFromAttributesProperty(openingLikeEleme objectFlags := ObjectFlagsJsxAttributes createJsxAttributesType := func() *Type { objectFlags |= ObjectFlagsFreshLiteral - result := c.newAnonymousType(attributes.Symbol(), attributesTable, nil, nil, nil) + result := c.newAnonymousType(attributesSymbol, attributesTable, nil, nil, nil) result.objectFlags |= objectFlags | ObjectFlagsObjectLiteral | ObjectFlagsContainsObjectOrArrayLiteral return result } jsxChildrenPropertyName := c.getJsxElementChildrenPropertyName(c.getJsxNamespaceAt(openingLikeElement)) - // Create anonymous type from given attributes symbol table. - // @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable - // @param attributesTable a symbol table of attributes property - for _, attributeDecl := range attributes.AsJsxAttributes().Properties.Nodes { - member := attributeDecl.Symbol() - if ast.IsJsxAttribute(attributeDecl) { - exprType := c.checkJsxAttribute(attributeDecl, checkMode) - objectFlags |= exprType.objectFlags & ObjectFlagsPropagatingFlags - attributeSymbol := c.newSymbol(ast.SymbolFlagsProperty|member.Flags, member.Name) - attributeSymbol.Declarations = member.Declarations - attributeSymbol.Parent = member.Parent - if member.ValueDeclaration != nil { - attributeSymbol.ValueDeclaration = member.ValueDeclaration - } - links := c.valueSymbolLinks.Get(attributeSymbol) - links.resolvedType = exprType - links.target = member - attributesTable[attributeSymbol.Name] = attributeSymbol - if allAttributesTable != nil { - allAttributesTable[attributeSymbol.Name] = attributeSymbol - } - if attributeDecl.Name().Text() == jsxChildrenPropertyName { - explicitlySpecifyChildrenAttribute = true - } - if contextualType != nil { - prop := c.getPropertyOfType(contextualType, member.Name) - if prop != nil && prop.Declarations != nil && c.isDeprecatedSymbol(prop) && ast.IsIdentifier(attributeDecl.Name()) { - c.addDeprecatedSuggestion(attributeDecl.Name(), prop.Declarations, attributeDecl.Name().Text()) + isJsxOpenFragment := ast.IsJsxOpeningFragment(openingLikeElement) + if !isJsxOpenFragment { + attributes := openingLikeElement.Attributes() + attributesSymbol = attributes.Symbol() + attributeParent = attributes + contextualType := c.getContextualType(attributes, ContextFlagsNone) + // Create anonymous type from given attributes symbol table. + // @param symbol a symbol of JsxAttributes containing attributes corresponding to attributesTable + // @param attributesTable a symbol table of attributes property + for _, attributeDecl := range attributes.AsJsxAttributes().Properties.Nodes { + member := attributeDecl.Symbol() + if ast.IsJsxAttribute(attributeDecl) { + exprType := c.checkJsxAttribute(attributeDecl, checkMode) + objectFlags |= exprType.objectFlags & ObjectFlagsPropagatingFlags + attributeSymbol := c.newSymbol(ast.SymbolFlagsProperty|member.Flags, member.Name) + attributeSymbol.Declarations = member.Declarations + attributeSymbol.Parent = member.Parent + if member.ValueDeclaration != nil { + attributeSymbol.ValueDeclaration = member.ValueDeclaration } - } - if contextualType != nil && checkMode&CheckModeInferential != 0 && checkMode&CheckModeSkipContextSensitive == 0 && c.isContextSensitive(attributeDecl) { - inferenceContext := c.getInferenceContext(attributes) - // Debug.assert(inferenceContext) - // In CheckMode.Inferential we should always have an inference context - inferenceNode := attributeDecl.Initializer().Expression() - c.addIntraExpressionInferenceSite(inferenceContext, inferenceNode, exprType) - } - } else { - // Debug.assert(attributeDecl.Kind == ast.KindJsxSpreadAttribute) - if len(attributesTable) != 0 { - spread = c.getSpreadType(spread, createJsxAttributesType(), attributes.Symbol(), objectFlags, false /*readonly*/) - attributesTable = make(ast.SymbolTable) - } - exprType := c.getReducedType(c.checkExpressionEx(attributeDecl.Expression(), checkMode&CheckModeInferential)) - if IsTypeAny(exprType) { - hasSpreadAnyType = true - } - if c.isValidSpreadType(exprType) { - spread = c.getSpreadType(spread, exprType, attributes.Symbol(), objectFlags, false /*readonly*/) + links := c.valueSymbolLinks.Get(attributeSymbol) + links.resolvedType = exprType + links.target = member + attributesTable[attributeSymbol.Name] = attributeSymbol if allAttributesTable != nil { - c.checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl) + allAttributesTable[attributeSymbol.Name] = attributeSymbol + } + if attributeDecl.Name().Text() == jsxChildrenPropertyName { + explicitlySpecifyChildrenAttribute = true + } + if contextualType != nil { + prop := c.getPropertyOfType(contextualType, member.Name) + if prop != nil && prop.Declarations != nil && c.isDeprecatedSymbol(prop) && ast.IsIdentifier(attributeDecl.Name()) { + c.addDeprecatedSuggestion(attributeDecl.Name(), prop.Declarations, attributeDecl.Name().Text()) + } + } + if contextualType != nil && checkMode&CheckModeInferential != 0 && checkMode&CheckModeSkipContextSensitive == 0 && c.isContextSensitive(attributeDecl) { + inferenceContext := c.getInferenceContext(attributes) + // Debug.assert(inferenceContext) + // In CheckMode.Inferential we should always have an inference context + inferenceNode := attributeDecl.Initializer().Expression() + c.addIntraExpressionInferenceSite(inferenceContext, inferenceNode, exprType) } } else { - c.error(attributeDecl.Expression(), diagnostics.Spread_types_may_only_be_created_from_object_types) - if typeToIntersect != nil { - typeToIntersect = c.getIntersectionType([]*Type{typeToIntersect, exprType}) + // Debug.assert(attributeDecl.Kind == ast.KindJsxSpreadAttribute) + if len(attributesTable) != 0 { + spread = c.getSpreadType(spread, createJsxAttributesType(), attributesSymbol, objectFlags, false /*readonly*/) + attributesTable = make(ast.SymbolTable) + } + exprType := c.getReducedType(c.checkExpressionEx(attributeDecl.Expression(), checkMode&CheckModeInferential)) + if IsTypeAny(exprType) { + hasSpreadAnyType = true + } + if c.isValidSpreadType(exprType) { + spread = c.getSpreadType(spread, exprType, attributesSymbol, objectFlags, false /*readonly*/) + if allAttributesTable != nil { + c.checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl) + } } else { - typeToIntersect = exprType + c.error(attributeDecl.Expression(), diagnostics.Spread_types_may_only_be_created_from_object_types) + if typeToIntersect != nil { + typeToIntersect = c.getIntersectionType([]*Type{typeToIntersect, exprType}) + } else { + typeToIntersect = exprType + } } } } - } - if !hasSpreadAnyType { - if len(attributesTable) != 0 { - spread = c.getSpreadType(spread, createJsxAttributesType(), attributes.Symbol(), objectFlags, false /*readonly*/) + if !hasSpreadAnyType { + if len(attributesTable) != 0 { + spread = c.getSpreadType(spread, createJsxAttributesType(), attributesSymbol, objectFlags, false /*readonly*/) + } } } - // Handle children attribute - var parent *ast.Node - if ast.IsJsxElement(openingLikeElement.Parent) { - parent = openingLikeElement.Parent + parentHasSemanticJsxChildren := func(openingLikeElement *ast.Node) bool { + // Handle children attribute + parent := openingLikeElement.Parent + if parent == nil { + return false + } + var children []*ast.Node + + switch { + case ast.IsJsxElement(parent): + // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement + if parent.AsJsxElement().OpeningElement == openingLikeElement { + children = parent.AsJsxElement().Children.Nodes + } + case ast.IsJsxFragment(parent): + if parent.AsJsxFragment().OpeningFragment == openingLikeElement { + children = parent.AsJsxFragment().Children.Nodes + } + } + return len(getSemanticJsxChildren(children)) != 0 } - // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement - if parent != nil && parent.AsJsxElement().OpeningElement == openingLikeElement && len(getSemanticJsxChildren(parent.AsJsxElement().Children.Nodes)) != 0 { - var childTypes []*Type = c.checkJsxChildren(parent, checkMode) + if parentHasSemanticJsxChildren(openingLikeElement) { + var childTypes []*Type = c.checkJsxChildren(openingLikeElement.Parent, checkMode) if !hasSpreadAnyType && jsxChildrenPropertyName != ast.InternalSymbolNameMissing && jsxChildrenPropertyName != "" { // Error if there is a attribute named "children" explicitly specified and children element. // This is because children element will overwrite the value from attributes. // Note: we will not warn "children" attribute overwritten if "children" attribute is specified in object spread. if explicitlySpecifyChildrenAttribute { - c.error(attributes, diagnostics.X_0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName) + c.error(attributeParent, diagnostics.X_0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName) } var childrenContextualType *Type - if contextualType := c.getApparentTypeOfContextualType(openingLikeElement.Attributes(), ContextFlagsNone); contextualType != nil { - childrenContextualType = c.getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName) + if ast.IsJsxOpeningElement(openingLikeElement) { + if contextualType := c.getApparentTypeOfContextualType(openingLikeElement.Attributes(), ContextFlagsNone); contextualType != nil { + childrenContextualType = c.getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName) + } } // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process childrenPropSymbol := c.newSymbol(ast.SymbolFlagsProperty, jsxChildrenPropertyName) @@ -730,11 +821,11 @@ func (c *Checker) createJsxAttributesTypeFromAttributesProperty(openingLikeEleme } // Fake up a property declaration for the children childrenPropSymbol.ValueDeclaration = c.factory.NewPropertySignatureDeclaration(nil, c.factory.NewIdentifier(jsxChildrenPropertyName), nil /*postfixToken*/, nil /*type*/, nil /*initializer*/) - childrenPropSymbol.ValueDeclaration.Parent = attributes + childrenPropSymbol.ValueDeclaration.Parent = attributeParent childrenPropSymbol.ValueDeclaration.AsPropertySignatureDeclaration().Symbol = childrenPropSymbol childPropMap := make(ast.SymbolTable) childPropMap[jsxChildrenPropertyName] = childrenPropSymbol - spread = c.getSpreadType(spread, c.newAnonymousType(attributes.Symbol(), childPropMap, nil, nil, nil), attributes.Symbol(), objectFlags, false /*readonly*/) + spread = c.getSpreadType(spread, c.newAnonymousType(attributesSymbol, childPropMap, nil, nil, nil), attributesSymbol, objectFlags, false /*readonly*/) } } if hasSpreadAnyType { @@ -822,7 +913,7 @@ func (c *Checker) getUninstantiatedJsxSignaturesOfType(elementType *Type, caller } func (c *Checker) getEffectiveFirstArgumentForJsxSignature(signature *Signature, node *ast.Node) *Type { - if c.getJsxReferenceKind(node) != JsxReferenceKindComponent { + if ast.IsJsxOpeningFragment(node) || c.getJsxReferenceKind(node) != JsxReferenceKindComponent { return c.getJsxPropsTypeFromCallSignature(signature, node) } return c.getJsxPropsTypeFromClassType(signature, node) @@ -1007,6 +1098,9 @@ func (c *Checker) getNameFromJsxElementAttributesContainer(nameOfAttribPropConta } func (c *Checker) getStaticTypeOfReferencedJsxConstructor(context *ast.Node) *Type { + if ast.IsJsxOpeningFragment(context) { + return c.getJSXFragmentType(context) + } if isJsxIntrinsicTagName(context.TagName()) { result := c.getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context) fakeSignature := c.createSignatureForJSXIntrinsic(context, result) diff --git a/internal/checker/types.go b/internal/checker/types.go index 95e19ea247..ffda84eecc 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -394,6 +394,7 @@ type SourceFileLinks struct { localJsxFragmentNamespace string localJsxFactory *ast.EntityName localJsxFragmentFactory *ast.EntityName + jsxFragmentType *Type } // Signature specific links diff --git a/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt b/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt new file mode 100644 index 0000000000..057d139771 --- /dev/null +++ b/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt @@ -0,0 +1,28 @@ +expandoContextualTypes.tsx(20,12): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + +==== expandoContextualTypes.tsx (1 errors) ==== + // https://github.com/microsoft/typescript-go/issues/921 + + /// + + import type { ComponentType } from "react"; + + export type Page

> = ComponentType

& { + getLayout?: (component: JSX.Element) => JSX.Element; + } + + export const FooPage: Page = () => { + return ( +

+

Foo

+
+ ) + }; + + FooPage.getLayout = () => { + return <> + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt new file mode 100644 index 0000000000..df7d2e819b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt @@ -0,0 +1,10 @@ +jsxFactoryAndJsxFragmentFactoryNull.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + +==== jsxFactoryAndJsxFragmentFactoryNull.tsx (1 errors) ==== + declare var h: any; + + <>; + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + <>1<>2.12.2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff new file mode 100644 index 0000000000..0ebefe1eb4 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff @@ -0,0 +1,14 @@ +--- old.jsxFactoryAndJsxFragmentFactoryNull.errors.txt ++++ new.jsxFactoryAndJsxFragmentFactoryNull.errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsxFactoryAndJsxFragmentFactoryNull.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++ ++ ++==== jsxFactoryAndJsxFragmentFactoryNull.tsx (1 errors) ==== ++ declare var h: any; ++ ++ <>; ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++ <>1<>2.12.2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt new file mode 100644 index 0000000000..bcca5aebff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt @@ -0,0 +1,13 @@ +jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. + + +==== jsxFragReactReferenceErrors.tsx (1 errors) ==== + /// + /// + export function Component(){ + + return <> + ~~ +!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff new file mode 100644 index 0000000000..19fc1a48be --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsxFragReactReferenceErrors(jsx=preserve).errors.txt ++++ new.jsxFragReactReferenceErrors(jsx=preserve).errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. ++ ++ ++==== jsxFragReactReferenceErrors.tsx (1 errors) ==== ++ /// ++ /// ++ export function Component(){ ++ ++ return <> ++ ~~ ++!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. ++ ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt new file mode 100644 index 0000000000..bcca5aebff --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt @@ -0,0 +1,13 @@ +jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. + + +==== jsxFragReactReferenceErrors.tsx (1 errors) ==== + /// + /// + export function Component(){ + + return <> + ~~ +!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff new file mode 100644 index 0000000000..f0d70c08d7 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff @@ -0,0 +1,17 @@ +--- old.jsxFragReactReferenceErrors(jsx=react-native).errors.txt ++++ new.jsxFragReactReferenceErrors(jsx=react-native).errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. ++ ++ ++==== jsxFragReactReferenceErrors.tsx (1 errors) ==== ++ /// ++ /// ++ export function Component(){ ++ ++ return <> ++ ~~ ++!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. ++ ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt new file mode 100644 index 0000000000..f212c72357 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt @@ -0,0 +1,12 @@ +jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + +==== jsxFragmentFactoryReference.tsx (1 errors) ==== + export class LoggedOut { + content = () => ( + <> + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ) + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff new file mode 100644 index 0000000000..b8ebc99ec0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsxFragmentFactoryReference(jsx=preserve).errors.txt ++++ new.jsxFragmentFactoryReference(jsx=preserve).errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxFragmentFactoryReference.tsx (1 errors) ==== ++ export class LoggedOut { ++ content = () => ( ++ <> ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ) ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt index 9abda8ead5..a32738b88c 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt @@ -1,12 +1,15 @@ jsxFragmentFactoryReference.tsx(3,9): error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. +jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxFragmentFactoryReference.tsx (1 errors) ==== +==== jsxFragmentFactoryReference.tsx (2 errors) ==== export class LoggedOut { content = () => ( <> ~~ !!! error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt.diff deleted file mode 100644 index 7e353d0d72..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react).errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.jsxFragmentFactoryReference(jsx=react).errors.txt -+++ new.jsxFragmentFactoryReference(jsx=react).errors.txt -@@= skipped -0, +0 lines =@@ - jsxFragmentFactoryReference.tsx(3,9): error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. --jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -- -- --==== jsxFragmentFactoryReference.tsx (2 errors) ==== -+ -+ -+==== jsxFragmentFactoryReference.tsx (1 errors) ==== - export class LoggedOut { - content = () => ( - <> - ~~ - !!! error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. -- ~~ --!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt index 453fbd038e..c8caaefa36 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt @@ -1,12 +1,15 @@ jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxFragmentFactoryReference.tsx (1 errors) ==== +==== jsxFragmentFactoryReference.tsx (2 errors) ==== export class LoggedOut { content = () => ( <> ~~ !!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff index c2e0779654..3d0c1638be 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff @@ -2,16 +2,22 @@ +++ new.jsxFragmentFactoryReference(jsx=react-jsx).errors.txt @@= skipped -0, +0 lines =@@ -jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +- +- +-==== jsxFragmentFactoryReference.tsx (1 errors) ==== +jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - - - ==== jsxFragmentFactoryReference.tsx (1 errors) ==== -@@= skipped -5, +5 lines =@@ ++jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxFragmentFactoryReference.tsx (2 errors) ==== + export class LoggedOut { content = () => ( <> ~~ -!!! error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +!!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt index 7529f71c4d..16bb6f5a54 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt @@ -1,12 +1,15 @@ jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxFragmentFactoryReference.tsx (1 errors) ==== +==== jsxFragmentFactoryReference.tsx (2 errors) ==== export class LoggedOut { content = () => ( <> ~~ !!! error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff index cd429f045a..c136dcf226 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff @@ -2,16 +2,22 @@ +++ new.jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt @@= skipped -0, +0 lines =@@ -jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +- +- +-==== jsxFragmentFactoryReference.tsx (1 errors) ==== +jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - - - ==== jsxFragmentFactoryReference.tsx (1 errors) ==== -@@= skipped -5, +5 lines =@@ ++jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxFragmentFactoryReference.tsx (2 errors) ==== + export class LoggedOut { content = () => ( <> ~~ -!!! error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +!!! error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt new file mode 100644 index 0000000000..f212c72357 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt @@ -0,0 +1,12 @@ +jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + +==== jsxFragmentFactoryReference.tsx (1 errors) ==== + export class LoggedOut { + content = () => ( + <> + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ) + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff new file mode 100644 index 0000000000..83d930af26 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff @@ -0,0 +1,16 @@ +--- old.jsxFragmentFactoryReference(jsx=react-native).errors.txt ++++ new.jsxFragmentFactoryReference(jsx=react-native).errors.txt +@@= skipped -0, +0 lines =@@ +- ++jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxFragmentFactoryReference.tsx (1 errors) ==== ++ export class LoggedOut { ++ content = () => ( ++ <> ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ) ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt index a13bc939c5..6af267ee06 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt @@ -1,14 +1,23 @@ +a.tsx(6,28): error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. + Types of property 'children' are incompatible. + Type '() => string' is not assignable to type 'ReactNode'. + Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. a.tsx(7,47): error TS2322: Type '() => string' is not assignable to type 'ReactNode'. Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. -==== a.tsx (1 errors) ==== +==== a.tsx (2 errors) ==== /// /// const test = () => "asd"; const jsxWithJsxFragment = <>{test}; + ~~ +!!! error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. +!!! error TS2322: Types of property 'children' are incompatible. +!!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'. +!!! error TS2322: Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. const jsxWithReactFragment = {test}; ~~~~ !!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'. diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt.diff index 132d1c970f..af9c9d5f71 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentWrongType.errors.txt.diff @@ -1,27 +1,20 @@ --- old.jsxFragmentWrongType.errors.txt +++ new.jsxFragmentWrongType.errors.txt @@= skipped -0, +0 lines =@@ --a.tsx(6,28): error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. -- Types of property 'children' are incompatible. -- Type '() => string' is not assignable to type 'ReactNode'. + a.tsx(6,28): error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. + Types of property 'children' are incompatible. + Type '() => string' is not assignable to type 'ReactNode'. ++ Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. a.tsx(7,47): error TS2322: Type '() => string' is not assignable to type 'ReactNode'. -- -- --==== a.tsx (2 errors) ==== + Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. -+ -+ -+==== a.tsx (1 errors) ==== - /// - /// - - const test = () => "asd"; - - const jsxWithJsxFragment = <>{test}; -- ~~ --!!! error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. --!!! error TS2322: Types of property 'children' are incompatible. --!!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'. + + + ==== a.tsx (2 errors) ==== +@@= skipped -14, +16 lines =@@ + !!! error TS2322: Type '{ children: () => string; }' is not assignable to type '{ children?: ReactNode; }'. + !!! error TS2322: Types of property 'children' are incompatible. + !!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'. ++!!! error TS2322: Type '() => string' is not assignable to type 'ReactElement> | ReactFragment | ReactPortal'. const jsxWithReactFragment = {test}; ~~~~ !!! error TS2322: Type '() => string' is not assignable to type 'ReactNode'. diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt index 69e07e5236..b4fb215aae 100644 --- a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt @@ -1,14 +1,17 @@ index.js(2,12): error TS17014: JSX fragment has no corresponding closing tag. +index.js(2,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. index.js(2,13): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. index.js(3,1): error TS1005: ' x; ~~~ !!! error TS17014: JSX fragment has no corresponding closing tag. ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ~~ !!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt index 2c20091271..4038850823 100644 --- a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt @@ -1,11 +1,12 @@ index.tsx(3,14): error TS17008: JSX element 'number' has no corresponding closing tag. +index.tsx(4,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. index.tsx(4,13): error TS17014: JSX fragment has no corresponding closing tag. index.tsx(5,14): error TS1003: Identifier expected. index.tsx(5,18): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? index.tsx(6,1): error TS1005: ' x; @@ -13,6 +14,8 @@ index.tsx(6,1): error TS1005: ' x; ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ~~ !!! error TS17014: JSX fragment has no corresponding closing tag. const c = + <1234> x; ~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff new file mode 100644 index 0000000000..febd94f31f --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff @@ -0,0 +1,24 @@ +--- old.parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt ++++ new.parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt +@@= skipped -0, +0 lines =@@ + index.tsx(3,14): error TS17008: JSX element 'number' has no corresponding closing tag. ++index.tsx(4,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + index.tsx(4,13): error TS17014: JSX fragment has no corresponding closing tag. + index.tsx(5,14): error TS1003: Identifier expected. + index.tsx(5,18): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? + index.tsx(6,1): error TS1005: ' x; + ~~~~~~ + !!! error TS17008: JSX element 'number' has no corresponding closing tag. + const b = + <> x; ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ~~ + !!! error TS17014: JSX fragment has no corresponding closing tag. + const c = + <1234> x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt index 7867b75bdd..6dd5e9c145 100644 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt @@ -1,6 +1,9 @@ preacty-no-fragment.tsx(5,12): error TS6133: 'Fragment' is declared but its value is never read. preacty-only-fragment-no-jsx.tsx(6,1): error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. +snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. +snabbdomy-only-fragment.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. +snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== renderer.d.ts (0 errors) ==== @@ -23,11 +26,13 @@ snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'js import {h, Fragment} from "./renderer"; <>
-==== snabbdomy.tsx (0 errors) ==== +==== snabbdomy.tsx (1 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {jsx} from "./renderer"; <> + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-only-fragment.tsx (0 errors) ==== /** @@ -37,11 +42,13 @@ snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'js import {h, Fragment} from "./renderer"; <> -==== snabbdomy-only-fragment.tsx (0 errors) ==== +==== snabbdomy-only-fragment.tsx (1 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {jsx} from "./renderer"; <> + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-only-fragment-no-jsx.tsx (1 errors) ==== /** @@ -53,13 +60,15 @@ snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'js ~~ !!! error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. -==== snabbdomy-only-fragment-no-jsx.tsx (1 errors) ==== +==== snabbdomy-only-fragment-no-jsx.tsx (2 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {} from "./renderer"; <> ~~ !!! error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-no-fragment.tsx (1 errors) ==== /** diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff new file mode 100644 index 0000000000..f533e50f56 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff @@ -0,0 +1,59 @@ +--- old.inlineJsxAndJsxFragPragma.errors.txt ++++ new.inlineJsxAndJsxFragPragma.errors.txt +@@= skipped -0, +0 lines =@@ + preacty-no-fragment.tsx(5,12): error TS6133: 'Fragment' is declared but its value is never read. + preacty-only-fragment-no-jsx.tsx(6,1): error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. + snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. ++snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++snabbdomy-only-fragment.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + + ==== renderer.d.ts (0 errors) ==== +@@= skipped -22, +25 lines =@@ + import {h, Fragment} from "./renderer"; + <>
+ +-==== snabbdomy.tsx (0 errors) ==== ++==== snabbdomy.tsx (1 errors) ==== + /* @jsx jsx */ + /* @jsxfrag null */ + import {jsx} from "./renderer"; + <> ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + ==== preacty-only-fragment.tsx (0 errors) ==== + /** +@@= skipped -14, +16 lines =@@ + import {h, Fragment} from "./renderer"; + <> + +-==== snabbdomy-only-fragment.tsx (0 errors) ==== ++==== snabbdomy-only-fragment.tsx (1 errors) ==== + /* @jsx jsx */ + /* @jsxfrag null */ + import {jsx} from "./renderer"; + <> ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + ==== preacty-only-fragment-no-jsx.tsx (1 errors) ==== + /** +@@= skipped -16, +18 lines =@@ + ~~ + !!! error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. + +-==== snabbdomy-only-fragment-no-jsx.tsx (1 errors) ==== ++==== snabbdomy-only-fragment-no-jsx.tsx (2 errors) ==== + /* @jsx jsx */ + /* @jsxfrag null */ + import {} from "./renderer"; + <> + ~~ + !!! error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + ==== preacty-no-fragment.tsx (1 errors) ==== + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt new file mode 100644 index 0000000000..19ba24340e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt @@ -0,0 +1,49 @@ +snabbdomy.tsx(6,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + + +==== react.d.ts (0 errors) ==== + declare global { + namespace JSX { + interface IntrinsicElements { + [e: string]: any; + } + } + } + export function createElement(): void; + export function Fragment(): void; + +==== preact.d.ts (0 errors) ==== + export function h(): void; + export function Frag(): void; + +==== snabbdom.d.ts (0 errors) ==== + export function h(): void; + +==== reacty.tsx (0 errors) ==== + import {createElement, Fragment} from "./react"; + <> + +==== preacty.tsx (0 errors) ==== + /** + * @jsx h + * @jsxFrag Frag + */ + import {h, Frag} from "./preact"; + <>
+ +==== snabbdomy.tsx (1 errors) ==== + /** + * @jsx h + * @jsxfrag null + */ + import {h} from "./snabbdom"; + <>
+ ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. + +==== mix-n-match.tsx (0 errors) ==== + /* @jsx h */ + /* @jsxFrag Fragment */ + import {h} from "./preact"; + import {Fragment} from "./react"; + <> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff new file mode 100644 index 0000000000..17d6d5a746 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff @@ -0,0 +1,53 @@ +--- old.inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt ++++ new.inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt +@@= skipped -0, +0 lines =@@ +- ++snabbdomy.tsx(6,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++ ++ ++==== react.d.ts (0 errors) ==== ++ declare global { ++ namespace JSX { ++ interface IntrinsicElements { ++ [e: string]: any; ++ } ++ } ++ } ++ export function createElement(): void; ++ export function Fragment(): void; ++ ++==== preact.d.ts (0 errors) ==== ++ export function h(): void; ++ export function Frag(): void; ++ ++==== snabbdom.d.ts (0 errors) ==== ++ export function h(): void; ++ ++==== reacty.tsx (0 errors) ==== ++ import {createElement, Fragment} from "./react"; ++ <> ++ ++==== preacty.tsx (0 errors) ==== ++ /** ++ * @jsx h ++ * @jsxFrag Frag ++ */ ++ import {h, Frag} from "./preact"; ++ <>
++ ++==== snabbdomy.tsx (1 errors) ==== ++ /** ++ * @jsx h ++ * @jsxfrag null ++ */ ++ import {h} from "./snabbdom"; ++ <>
++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ++ ++==== mix-n-match.tsx (0 errors) ==== ++ /* @jsx h */ ++ /* @jsxFrag Fragment */ ++ import {h} from "./preact"; ++ import {Fragment} from "./react"; ++ <> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt b/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt index 97f6e43717..5bddd259ed 100644 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt @@ -1,4 +1,5 @@ index.tsx(3,1): error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. +index.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. index.tsx(3,1): error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. reacty.tsx(3,1): error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. @@ -19,11 +20,13 @@ reacty.tsx(3,1): error TS17017: An @jsxFrag pragma is required when using an @js <> ~~~~~~~~~~~~ !!! error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. -==== index.tsx (2 errors) ==== +==== index.tsx (3 errors) ==== /** @jsx dom */ import { dom } from "./renderer"; <> ~~ !!! error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ~~~~~~~~~~~~ !!! error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt.diff deleted file mode 100644 index ef6f24a3a1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxFactoryWithFragmentIsError.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.inlineJsxFactoryWithFragmentIsError.errors.txt -+++ new.inlineJsxFactoryWithFragmentIsError.errors.txt -@@= skipped -0, +0 lines =@@ - index.tsx(3,1): error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. --index.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - index.tsx(3,1): error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. - reacty.tsx(3,1): error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. - -@@= skipped -19, +18 lines =@@ - <> - ~~~~~~~~~~~~ - !!! error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. --==== index.tsx (3 errors) ==== -+==== index.tsx (2 errors) ==== - /** @jsx dom */ - import { dom } from "./renderer"; - <> - ~~ - !!! error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found. -- ~~ --!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ~~~~~~~~~~~~ - !!! error TS17017: An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt new file mode 100644 index 0000000000..890a4fc53f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt @@ -0,0 +1,115 @@ +intraExpressionInferencesJsx.tsx(35,29): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + +==== intraExpressionInferencesJsx.tsx (1 errors) ==== + /// + + // repro from #52798 + + type A = { + a: boolean; + }; + + type B = { + b: string; + }; + + type C = { + c: number; + }; + + type Animations = { + [key: string]: { value: number } & ( + | ({ kind: "a"; func?(): Partial } & A) + | ({ kind: "b"; func?(): Partial } & B) + | ({ kind: "c"; func?(): Partial } & C) + ); + }; + + type StyleParam = Record; + + type AnimatedViewProps = { + style: (animationsValues: StyleParam) => string; + animations: T; + }; + + const Component = ({ + animations, + style, + }: AnimatedViewProps) => <>; + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + { + return ""; + }} + />; + { + return ""; + }} + />; + { + return { + a: true, + }; + }, + }, + }} + style={(anim) => { + return ""; + }} + />; + + // repro from #52786 + + interface Props { + a: (x: string) => T; + b: (arg: T) => void; + } + + function Foo(props: Props) { + return
; + } + + 10} + b={(arg) => { arg.toString(); }} + />; + + 10} + b={(arg) => { arg.toString(); }} + />; + + 10, + b: (arg) => { arg.toString(); }, + }} />; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff new file mode 100644 index 0000000000..9b4f597188 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff @@ -0,0 +1,119 @@ +--- old.intraExpressionInferencesJsx.errors.txt ++++ new.intraExpressionInferencesJsx.errors.txt +@@= skipped -0, +0 lines =@@ +- ++intraExpressionInferencesJsx.tsx(35,29): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== intraExpressionInferencesJsx.tsx (1 errors) ==== ++ /// ++ ++ // repro from #52798 ++ ++ type A = { ++ a: boolean; ++ }; ++ ++ type B = { ++ b: string; ++ }; ++ ++ type C = { ++ c: number; ++ }; ++ ++ type Animations = { ++ [key: string]: { value: number } & ( ++ | ({ kind: "a"; func?(): Partial } & A) ++ | ({ kind: "b"; func?(): Partial } & B) ++ | ({ kind: "c"; func?(): Partial } & C) ++ ); ++ }; ++ ++ type StyleParam = Record; ++ ++ type AnimatedViewProps = { ++ style: (animationsValues: StyleParam) => string; ++ animations: T; ++ }; ++ ++ const Component = ({ ++ animations, ++ style, ++ }: AnimatedViewProps) => <>; ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ { ++ return ""; ++ }} ++ />; ++ { ++ return ""; ++ }} ++ />; ++ { ++ return { ++ a: true, ++ }; ++ }, ++ }, ++ }} ++ style={(anim) => { ++ return ""; ++ }} ++ />; ++ ++ // repro from #52786 ++ ++ interface Props { ++ a: (x: string) => T; ++ b: (arg: T) => void; ++ } ++ ++ function Foo(props: Props) { ++ return
; ++ } ++ ++ 10} ++ b={(arg) => { arg.toString(); }} ++ />; ++ ++ 10} ++ b={(arg) => { arg.toString(); }} ++ />; ++ ++ 10, ++ b: (arg) => { arg.toString(); }, ++ }} />; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt index 248540ed38..2b8fbaf4e4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt @@ -1,11 +1,14 @@ jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== +==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== /// const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff new file mode 100644 index 0000000000..129afb7c02 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt ++++ new.jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt +@@= skipped -0, +0 lines =@@ + jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +- +- +-==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== ++jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== + /// + const a = <> + ~~ + !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. +

+ text +
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt index e66480f8dc..31af5093de 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt @@ -1,11 +1,14 @@ jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== +==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== /// const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff new file mode 100644 index 0000000000..f4a16b80de --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff @@ -0,0 +1,20 @@ +--- old.jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt ++++ new.jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt +@@= skipped -0, +0 lines =@@ + jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +- +- +-==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== ++jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ++ ++ ++==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== + /// + const a = <> + ~~ + !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. +

+ text +
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt index c37e010cab..7155c43a5d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt @@ -1,4 +1,5 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ==== react.tsx (0 errors) ==== @@ -12,12 +13,14 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/js export {}; -==== preact.tsx (1 errors) ==== +==== preact.tsx (2 errors) ==== /// /* @jsxImportSource preact */ const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff new file mode 100644 index 0000000000..43fcd4054d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff @@ -0,0 +1,24 @@ +--- old.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt ++++ new.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt +@@= skipped -0, +0 lines =@@ + preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + + ==== react.tsx (0 errors) ==== +@@= skipped -11, +12 lines =@@ + + + export {}; +-==== preact.tsx (1 errors) ==== ++==== preact.tsx (2 errors) ==== + /// + /* @jsxImportSource preact */ + const a = <> + ~~ + !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. +

+ text +
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt index 79e8e02a87..ad4bb3c20b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt @@ -1,4 +1,5 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. +preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ==== react.tsx (0 errors) ==== @@ -12,12 +13,14 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/js export {}; -==== preact.tsx (1 errors) ==== +==== preact.tsx (2 errors) ==== /// /* @jsxImportSource preact */ const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. + ~~ +!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff new file mode 100644 index 0000000000..50a5d39ea1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff @@ -0,0 +1,24 @@ +--- old.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt ++++ new.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt +@@= skipped -0, +0 lines =@@ + preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + + + ==== react.tsx (0 errors) ==== +@@= skipped -11, +12 lines =@@ + + + export {}; +-==== preact.tsx (1 errors) ==== ++==== preact.tsx (2 errors) ==== + /// + /* @jsxImportSource preact */ + const a = <> + ~~ + !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. +

+ text +
\ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff new file mode 100644 index 0000000000..a3aefeef8d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt ++++ new.parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt +@@= skipped -0, +0 lines =@@ + index.js(2,12): error TS17014: JSX fragment has no corresponding closing tag. ++index.js(2,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + index.js(2,13): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + index.js(3,1): error TS1005: ' x; + ~~~ + !!! error TS17014: JSX fragment has no corresponding closing tag. ++ ~~ ++!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. + ~~ + !!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + \ No newline at end of file From 3862f62954e353c820656ef744a39d9fcb67092b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 22:26:51 +0200 Subject: [PATCH 2/6] Port "fix fragment resolving behavior with `jsx: preserve` and `jsxFragmentFactory: null`" Co-authored-by: Isabel Duan --- internal/checker/checker.go | 16 +++-- internal/checker/jsx.go | 14 ++++- ...actoryAndJsxFragmentFactoryNull.errors.txt | 10 ---- ...yAndJsxFragmentFactoryNull.errors.txt.diff | 14 ----- ...ctReferenceErrors(jsx=preserve).errors.txt | 13 ---- ...erenceErrors(jsx=preserve).errors.txt.diff | 17 ------ .../inlineJsxAndJsxFragPragma.errors.txt | 15 +---- .../inlineJsxAndJsxFragPragma.errors.txt.diff | 59 ------------------- ...gPragmaOverridesCompilerOptions.errors.txt | 49 --------------- ...maOverridesCompilerOptions.errors.txt.diff | 53 ----------------- 10 files changed, 27 insertions(+), 233 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 91a108a8bd..4c1f906884 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -26926,10 +26926,14 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if ast.IsJsxOpeningLikeElement(node) { jsxFactoryLocation = node.TagName() } - // allow null as jsxFragmentFactory + // #38720/60122, allow null as jsxFragmentFactory var jsxFactorySym *ast.Symbol if !(ast.IsJsxOpeningFragment(node) && jsxFactoryNamespace == "null") { - jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, ast.SymbolFlagsValue, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) + flags := ast.SymbolFlagsValue + if c.compilerOptions.Jsx == core.JsxEmitPreserve { + flags &= ^ast.SymbolFlagsEnum + } + jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } if jsxFactorySym != nil { // Mark local symbol as referenced here because it might not have been marked @@ -26940,12 +26944,16 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement c.markAliasSymbolAsReferenced(jsxFactorySym) } } - // For JsxFragment, mark jsx pragma as referenced via resolveName + // if JsxFragment, additionally mark jsx pragma as referenced, since `getJsxNamespace` above would have resolved to only the fragment factory if they are distinct if ast.IsJsxOpeningFragment(node) { file := ast.GetSourceFileOfNode(node) localJsxNamespace := c.getLocalJsxNamespace(file) if localJsxNamespace != "" { - c.resolveName(jsxFactoryLocation, localJsxNamespace, ast.SymbolFlagsValue, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) + flags := ast.SymbolFlagsValue + if c.compilerOptions.Jsx == core.JsxEmitPreserve { + flags &= ^ast.SymbolFlagsEnum + } + c.resolveName(jsxFactoryLocation, localJsxNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } } } diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 91cb6dba83..fc8cc5364b 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -117,7 +117,8 @@ func (c *Checker) checkJsxFragment(node *ast.Node) *Type { c.error(node, message) } c.checkJsxChildren(node, CheckModeNormal) - return c.getJsxElementTypeAt(node) + t := c.getJsxElementTypeAt(node) + return core.IfElse(c.isErrorType(t), c.anyType, t) } func (c *Checker) checkJsxAttributes(node *ast.Node, checkMode CheckMode) *Type { @@ -488,9 +489,18 @@ func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { return links.jsxFragmentType } jsxFragmentFactoryName := c.getJsxNamespace(node) + // #38720/60122, allow null as jsxFragmentFactory + if jsxFragmentFactoryName == "null" { + links.jsxFragmentType = c.anyType + return links.jsxFragmentType + } jsxFactorySymbol := c.getJsxNamespaceContainerForImplicitImport(node) if jsxFactorySymbol == nil { - jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, ast.SymbolFlagsValue, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) + flags := ast.SymbolFlagsValue + if c.compilerOptions.Jsx == core.JsxEmitPreserve { + flags &= ^ast.SymbolFlagsEnum + } + jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, flags, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) } if jsxFactorySymbol == nil { links.jsxFragmentType = c.errorType diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt deleted file mode 100644 index df7d2e819b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -jsxFactoryAndJsxFragmentFactoryNull.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - -==== jsxFactoryAndJsxFragmentFactoryNull.tsx (1 errors) ==== - declare var h: any; - - <>; - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - <>1<>2.12.2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff deleted file mode 100644 index 0ebefe1eb4..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.jsxFactoryAndJsxFragmentFactoryNull.errors.txt -+++ new.jsxFactoryAndJsxFragmentFactoryNull.errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsxFactoryAndJsxFragmentFactoryNull.tsx(3,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+ -+ -+==== jsxFactoryAndJsxFragmentFactoryNull.tsx (1 errors) ==== -+ declare var h: any; -+ -+ <>; -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+ <>1<>2.12.2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt deleted file mode 100644 index bcca5aebff..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. - - -==== jsxFragReactReferenceErrors.tsx (1 errors) ==== - /// - /// - export function Component(){ - - return <> - ~~ -!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff deleted file mode 100644 index 19fc1a48be..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=preserve).errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsxFragReactReferenceErrors(jsx=preserve).errors.txt -+++ new.jsxFragReactReferenceErrors(jsx=preserve).errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. -+ -+ -+==== jsxFragReactReferenceErrors.tsx (1 errors) ==== -+ /// -+ /// -+ export function Component(){ -+ -+ return <> -+ ~~ -+!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. -+ -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt index 6dd5e9c145..7867b75bdd 100644 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt @@ -1,9 +1,6 @@ preacty-no-fragment.tsx(5,12): error TS6133: 'Fragment' is declared but its value is never read. preacty-only-fragment-no-jsx.tsx(6,1): error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. -snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -snabbdomy-only-fragment.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== renderer.d.ts (0 errors) ==== @@ -26,13 +23,11 @@ snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory import {h, Fragment} from "./renderer"; <>
-==== snabbdomy.tsx (1 errors) ==== +==== snabbdomy.tsx (0 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {jsx} from "./renderer"; <> - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-only-fragment.tsx (0 errors) ==== /** @@ -42,13 +37,11 @@ snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory import {h, Fragment} from "./renderer"; <> -==== snabbdomy-only-fragment.tsx (1 errors) ==== +==== snabbdomy-only-fragment.tsx (0 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {jsx} from "./renderer"; <> - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-only-fragment-no-jsx.tsx (1 errors) ==== /** @@ -60,15 +53,13 @@ snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory ~~ !!! error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. -==== snabbdomy-only-fragment-no-jsx.tsx (2 errors) ==== +==== snabbdomy-only-fragment-no-jsx.tsx (1 errors) ==== /* @jsx jsx */ /* @jsxfrag null */ import {} from "./renderer"; <> ~~ !!! error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. ==== preacty-no-fragment.tsx (1 errors) ==== /** diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff deleted file mode 100644 index f533e50f56..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt.diff +++ /dev/null @@ -1,59 +0,0 @@ ---- old.inlineJsxAndJsxFragPragma.errors.txt -+++ new.inlineJsxAndJsxFragPragma.errors.txt -@@= skipped -0, +0 lines =@@ - preacty-no-fragment.tsx(5,12): error TS6133: 'Fragment' is declared but its value is never read. - preacty-only-fragment-no-jsx.tsx(6,1): error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. - snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. -+snabbdomy-only-fragment-no-jsx.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+snabbdomy-only-fragment.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+snabbdomy.tsx(4,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - - ==== renderer.d.ts (0 errors) ==== -@@= skipped -22, +25 lines =@@ - import {h, Fragment} from "./renderer"; - <>
- --==== snabbdomy.tsx (0 errors) ==== -+==== snabbdomy.tsx (1 errors) ==== - /* @jsx jsx */ - /* @jsxfrag null */ - import {jsx} from "./renderer"; - <> -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - ==== preacty-only-fragment.tsx (0 errors) ==== - /** -@@= skipped -14, +16 lines =@@ - import {h, Fragment} from "./renderer"; - <> - --==== snabbdomy-only-fragment.tsx (0 errors) ==== -+==== snabbdomy-only-fragment.tsx (1 errors) ==== - /* @jsx jsx */ - /* @jsxfrag null */ - import {jsx} from "./renderer"; - <> -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - ==== preacty-only-fragment-no-jsx.tsx (1 errors) ==== - /** -@@= skipped -16, +18 lines =@@ - ~~ - !!! error TS2874: This JSX tag requires 'h' to be in scope, but it could not be found. - --==== snabbdomy-only-fragment-no-jsx.tsx (1 errors) ==== -+==== snabbdomy-only-fragment-no-jsx.tsx (2 errors) ==== - /* @jsx jsx */ - /* @jsxfrag null */ - import {} from "./renderer"; - <> - ~~ - !!! error TS2874: This JSX tag requires 'jsx' to be in scope, but it could not be found. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - ==== preacty-no-fragment.tsx (1 errors) ==== - /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt deleted file mode 100644 index 19ba24340e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -snabbdomy.tsx(6,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - - -==== react.d.ts (0 errors) ==== - declare global { - namespace JSX { - interface IntrinsicElements { - [e: string]: any; - } - } - } - export function createElement(): void; - export function Fragment(): void; - -==== preact.d.ts (0 errors) ==== - export function h(): void; - export function Frag(): void; - -==== snabbdom.d.ts (0 errors) ==== - export function h(): void; - -==== reacty.tsx (0 errors) ==== - import {createElement, Fragment} from "./react"; - <> - -==== preacty.tsx (0 errors) ==== - /** - * @jsx h - * @jsxFrag Frag - */ - import {h, Frag} from "./preact"; - <>
- -==== snabbdomy.tsx (1 errors) ==== - /** - * @jsx h - * @jsxfrag null - */ - import {h} from "./snabbdom"; - <>
- ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. - -==== mix-n-match.tsx (0 errors) ==== - /* @jsx h */ - /* @jsxFrag Fragment */ - import {h} from "./preact"; - import {Fragment} from "./react"; - <> \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff deleted file mode 100644 index 17d6d5a746..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt.diff +++ /dev/null @@ -1,53 +0,0 @@ ---- old.inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt -+++ new.inlineJsxAndJsxFragPragmaOverridesCompilerOptions.errors.txt -@@= skipped -0, +0 lines =@@ -- -+snabbdomy.tsx(6,1): error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+ -+ -+==== react.d.ts (0 errors) ==== -+ declare global { -+ namespace JSX { -+ interface IntrinsicElements { -+ [e: string]: any; -+ } -+ } -+ } -+ export function createElement(): void; -+ export function Fragment(): void; -+ -+==== preact.d.ts (0 errors) ==== -+ export function h(): void; -+ export function Frag(): void; -+ -+==== snabbdom.d.ts (0 errors) ==== -+ export function h(): void; -+ -+==== reacty.tsx (0 errors) ==== -+ import {createElement, Fragment} from "./react"; -+ <> -+ -+==== preacty.tsx (0 errors) ==== -+ /** -+ * @jsx h -+ * @jsxFrag Frag -+ */ -+ import {h, Frag} from "./preact"; -+ <>
-+ -+==== snabbdomy.tsx (1 errors) ==== -+ /** -+ * @jsx h -+ * @jsxfrag null -+ */ -+ import {h} from "./snabbdom"; -+ <>
-+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'null' to be in scope, but it could not be found. -+ -+==== mix-n-match.tsx (0 errors) ==== -+ /* @jsx h */ -+ /* @jsxFrag Fragment */ -+ import {h} from "./preact"; -+ import {Fragment} from "./react"; -+ <> \ No newline at end of file From 2953e3b5bfbe7445b00937df0d0d8a5083ee939e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 22:29:29 +0200 Subject: [PATCH 3/6] Port "fix missing react error with fragments in `react-native`" Co-authored-by: Isabel Duan --- internal/checker/checker.go | 4 ++-- internal/checker/jsx.go | 2 +- ...ReferenceErrors(jsx=react-native).errors.txt | 13 ------------- ...enceErrors(jsx=react-native).errors.txt.diff | 17 ----------------- 4 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 4c1f906884..706bfada0e 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -26930,7 +26930,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement var jsxFactorySym *ast.Symbol if !(ast.IsJsxOpeningFragment(node) && jsxFactoryNamespace == "null") { flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve { + if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { flags &= ^ast.SymbolFlagsEnum } jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) @@ -26950,7 +26950,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement localJsxNamespace := c.getLocalJsxNamespace(file) if localJsxNamespace != "" { flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve { + if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { flags &= ^ast.SymbolFlagsEnum } c.resolveName(jsxFactoryLocation, localJsxNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index fc8cc5364b..b62f9079f8 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -497,7 +497,7 @@ func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { jsxFactorySymbol := c.getJsxNamespaceContainerForImplicitImport(node) if jsxFactorySymbol == nil { flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve { + if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { flags &= ^ast.SymbolFlagsEnum } jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, flags, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt deleted file mode 100644 index bcca5aebff..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. - - -==== jsxFragReactReferenceErrors.tsx (1 errors) ==== - /// - /// - export function Component(){ - - return <> - ~~ -!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff deleted file mode 100644 index f0d70c08d7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragReactReferenceErrors(jsx=react-native).errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.jsxFragReactReferenceErrors(jsx=react-native).errors.txt -+++ new.jsxFragReactReferenceErrors(jsx=react-native).errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsxFragReactReferenceErrors.tsx(5,8): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. -+ -+ -+==== jsxFragReactReferenceErrors.tsx (1 errors) ==== -+ /// -+ /// -+ export function Component(){ -+ -+ return <> -+ ~~ -+!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. -+ -+ } \ No newline at end of file From 827255f76d9b95f8b79d7a97e268be89f814a6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 22:38:05 +0200 Subject: [PATCH 4/6] Remove reference not found errors from `jsx: preserve` Co-authored-by: Isabel Duan --- internal/checker/checker.go | 5 +- internal/checker/jsx.go | 6 +- .../expandoContextualTypes.errors.txt | 28 ----- ...tFactoryReference(jsx=preserve).errors.txt | 12 -- ...oryReference(jsx=preserve).errors.txt.diff | 16 --- ...FactoryReference(jsx=react-jsx).errors.txt | 5 +- ...ryReference(jsx=react-jsx).errors.txt.diff | 14 +-- ...toryReference(jsx=react-jsxdev).errors.txt | 5 +- ...eference(jsx=react-jsxdev).errors.txt.diff | 14 +-- ...toryReference(jsx=react-native).errors.txt | 12 -- ...eference(jsx=react-native).errors.txt.diff | 16 --- ...ExpressionNoTypeAssertionInJsx2.errors.txt | 5 +- ...ExpressionNoTypeAssertionInJsx4.errors.txt | 5 +- ...ssionNoTypeAssertionInJsx4.errors.txt.diff | 24 ---- .../intraExpressionInferencesJsx.errors.txt | 115 ----------------- ...traExpressionInferencesJsx.errors.txt.diff | 119 ------------------ ...formCustomImport(jsx=react-jsx).errors.txt | 5 +- ...ustomImport(jsx=react-jsx).errors.txt.diff | 20 --- ...mCustomImport(jsx=react-jsxdev).errors.txt | 5 +- ...omImport(jsx=react-jsxdev).errors.txt.diff | 20 --- ...stomImportPragma(jsx=react-jsx).errors.txt | 5 +- ...mportPragma(jsx=react-jsx).errors.txt.diff | 24 ---- ...mImportPragma(jsx=react-jsxdev).errors.txt | 5 +- ...rtPragma(jsx=react-jsxdev).errors.txt.diff | 24 ---- ...ssionNoTypeAssertionInJsx2.errors.txt.diff | 20 --- 25 files changed, 23 insertions(+), 506 deletions(-) delete mode 100644 testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 706bfada0e..90f86341b0 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -26926,11 +26926,12 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if ast.IsJsxOpeningLikeElement(node) { jsxFactoryLocation = node.TagName() } + shouldFactoryRefErr := c.compilerOptions.Jsx != core.JsxEmitPreserve && c.compilerOptions.Jsx != core.JsxEmitReactNative // #38720/60122, allow null as jsxFragmentFactory var jsxFactorySym *ast.Symbol if !(ast.IsJsxOpeningFragment(node) && jsxFactoryNamespace == "null") { flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { + if !shouldFactoryRefErr { flags &= ^ast.SymbolFlagsEnum } jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) @@ -26950,7 +26951,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement localJsxNamespace := c.getLocalJsxNamespace(file) if localJsxNamespace != "" { flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { + if !shouldFactoryRefErr { flags &= ^ast.SymbolFlagsEnum } c.resolveName(jsxFactoryLocation, localJsxNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index b62f9079f8..88dde88d10 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -490,14 +490,16 @@ func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { } jsxFragmentFactoryName := c.getJsxNamespace(node) // #38720/60122, allow null as jsxFragmentFactory - if jsxFragmentFactoryName == "null" { + shouldResolveFactoryReference := (c.compilerOptions.Jsx == core.JsxEmitReact || c.compilerOptions.JsxFragmentFactory != "") && jsxFragmentFactoryName != "null" + if !shouldResolveFactoryReference { links.jsxFragmentType = c.anyType return links.jsxFragmentType } jsxFactorySymbol := c.getJsxNamespaceContainerForImplicitImport(node) if jsxFactorySymbol == nil { + shouldModuleRefErr := c.compilerOptions.Jsx != core.JsxEmitPreserve && c.compilerOptions.Jsx != core.JsxEmitReactNative flags := ast.SymbolFlagsValue - if c.compilerOptions.Jsx == core.JsxEmitPreserve || c.compilerOptions.Jsx == core.JsxEmitReactNative { + if !shouldModuleRefErr { flags &= ^ast.SymbolFlagsEnum } jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, flags, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) diff --git a/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt b/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt deleted file mode 100644 index 057d139771..0000000000 --- a/testdata/baselines/reference/compiler/expandoContextualTypes.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -expandoContextualTypes.tsx(20,12): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - -==== expandoContextualTypes.tsx (1 errors) ==== - // https://github.com/microsoft/typescript-go/issues/921 - - /// - - import type { ComponentType } from "react"; - - export type Page

> = ComponentType

& { - getLayout?: (component: JSX.Element) => JSX.Element; - } - - export const FooPage: Page = () => { - return ( -

-

Foo

-
- ) - }; - - FooPage.getLayout = () => { - return <> - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - }; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt deleted file mode 100644 index f212c72357..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - -==== jsxFragmentFactoryReference.tsx (1 errors) ==== - export class LoggedOut { - content = () => ( - <> - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff deleted file mode 100644 index b8ebc99ec0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=preserve).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsxFragmentFactoryReference(jsx=preserve).errors.txt -+++ new.jsxFragmentFactoryReference(jsx=preserve).errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxFragmentFactoryReference.tsx (1 errors) ==== -+ export class LoggedOut { -+ content = () => ( -+ <> -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ ) -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt index c8caaefa36..453fbd038e 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt @@ -1,15 +1,12 @@ jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxFragmentFactoryReference.tsx (2 errors) ==== +==== jsxFragmentFactoryReference.tsx (1 errors) ==== export class LoggedOut { content = () => ( <> ~~ !!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff index 3d0c1638be..c2e0779654 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt.diff @@ -2,22 +2,16 @@ +++ new.jsxFragmentFactoryReference(jsx=react-jsx).errors.txt @@= skipped -0, +0 lines =@@ -jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -- -- --==== jsxFragmentFactoryReference.tsx (1 errors) ==== +jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxFragmentFactoryReference.tsx (2 errors) ==== - export class LoggedOut { + + + ==== jsxFragmentFactoryReference.tsx (1 errors) ==== +@@= skipped -5, +5 lines =@@ content = () => ( <> ~~ -!!! error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +!!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt index 16bb6f5a54..7529f71c4d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt @@ -1,15 +1,12 @@ jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxFragmentFactoryReference.tsx (2 errors) ==== +==== jsxFragmentFactoryReference.tsx (1 errors) ==== export class LoggedOut { content = () => ( <> ~~ !!! error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff index c136dcf226..cd429f045a 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt.diff @@ -2,22 +2,16 @@ +++ new.jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt @@= skipped -0, +0 lines =@@ -jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -- -- --==== jsxFragmentFactoryReference.tsx (1 errors) ==== +jsxFragmentFactoryReference.tsx(3,9): error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxFragmentFactoryReference.tsx (2 errors) ==== - export class LoggedOut { + + + ==== jsxFragmentFactoryReference.tsx (1 errors) ==== +@@= skipped -5, +5 lines =@@ content = () => ( <> ~~ -!!! error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? +!!! error TS2875: This JSX tag requires the module path 'react/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ) } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt deleted file mode 100644 index f212c72357..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - -==== jsxFragmentFactoryReference.tsx (1 errors) ==== - export class LoggedOut { - content = () => ( - <> - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ) - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff deleted file mode 100644 index 83d930af26..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxFragmentFactoryReference(jsx=react-native).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.jsxFragmentFactoryReference(jsx=react-native).errors.txt -+++ new.jsxFragmentFactoryReference(jsx=react-native).errors.txt -@@= skipped -0, +0 lines =@@ -- -+jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxFragmentFactoryReference.tsx (1 errors) ==== -+ export class LoggedOut { -+ content = () => ( -+ <> -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ ) -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt index b4fb215aae..69e07e5236 100644 --- a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt @@ -1,17 +1,14 @@ index.js(2,12): error TS17014: JSX fragment has no corresponding closing tag. -index.js(2,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. index.js(2,13): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. index.js(3,1): error TS1005: ' x; ~~~ !!! error TS17014: JSX fragment has no corresponding closing tag. ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ~~ !!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt index 4038850823..2c20091271 100644 --- a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt @@ -1,12 +1,11 @@ index.tsx(3,14): error TS17008: JSX element 'number' has no corresponding closing tag. -index.tsx(4,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. index.tsx(4,13): error TS17014: JSX fragment has no corresponding closing tag. index.tsx(5,14): error TS1003: Identifier expected. index.tsx(5,18): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? index.tsx(6,1): error TS1005: ' x; @@ -14,8 +13,6 @@ index.tsx(6,1): error TS1005: ' x; ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ~~ !!! error TS17014: JSX fragment has no corresponding closing tag. const c = + <1234> x; ~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff deleted file mode 100644 index febd94f31f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt -+++ new.parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt -@@= skipped -0, +0 lines =@@ - index.tsx(3,14): error TS17008: JSX element 'number' has no corresponding closing tag. -+index.tsx(4,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - index.tsx(4,13): error TS17014: JSX fragment has no corresponding closing tag. - index.tsx(5,14): error TS1003: Identifier expected. - index.tsx(5,18): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`? - index.tsx(6,1): error TS1005: ' x; - ~~~~~~ - !!! error TS17008: JSX element 'number' has no corresponding closing tag. - const b = + <> x; -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ~~ - !!! error TS17014: JSX fragment has no corresponding closing tag. - const c = + <1234> x; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt deleted file mode 100644 index 890a4fc53f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt +++ /dev/null @@ -1,115 +0,0 @@ -intraExpressionInferencesJsx.tsx(35,29): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - -==== intraExpressionInferencesJsx.tsx (1 errors) ==== - /// - - // repro from #52798 - - type A = { - a: boolean; - }; - - type B = { - b: string; - }; - - type C = { - c: number; - }; - - type Animations = { - [key: string]: { value: number } & ( - | ({ kind: "a"; func?(): Partial
} & A) - | ({ kind: "b"; func?(): Partial } & B) - | ({ kind: "c"; func?(): Partial } & C) - ); - }; - - type StyleParam = Record; - - type AnimatedViewProps = { - style: (animationsValues: StyleParam) => string; - animations: T; - }; - - const Component = ({ - animations, - style, - }: AnimatedViewProps) => <>; - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - { - return ""; - }} - />; - { - return ""; - }} - />; - { - return { - a: true, - }; - }, - }, - }} - style={(anim) => { - return ""; - }} - />; - - // repro from #52786 - - interface Props { - a: (x: string) => T; - b: (arg: T) => void; - } - - function Foo(props: Props) { - return
; - } - - 10} - b={(arg) => { arg.toString(); }} - />; - - 10} - b={(arg) => { arg.toString(); }} - />; - - 10, - b: (arg) => { arg.toString(); }, - }} />; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff deleted file mode 100644 index 9b4f597188..0000000000 --- a/testdata/baselines/reference/submodule/conformance/intraExpressionInferencesJsx.errors.txt.diff +++ /dev/null @@ -1,119 +0,0 @@ ---- old.intraExpressionInferencesJsx.errors.txt -+++ new.intraExpressionInferencesJsx.errors.txt -@@= skipped -0, +0 lines =@@ -- -+intraExpressionInferencesJsx.tsx(35,29): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== intraExpressionInferencesJsx.tsx (1 errors) ==== -+ /// -+ -+ // repro from #52798 -+ -+ type A = { -+ a: boolean; -+ }; -+ -+ type B = { -+ b: string; -+ }; -+ -+ type C = { -+ c: number; -+ }; -+ -+ type Animations = { -+ [key: string]: { value: number } & ( -+ | ({ kind: "a"; func?(): Partial } & A) -+ | ({ kind: "b"; func?(): Partial } & B) -+ | ({ kind: "c"; func?(): Partial } & C) -+ ); -+ }; -+ -+ type StyleParam = Record; -+ -+ type AnimatedViewProps = { -+ style: (animationsValues: StyleParam) => string; -+ animations: T; -+ }; -+ -+ const Component = ({ -+ animations, -+ style, -+ }: AnimatedViewProps) => <>; -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ { -+ return ""; -+ }} -+ />; -+ { -+ return ""; -+ }} -+ />; -+ { -+ return { -+ a: true, -+ }; -+ }, -+ }, -+ }} -+ style={(anim) => { -+ return ""; -+ }} -+ />; -+ -+ // repro from #52786 -+ -+ interface Props { -+ a: (x: string) => T; -+ b: (arg: T) => void; -+ } -+ -+ function Foo(props: Props) { -+ return
; -+ } -+ -+ 10} -+ b={(arg) => { arg.toString(); }} -+ />; -+ -+ 10} -+ b={(arg) => { arg.toString(); }} -+ />; -+ -+ 10, -+ b: (arg) => { arg.toString(); }, -+ }} />; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt index 2b8fbaf4e4..248540ed38 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt @@ -1,14 +1,11 @@ jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== +==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== /// const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff deleted file mode 100644 index 129afb7c02..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt -+++ new.jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt -@@= skipped -0, +0 lines =@@ - jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -- -- --==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== -+jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== - /// - const a = <> - ~~ - !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -

- text -
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt index 31af5093de..e66480f8dc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt @@ -1,14 +1,11 @@ jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== +==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== /// const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff deleted file mode 100644 index f4a16b80de..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt -+++ new.jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt -@@= skipped -0, +0 lines =@@ - jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -- -- --==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== -+jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -+ -+ -+==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ==== - /// - const a = <> - ~~ - !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -

- text -
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt index 7155c43a5d..c37e010cab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt @@ -1,5 +1,4 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ==== react.tsx (0 errors) ==== @@ -13,14 +12,12 @@ preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'R export {}; -==== preact.tsx (2 errors) ==== +==== preact.tsx (1 errors) ==== /// /* @jsxImportSource preact */ const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff deleted file mode 100644 index 43fcd4054d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt -+++ new.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt -@@= skipped -0, +0 lines =@@ - preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - - ==== react.tsx (0 errors) ==== -@@= skipped -11, +12 lines =@@ - - - export {}; --==== preact.tsx (1 errors) ==== -+==== preact.tsx (2 errors) ==== - /// - /* @jsxImportSource preact */ - const a = <> - ~~ - !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -

- text -
\ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt index ad4bb3c20b..79e8e02a87 100644 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt @@ -1,5 +1,4 @@ preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. ==== react.tsx (0 errors) ==== @@ -13,14 +12,12 @@ preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'R export {}; -==== preact.tsx (2 errors) ==== +==== preact.tsx (1 errors) ==== /// /* @jsxImportSource preact */ const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. - ~~ -!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.

text
diff --git a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff deleted file mode 100644 index 50a5d39ea1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt -+++ new.jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt -@@= skipped -0, +0 lines =@@ - preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - - - ==== react.tsx (0 errors) ==== -@@= skipped -11, +12 lines =@@ - - - export {}; --==== preact.tsx (1 errors) ==== -+==== preact.tsx (2 errors) ==== - /// - /* @jsxImportSource preact */ - const a = <> - ~~ - !!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. -

- text -
\ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff deleted file mode 100644 index a3aefeef8d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt -+++ new.parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt -@@= skipped -0, +0 lines =@@ - index.js(2,12): error TS17014: JSX fragment has no corresponding closing tag. -+index.js(2,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - index.js(2,13): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. - index.js(3,1): error TS1005: ' x; - ~~~ - !!! error TS17014: JSX fragment has no corresponding closing tag. -+ ~~ -+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found. - ~~ - !!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. - \ No newline at end of file From 4d0638f824e059189dfba0b53498a74f5fcab9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 23:10:03 +0200 Subject: [PATCH 5/6] fmt --- internal/checker/checker.go | 4 ++-- internal/checker/jsx.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index e347ee7489..02c6befb4f 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -26951,7 +26951,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if !(ast.IsJsxOpeningFragment(node) && jsxFactoryNamespace == "null") { flags := ast.SymbolFlagsValue if !shouldFactoryRefErr { - flags &= ^ast.SymbolFlagsEnum + flags&=^ast.SymbolFlagsEnum } jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } @@ -26971,7 +26971,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if localJsxNamespace != "" { flags := ast.SymbolFlagsValue if !shouldFactoryRefErr { - flags &= ^ast.SymbolFlagsEnum + flags&=^ast.SymbolFlagsEnum } c.resolveName(jsxFactoryLocation, localJsxNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 88dde88d10..50ae3a7f53 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -500,7 +500,7 @@ func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { shouldModuleRefErr := c.compilerOptions.Jsx != core.JsxEmitPreserve && c.compilerOptions.Jsx != core.JsxEmitReactNative flags := ast.SymbolFlagsValue if !shouldModuleRefErr { - flags &= ^ast.SymbolFlagsEnum + flags&=^ast.SymbolFlagsEnum } jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, flags, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) } From bdbe146f7f028bdc6b73c868e3673d7b57472486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Jun 2025 23:36:38 +0200 Subject: [PATCH 6/6] Revert "fmt" This reverts commit 4d0638f824e059189dfba0b53498a74f5fcab9ec. --- internal/checker/checker.go | 4 ++-- internal/checker/jsx.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 02c6befb4f..e347ee7489 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -26951,7 +26951,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if !(ast.IsJsxOpeningFragment(node) && jsxFactoryNamespace == "null") { flags := ast.SymbolFlagsValue if !shouldFactoryRefErr { - flags&=^ast.SymbolFlagsEnum + flags &= ^ast.SymbolFlagsEnum } jsxFactorySym = c.resolveName(jsxFactoryLocation, jsxFactoryNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } @@ -26971,7 +26971,7 @@ func (c *Checker) markJsxAliasReferenced(node *ast.Node /*JsxOpeningLikeElement if localJsxNamespace != "" { flags := ast.SymbolFlagsValue if !shouldFactoryRefErr { - flags&=^ast.SymbolFlagsEnum + flags &= ^ast.SymbolFlagsEnum } c.resolveName(jsxFactoryLocation, localJsxNamespace, flags, jsxFactoryRefErr, true /*isUse*/, false /*excludeGlobals*/) } diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 50ae3a7f53..88dde88d10 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -500,7 +500,7 @@ func (c *Checker) getJSXFragmentType(node *ast.Node) *Type { shouldModuleRefErr := c.compilerOptions.Jsx != core.JsxEmitPreserve && c.compilerOptions.Jsx != core.JsxEmitReactNative flags := ast.SymbolFlagsValue if !shouldModuleRefErr { - flags&=^ast.SymbolFlagsEnum + flags &= ^ast.SymbolFlagsEnum } jsxFactorySymbol = c.resolveName(node, jsxFragmentFactoryName, flags, diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found, true /*isUse*/, false /*excludeGlobals*/) }