diff --git a/internal/api/encoder/encoder.go b/internal/api/encoder/encoder.go index 55f49f809c..497a967262 100644 --- a/internal/api/encoder/encoder.go +++ b/internal/api/encoder/encoder.go @@ -686,7 +686,7 @@ func getChildrenPropertyMask(node *ast.Node) uint8 { return (boolToByte(n.TagName != nil) << 0) | (boolToByte(n.TypeExpression != nil) << 1) | (boolToByte(n.Name() != nil) << 2) | (boolToByte(n.Comment != nil) << 3) case ast.KindJSDocSignature: n := node.AsJSDocSignature() - return (boolToByte(n.TypeParameters() != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2) + return (boolToByte(n.TypeParameters != nil) << 0) | (boolToByte(n.Parameters != nil) << 1) | (boolToByte(n.Type != nil) << 2) case ast.KindClassStaticBlockDeclaration: n := node.AsClassStaticBlockDeclaration() return (boolToByte(n.Modifiers() != nil) << 0) | (boolToByte(n.Body != nil) << 1) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index d01852e3f6..ddd62ebed4 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -9201,6 +9201,7 @@ type JSDocTemplateTag struct { JSDocTagBase Constraint *Node TypeParameters *TypeParameterList + Host *Node } func (f *NodeFactory) NewJSDocTemplateTag(tagName *IdentifierNode, constraint *Node, typeParameters *TypeParameterList, comment *NodeList) *Node { @@ -9876,40 +9877,36 @@ func (node *JSDocTypeLiteral) Clone(f NodeFactoryCoercible) *Node { // JSDocSignature type JSDocSignature struct { TypeNodeBase - typeParameters *TypeParameterList - Parameters *NodeList - Type *JSDocTag + FunctionLikeBase } -func (f *NodeFactory) NewJSDocSignature(typeParameters *TypeParameterList, parameters *NodeList, typeNode *JSDocTag) *Node { +func (f *NodeFactory) NewJSDocSignature(typeParameters *NodeList, parameters *NodeList, typeNode *JSDocTag) *Node { data := &JSDocSignature{} - data.typeParameters = typeParameters + data.TypeParameters = typeParameters data.Parameters = parameters data.Type = typeNode return f.newNode(KindJSDocSignature, data) } -func (f *NodeFactory) UpdateJSDocSignature(node *JSDocSignature, typeParameters *TypeParameterList, parameters *NodeList, typeNode *JSDocTag) *Node { - if typeParameters != node.typeParameters || parameters != node.Parameters || typeNode != node.Type { +func (f *NodeFactory) UpdateJSDocSignature(node *JSDocSignature, typeParameters *NodeList, parameters *NodeList, typeNode *JSDocTag) *Node { + if typeParameters != node.TypeParameters || parameters != node.Parameters || typeNode != node.Type { return updateNode(f.NewJSDocSignature(typeParameters, parameters, typeNode), node.AsNode(), f.hooks) } return node.AsNode() } func (node *JSDocSignature) ForEachChild(v Visitor) bool { - return visitNodeList(v, node.typeParameters) || visitNodeList(v, node.Parameters) || visit(v, node.Type) + return visitNodeList(v, node.TypeParameters) || visitNodeList(v, node.Parameters) || visit(v, node.Type) } func (node *JSDocSignature) VisitEachChild(v *NodeVisitor) *Node { - return v.Factory.UpdateJSDocSignature(node, v.visitNodes(node.typeParameters), v.visitNodes(node.Parameters), v.visitNode(node.Type)) + return v.Factory.UpdateJSDocSignature(node, v.visitNodes(node.TypeParameters), v.visitNodes(node.Parameters), v.visitNode(node.Type)) } func (node *JSDocSignature) Clone(f NodeFactoryCoercible) *Node { - return cloneNode(f.AsNodeFactory().NewJSDocSignature(node.TypeParameters(), node.Parameters, node.Type), node.AsNode(), f.AsNodeFactory().hooks) + return cloneNode(f.AsNodeFactory().NewJSDocSignature(node.TypeParameters, node.Parameters, node.Type), node.AsNode(), f.AsNodeFactory().hooks) } -func (node *JSDocSignature) TypeParameters() *TypeParameterList { return node.typeParameters } - // JSDocNameReference type JSDocNameReference struct { TypeNodeBase diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 8525bf1851..feae9dc7af 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -865,9 +865,11 @@ func WalkUpParenthesizedTypes(node *TypeNode) *Node { } func GetEffectiveTypeParent(parent *Node) *Node { - if IsInJSFile(parent) && parent.Kind == KindJSDocTypeExpression { - if host := parent.AsJSDocTypeExpression().Host; host != nil { - parent = host + if parent != nil && IsInJSFile(parent) { + if parent.Kind == KindJSDocTypeExpression && parent.AsJSDocTypeExpression().Host != nil { + parent = parent.AsJSDocTypeExpression().Host + } else if parent.Kind == KindJSDocTemplateTag && parent.AsJSDocTemplateTag().Host != nil { + parent = parent.AsJSDocTemplateTag().Host } } return parent diff --git a/internal/binder/nameresolver.go b/internal/binder/nameresolver.go index 569b407cc9..5966c86858 100644 --- a/internal/binder/nameresolver.go +++ b/internal/binder/nameresolver.go @@ -288,13 +288,8 @@ loop: if isSelfReferenceLocation(location, lastLocation) { lastSelfReferenceLocation = location } - if location.Kind == ast.KindJSDocTypeExpression && location.AsJSDocTypeExpression().Host != nil { - lastLocation = location.AsJSDocTypeExpression().Host.Type() - location = location.AsJSDocTypeExpression().Host - } else { - lastLocation = location - location = location.Parent - } + lastLocation = location + location = ast.GetEffectiveTypeParent(location.Parent) } // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself. @@ -487,6 +482,9 @@ func isTypeParameterSymbolDeclaredInContainer(symbol *ast.Symbol, container *ast for _, decl := range symbol.Declarations { if decl.Kind == ast.KindTypeParameter { parent := decl.Parent + if parent.Kind == ast.KindJSDocTemplateTag { + parent = parent.AsJSDocTemplateTag().Host + } if parent == container { return true } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index f7368542c9..171af805a1 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -22602,7 +22602,7 @@ func (c *Checker) getOuterTypeParametersOfClassOrInterface(symbol *ast.Symbol) [ // Return the outer type parameters of a node or undefined if the node has no outer type parameters. func (c *Checker) getOuterTypeParameters(node *ast.Node, includeThisTypes bool) []*Type { for { - node = node.Parent + node = ast.GetEffectiveTypeParent(node.Parent) if node == nil { return nil } diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index faab4e00b0..20113b6888 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -67,33 +67,41 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod export.Flags = p.contextFlags | ast.NodeFlagsReparsed modifiers := p.newModifierList(export.Loc, p.nodeSlicePool.NewSlice1(export)) - typeParameters := p.gatherTypeParameters(jsDoc) - + typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, tag.AsJSDocTypedefTag().Name(), nil, nil) + typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag, typeAlias) var t *ast.Node switch typeExpression.Kind { case ast.KindJSDocTypeExpression: - t = typeExpression.Type() + t = setHost(typeExpression, typeAlias) case ast.KindJSDocTypeLiteral: - members := p.nodeSlicePool.NewSlice(0) - for _, member := range typeExpression.AsJSDocTypeLiteral().JSDocPropertyTags { - prop := p.factory.NewPropertySignatureDeclaration(nil, member.Name(), p.makeQuestionIfOptional(member.AsJSDocParameterOrPropertyTag()), member.Type(), nil /*initializer*/) - prop.Loc = member.Loc - prop.Flags = p.contextFlags | ast.NodeFlagsReparsed - members = append(members, prop) - } - t = p.factory.NewTypeLiteralNode(p.newNodeList(typeExpression.Loc, members)) - t.Loc = typeExpression.Loc - t.Flags = p.contextFlags | ast.NodeFlagsReparsed + t = p.reparseJSDocTypeLiteral(typeExpression, typeAlias) default: panic("typedef tag type expression should be a name reference or a type expression" + typeExpression.Kind.String()) } - typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, tag.AsJSDocTypedefTag().Name(), typeParameters, t) + typeAlias.AsTypeAliasDeclaration().Type = t + typeAlias.Loc = tag.Loc + typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed + p.reparseList = append(p.reparseList, typeAlias) + case ast.KindJSDocCallbackTag: + callbackTag := tag.AsJSDocCallbackTag() + if callbackTag.TypeExpression == nil { + break + } + + export := p.factory.NewModifier(ast.KindExportKeyword) + export.Loc = tag.Loc + export.Flags = p.contextFlags | ast.NodeFlagsReparsed + modifiers := p.newModifierList(export.Loc, p.nodeSlicePool.NewSlice1(export)) + functionType := p.reparseJSDocSignature(callbackTag.TypeExpression, tag, jsDoc, tag) + + typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, callbackTag.FullName, nil, functionType) + typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag, typeAlias) typeAlias.Loc = tag.Loc typeAlias.Flags = p.contextFlags | ast.NodeFlagsReparsed p.reparseList = append(p.reparseList, typeAlias) case ast.KindJSDocImportTag: importTag := tag.AsJSDocImportTag() - importClause := importTag.ImportClause.Clone(&p.factory) + importClause := importTag.ImportClause importClause.Flags |= ast.NodeFlagsReparsed importClause.AsImportClause().IsTypeOnly = true importDeclaration := p.factory.NewJSImportDeclaration(importTag.Modifiers(), importClause, importTag.ModuleSpecifier, importTag.Attributes) @@ -103,80 +111,140 @@ func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Nod p.reparseList = append(p.reparseList, importDeclaration) case ast.KindJSDocOverloadTag: if fun, ok := getFunctionLikeHost(parent); ok { - jsSignature := tag.AsJSDocOverloadTag().TypeExpression.AsJSDocSignature() - typeParameters := p.gatherTypeParameters(jsDoc) - var signature *ast.Node - switch fun.Kind { - case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction: - signature = p.factory.NewFunctionDeclaration(nil, nil, fun.Name(), typeParameters, nil, nil, nil) - case ast.KindMethodDeclaration, ast.KindMethodSignature: - signature = p.factory.NewMethodDeclaration(nil, nil, fun.Name(), nil, typeParameters, nil, nil, nil) - case ast.KindConstructor: - signature = p.factory.NewConstructorDeclaration(nil, typeParameters, nil, nil, nil) - default: - panic("Unexpected kind " + fun.Kind.String()) - } + p.reparseList = append(p.reparseList, p.reparseJSDocSignature(tag.AsJSDocOverloadTag().TypeExpression, fun, jsDoc, tag)) + } + } +} - parameters := p.nodeSlicePool.NewSlice(0) - for _, param := range jsSignature.Parameters.Nodes { - jsparam := param.AsJSDocParameterOrPropertyTag() +func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsDoc *ast.Node, tag *ast.Node) *ast.Node { + var signature *ast.Node + switch fun.Kind { + case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction: + signature = p.factory.NewFunctionDeclaration(nil, nil, fun.Name(), nil, nil, nil, nil) + case ast.KindMethodDeclaration, ast.KindMethodSignature: + signature = p.factory.NewMethodDeclaration(nil, nil, fun.Name(), nil, nil, nil, nil, nil) + case ast.KindConstructor: + signature = p.factory.NewConstructorDeclaration(nil, nil, nil, nil, nil) + case ast.KindJSDocCallbackTag: + signature = p.factory.NewFunctionTypeNode(nil, nil, nil) + default: + panic("Unexpected kind " + fun.Kind.String()) + } - var parameterType *ast.Node - if jsparam.TypeExpression != nil { - parameterType = p.makeNewType(jsparam.TypeExpression, signature) - } - parameter := p.factory.NewParameterDeclaration(nil, nil, jsparam.Name(), p.makeQuestionIfOptional(jsparam), parameterType, nil) - parameter.Loc = jsparam.Loc - parameter.Flags = p.contextFlags | ast.NodeFlagsReparsed - parameters = append(parameters, parameter) + if tag.Kind != ast.KindJSDocCallbackTag { + signature.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc, tag, signature) + } + parameters := p.nodeSlicePool.NewSlice(0) + for _, param := range jsSignature.Parameters() { + var parameter *ast.Node + if param.Kind == ast.KindJSDocThisTag { + thisTag := param.AsJSDocThisTag() + thisIdent := p.factory.NewIdentifier("this") + thisIdent.Loc = thisTag.Loc + thisIdent.Flags = p.contextFlags | ast.NodeFlagsReparsed + parameter = p.factory.NewParameterDeclaration(nil, nil, thisIdent, nil, nil, nil) + parameter.AsParameterDeclaration().Type = setHost(thisTag.TypeExpression, parameter) + } else { + jsparam := param.AsJSDocParameterOrPropertyTag() + parameter = p.factory.NewParameterDeclaration(nil, nil, jsparam.Name(), p.makeQuestionIfOptional(jsparam), nil, nil) + if jsparam.TypeExpression != nil { + t := p.reparseJSDocTypeLiteral(jsparam.TypeExpression.Type(), parameter) + setHost(jsparam.TypeExpression, parameter) + parameter.AsParameterDeclaration().Type = t } + } + parameter.Loc = param.Loc + parameter.Flags = p.contextFlags | ast.NodeFlagsReparsed + parameters = append(parameters, parameter) + } + signature.FunctionLikeData().Parameters = p.newNodeList(jsSignature.AsJSDocSignature().Parameters.Loc, parameters) + + if jsSignature.Type() != nil { + signature.FunctionLikeData().Type = setHost(jsSignature.Type().AsJSDocReturnTag().TypeExpression, signature) + } + signature.Loc = tag.Loc + if tag.Kind == ast.KindJSDocOverloadTag { + signature.Loc = tag.AsJSDocOverloadTag().TagName.Loc + } + signature.Flags = p.contextFlags | ast.NodeFlagsReparsed + return signature +} - if jsSignature.Type != nil { - signature.FunctionLikeData().Type = p.makeNewType(jsSignature.Type.AsJSDocReturnTag().TypeExpression, signature) +func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode, host *ast.Node) *ast.Node { + if t != nil && t.Kind == ast.KindJSDocTypeLiteral { + properties := p.nodeSlicePool.NewSlice(0) + for _, prop := range t.AsJSDocTypeLiteral().JSDocPropertyTags { + jsprop := prop.AsJSDocParameterOrPropertyTag() + name := prop.Name() + if name.Kind == ast.KindQualifiedName { + name = name.AsQualifiedName().Right } - signature.FunctionLikeData().Parameters = p.newNodeList(jsSignature.Parameters.Loc, parameters) - signature.Loc = tag.AsJSDocOverloadTag().TagName.Loc - signature.Flags = p.contextFlags | ast.NodeFlagsReparsed - p.reparseList = append(p.reparseList, signature) + property := p.factory.NewPropertySignatureDeclaration(nil, name, p.makeQuestionIfOptional(jsprop), nil, nil) + property.AsPropertySignatureDeclaration().Type = p.reparseJSDocTypeLiteral(jsprop.TypeExpression, property) + property.Loc = prop.Loc + property.Flags = p.contextFlags | ast.NodeFlagsReparsed + properties = append(properties, property) } - // !!! other unattached tags (@callback) support goes here + loc := t.Loc + t = p.factory.NewTypeLiteralNode(p.newNodeList(loc, properties)) + t.Loc = loc + t.Flags = p.contextFlags | ast.NodeFlagsReparsed } + return t } -func (p *Parser) gatherTypeParameters(j *ast.Node) *ast.NodeList { +func (p *Parser) gatherTypeParameters(j *ast.Node, tagWithTypeParameters *ast.Node, host *ast.Node) *ast.NodeList { typeParameters := p.nodeSlicePool.NewSlice(0) pos := -1 - end := -1 - first := true - for _, tag := range j.AsJSDoc().Tags.Nodes { - if tag.Kind == ast.KindJSDocTemplateTag { - if first { - pos = tag.Pos() - first = false - } - end = tag.End() + endPos := -1 + firstTemplate := true + // type parameters only apply to the tag or node they occur before, so record a place to stop + start := 0 + for i, other := range j.AsJSDoc().Tags.Nodes { + if other == tagWithTypeParameters { + break + } + if other.Kind == ast.KindJSDocTypedefTag || other.Kind == ast.KindJSDocCallbackTag || other.Kind == ast.KindJSDocOverloadTag { + start = i + 1 + } + } + for i, tag := range j.AsJSDoc().Tags.Nodes { + if tag == tagWithTypeParameters { + break + } + if i < start || tag.Kind != ast.KindJSDocTemplateTag { + continue + } + if firstTemplate { + pos = tag.Pos() + firstTemplate = false + } + endPos = tag.End() - constraint := tag.AsJSDocTemplateTag().Constraint - for _, tp := range tag.TypeParameters() { - typeParameter := tp.AsTypeParameter() - var reparse *ast.Node - if constraint == nil { - reparse = typeParameter.Clone(&p.factory) - } else { - clone := constraint.Type().Clone(&p.factory) - clone.Flags |= ast.NodeFlagsReparsed - reparse = p.factory.NewTypeParameterDeclaration(typeParameter.Modifiers(), typeParameter.Name(), clone, typeParameter.DefaultType) - reparse.Loc = typeParameter.Loc - } - reparse.Flags |= ast.NodeFlagsReparsed - typeParameters = append(typeParameters, reparse) + constraint := tag.AsJSDocTemplateTag().Constraint + firstTypeParameter := true + for _, tp := range tag.TypeParameters() { + reparse := tp + if constraint != nil && firstTypeParameter { + reparse = p.factory.NewTypeParameterDeclaration(tp.Modifiers(), tp.Name(), nil, tp.AsTypeParameter().DefaultType) + reparse.AsTypeParameter().Constraint = setHost(constraint, host) + reparse.Loc = tp.Loc + } + if tag.AsJSDocTemplateTag().Host == nil { + tag.AsJSDocTemplateTag().Host = host + } else if firstTypeParameter { + // don't panic for non-first type parameters like U,V in `@template T,U,V`; they share a host with the first one + panic("JSDoc type parameter already has a host: " + tag.AsJSDocTemplateTag().Host.Kind.String()) } + reparse.Flags |= ast.NodeFlagsReparsed + typeParameters = append(typeParameters, reparse) + firstTypeParameter = false } } if len(typeParameters) == 0 { return nil } else { - return p.newNodeList(core.NewTextRange(pos, end), typeParameters) + return p.newNodeList(core.NewTextRange(pos, endPos), typeParameters) } } @@ -188,73 +256,73 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) if parent.AsVariableStatement().DeclarationList != nil { for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { if declaration.AsVariableDeclaration().Type == nil { - declaration.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, declaration) + declaration.AsVariableDeclaration().Type = setHost(tag.AsJSDocTypeTag().TypeExpression, declaration) break } } } case ast.KindVariableDeclaration: if parent.AsVariableDeclaration().Type == nil { - parent.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + parent.AsVariableDeclaration().Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindCommonJSExport: export := parent.AsCommonJSExport() if export.Type == nil { - export.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + export.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindPropertyDeclaration: declaration := parent.AsPropertyDeclaration() if declaration.Type == nil { - declaration.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + declaration.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindPropertyAssignment: prop := parent.AsPropertyAssignment() if prop.Type == nil { - prop.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + prop.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindShorthandPropertyAssignment: prop := parent.AsShorthandPropertyAssignment() if prop.Type == nil { - prop.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + prop.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindExportAssignment, ast.KindJSExportAssignment: export := parent.AsExportAssignment() if export.Type == nil { - export.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) + export.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent) } case ast.KindReturnStatement: ret := parent.AsReturnStatement() - ret.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression, true /*isAssertion*/) + ret.Expression = p.makeNewCast(setHost(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression, true /*isAssertion*/) case ast.KindParenthesizedExpression: paren := parent.AsParenthesizedExpression() - paren.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression, true /*isAssertion*/) + paren.Expression = p.makeNewCast(setHost(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression, true /*isAssertion*/) case ast.KindExpressionStatement: if parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() if kind := ast.GetAssignmentDeclarationKind(bin); kind != ast.JSDeclarationKindNone { - bin.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) + bin.Type = setHost(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) } } } case ast.KindJSDocSatisfiesTag: if parent.Kind == ast.KindParenthesizedExpression { paren := parent.AsParenthesizedExpression() - paren.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocSatisfiesTag().TypeExpression, nil), paren.Expression, false /*isAssertion*/) + paren.Expression = p.makeNewCast(setHost(tag.AsJSDocSatisfiesTag().TypeExpression, nil), paren.Expression, false /*isAssertion*/) } case ast.KindJSDocTemplateTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.TypeParameters() == nil { - fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc) + fun.FunctionLikeData().TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, fun) } } else if parent.Kind == ast.KindClassDeclaration { class := parent.AsClassDeclaration() if class.TypeParameters == nil { - class.TypeParameters = p.gatherTypeParameters(jsDoc) + class.TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, parent) } } else if parent.Kind == ast.KindClassExpression { class := parent.AsClassExpression() if class.TypeParameters == nil { - class.TypeParameters = p.gatherTypeParameters(jsDoc) + class.TypeParameters = p.gatherTypeParameters(jsDoc, nil /*tagWithTypeParameters*/, parent) } } case ast.KindJSDocParameterTag: @@ -262,7 +330,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) jsparam := tag.AsJSDocParameterOrPropertyTag() if param, ok := findMatchingParameter(fun, jsparam); ok { if param.Type == nil { - param.Type = p.makeNewType(jsparam.TypeExpression, param.AsNode()) + param.Type = setHost(jsparam.TypeExpression, param.AsNode()) } if param.QuestionToken == nil && param.Initializer == nil { if question := p.makeQuestionIfOptional(jsparam); question != nil { @@ -283,7 +351,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) nil, /* type */ nil, /* initializer */ ) - thisParam.AsParameterDeclaration().Type = p.makeNewType(tag.AsJSDocThisTag().TypeExpression, thisParam) + thisParam.AsParameterDeclaration().Type = setHost(tag.AsJSDocThisTag().TypeExpression, thisParam) thisParam.Loc = tag.AsJSDocThisTag().TagName.Loc thisParam.Flags = p.contextFlags | ast.NodeFlagsReparsed @@ -299,7 +367,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) case ast.KindJSDocReturnTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.Type() == nil { - fun.FunctionLikeData().Type = p.makeNewType(tag.AsJSDocReturnTag().TypeExpression, fun) + fun.FunctionLikeData().Type = setHost(tag.AsJSDocReturnTag().TypeExpression, fun) } } case ast.KindJSDocReadonlyTag, ast.KindJSDocPrivateTag, ast.KindJSDocPublicTag, ast.KindJSDocProtectedTag, ast.KindJSDocOverrideTag: @@ -439,7 +507,7 @@ func (p *Parser) makeNewCast(t *ast.TypeNode, e *ast.Node, isAssertion bool) *as return assert } -func (p *Parser) makeNewType(typeExpression *ast.TypeNode, host *ast.Node) *ast.Node { +func setHost(typeExpression *ast.TypeNode, host *ast.Node) *ast.Node { if typeExpression == nil || typeExpression.Type() == nil { return nil } diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 4f9c719793..e0103fccae 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -1843,6 +1843,9 @@ func (p *Printer) emitTypeReference(node *ast.TypeReferenceNode) { // Emits the return type of a FunctionTypeNode or ConstructorTypeNode, including the arrow (`=>`) func (p *Printer) emitReturnType(node *ast.TypeNode) { + if node == nil { + return + } p.writePunctuation("=>") p.writeSpace() if p.inExtends && node.Kind == ast.KindInferType && node.AsInferTypeNode().TypeParameter.AsTypeParameter().Constraint != nil { diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt index b119782922..b812e341fb 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt @@ -2,9 +2,10 @@ index.js(2,28): error TS2304: Cannot find name 'B'. index.js(2,42): error TS2304: Cannot find name 'A'. index.js(2,48): error TS2304: Cannot find name 'B'. index.js(2,67): error TS2304: Cannot find name 'B'. +index.js(10,12): error TS2315: Type 'Funcs' is not generic. -==== index.js (4 errors) ==== +==== index.js (5 errors) ==== /** * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs ~ @@ -23,6 +24,8 @@ index.js(2,67): error TS2304: Cannot find name 'B'. * @template A * @template {Record} B * @param {Funcs} fns + ~~~~~~~~~~~ +!!! error TS2315: Type 'Funcs' is not generic. * @returns {[A, B]} */ function foo(fns) { diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types index 8f199e3acd..22ef6a0604 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types @@ -14,8 +14,8 @@ * @returns {[A, B]} */ function foo(fns) { ->foo : >(fns: { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; }) => [A, B] ->fns : { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; } +>foo : >(fns: any) => [A, B] +>fns : any return /** @type {any} */ (null); >(null) : any @@ -24,7 +24,7 @@ function foo(fns) { const result = foo({ >result : [unknown, Record] >foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : [unknown, Record] ->foo : >(fns: { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; }) => [A, B] +>foo : >(fns: any) => [A, B] >{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: string) => void; thing: string; }; } bar: { diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt index 1960cc42df..267621261d 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt @@ -1,15 +1,12 @@ -input.js(5,48): error TS2304: Cannot find name 'P'. input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== input.js (2 errors) ==== +==== input.js (1 errors) ==== /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** * @template P * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ - ~ -!!! error TS2304: Cannot find name 'P'. /** * @type {StatelessComponent} diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types index 8c306d3ccd..6b5aa2cc49 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.types @@ -11,19 +11,19 @@ * @type {StatelessComponent} */ const MyComponent = () => /* @type {any} */(null); ->MyComponent : { (): any; defaultProps?: P; } ->() => /* @type {any} */(null) : { (): any; defaultProps: { color: string; }; } +>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } +>() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; } >(null) : null MyComponent.defaultProps = { ->MyComponent.defaultProps = { color: "red"} : { color: string; } ->MyComponent.defaultProps : P ->MyComponent : { (): any; defaultProps?: P; } ->defaultProps : P ->{ color: "red"} : { color: string; } +>MyComponent.defaultProps = { color: "red"} : { color: "red"; } +>MyComponent.defaultProps : Partial<{ color: "blue" | "red"; }> +>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } +>defaultProps : Partial<{ color: "blue" | "red"; }> +>{ color: "red"} : { color: "red"; } color: "red" ->color : string +>color : "red" >"red" : "red" }; @@ -51,7 +51,7 @@ MyComponent2.defaultProps = { * @type {StatelessComponent} */ const check = MyComponent2; ->check : { (): any; defaultProps?: P; } +>check : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } >MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } /** diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types index 7932e4b495..ccf93fcc93 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types @@ -55,10 +55,10 @@ const identity = x => x; * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } +>flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } >array : unknown[] >iterable : (x: unknown) => unknown ->identity : (x: T_1) => T_1 +>identity : (x: T) => T /** @type {unknown[]} */ const result = []; diff --git a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types index ca429d9134..46595431a6 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileMethodOverloads2.types @@ -56,7 +56,7 @@ * @returns {unknown} */ transform(fn) { ->transform : { (fn: (y: T) => U): U; (): T; } +>transform : { (fn: (y: T) => U): U; (): T; } >fn : (y: T) => unknown return fn ? fn(this.value) : this.value; diff --git a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt index 79546958ff..b3a6719491 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsdocCallbackAndType.errors.txt @@ -1,4 +1,4 @@ -/a.js(5,12): error TS2304: Cannot find name 'B'. +/a.js(8,3): error TS2554: Expected 0 arguments, but got 1. ==== /a.js (1 errors) ==== @@ -7,9 +7,9 @@ * @callback B */ /** @type {B} */ - ~ -!!! error TS2304: Cannot find name 'B'. let b; b(); b(1); + ~ +!!! error TS2554: Expected 0 arguments, but got 1. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt b/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt deleted file mode 100644 index 9e2a2f66c8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -file1.js(3,21): error TS2304: Cannot find name 'T'. - - -==== file1.js (1 errors) ==== - /** - * @template {string} T - * @typedef {{ foo: T }} Foo - ~ -!!! error TS2304: Cannot find name 'T'. - */ - - export default {}; - -==== file2.js (0 errors) ==== - /** - * @template T - * @typedef {import('./file1').Foo} Bar - */ - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt index 18d3c442d6..edd678f512 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.errors.txt @@ -1,13 +1,12 @@ /a.js(21,14): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -/a.js(27,12): error TS2304: Cannot find name 'T1'. -/a.js(40,12): error TS2304: Cannot find name 'T2'. -/a.js(45,12): error TS2304: Cannot find name 'T3'. +/a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. + Type 'Promise' is not assignable to type 'string'. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (4 errors) ==== +==== /a.js (2 errors) ==== /** * @callback T1 * @param {string} str @@ -37,9 +36,10 @@ } /** @type {T1} */ - ~~ -!!! error TS2304: Cannot find name 'T1'. const f2 = async str => { + ~~ +!!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. +!!! error TS2322: Type 'Promise' is not assignable to type 'string'. return str; } @@ -52,15 +52,11 @@ } /** @type {T2} */ - ~~ -!!! error TS2304: Cannot find name 'T2'. const f4 = async str => { return str; } /** @type {T3} */ - ~~ -!!! error TS2304: Cannot find name 'T3'. const f5 = async str => { return str; } diff --git a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types index 3a95e08bd6..c23774926c 100644 --- a/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types +++ b/testdata/baselines/reference/submodule/conformance/asyncFunctionDeclaration16_es5.types @@ -40,11 +40,11 @@ const f1 = async str => { /** @type {T1} */ const f2 = async str => { >f2 : T1 ->async str => { return str;} : (str: any) => Promise ->str : any +>async str => { return str;} : (str: string) => Promise +>str : string return str; ->str : any +>str : string } /** @@ -63,20 +63,20 @@ const f3 = async str => { /** @type {T2} */ const f4 = async str => { >f4 : T2 ->async str => { return str;} : (str: any) => Promise ->str : any +>async str => { return str;} : (str: string) => Promise +>str : string return str; ->str : any +>str : string } /** @type {T3} */ const f5 = async str => { >f5 : T3 ->async str => { return str;} : (str: any) => Promise ->str : any +>async str => { return str;} : (str: string) => Promise +>str : string return str; ->str : any +>str : string } diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt index d1c4231be8..5a59e1a49e 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt @@ -1,12 +1,15 @@ +mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. -==== mod1.js (0 errors) ==== +==== mod1.js (1 errors) ==== /** @callback Con - some kind of continuation * @param {object | undefined} error * @return {any} I don't even know what this should return */ module.exports = C + ~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. function C() { this.p = 1 } diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt index 1ef41942a9..46a2b3efe8 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag1.errors.txt @@ -1,8 +1,7 @@ -cb.js(7,12): error TS2304: Cannot find name 'Sid'. cb.js(11,12): error TS2304: Cannot find name 'NoReturn'. -==== cb.js (2 errors) ==== +==== cb.js (1 errors) ==== /** @callback Sid * @param {string} s * @returns {string} What were you expecting @@ -10,8 +9,6 @@ cb.js(11,12): error TS2304: Cannot find name 'NoReturn'. var x = 1 /** @type {Sid} smallId */ - ~~~ -!!! error TS2304: Cannot find name 'Sid'. var sid = s => s + "!"; diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag1.types b/testdata/baselines/reference/submodule/conformance/callbackTag1.types index 43c91380f7..70dac8bf06 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag1.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag1.types @@ -12,10 +12,10 @@ var x = 1 /** @type {Sid} smallId */ var sid = s => s + "!"; >sid : Sid ->s => s + "!" : (s: any) => string ->s : any +>s => s + "!" : (s: string) => string +>s : string >s + "!" : string ->s : any +>s : string >"!" : "!" diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt index c1bec010f7..f011f90e35 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.errors.txt @@ -1,10 +1,8 @@ -cb.js(8,12): error TS2304: Cannot find name 'Id'. -cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. -cb.js(22,12): error TS2304: Cannot find name 'SharedId'. +cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. cb.js(25,12): error TS2304: Cannot find name 'Final'. -==== cb.js (4 errors) ==== +==== cb.js (2 errors) ==== /** @template T * @callback Id * @param {T} t @@ -13,8 +11,6 @@ cb.js(25,12): error TS2304: Cannot find name 'Final'. var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ - ~~ -!!! error TS2304: Cannot find name 'Id'. var one_twenty = s => "120"; /** @template S @@ -27,12 +23,10 @@ cb.js(25,12): error TS2304: Cannot find name 'Final'. /** @type {SharedId} */ this.id; ~~ -!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. +!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } /** @type {SharedId} */ - ~~~~~~~~ -!!! error TS2304: Cannot find name 'SharedId'. var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag2.types b/testdata/baselines/reference/submodule/conformance/callbackTag2.types index c6fb9fcc81..afdceb9570 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag2.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag2.types @@ -13,8 +13,8 @@ var x = 1 /** @type {Id} I actually wanted to write `const "120"` */ var one_twenty = s => "120"; >one_twenty : Id ->s => "120" : (s: any) => string ->s : any +>s => "120" : (s: string) => string +>s : string >"120" : "120" /** @template S @@ -23,7 +23,7 @@ var one_twenty = s => "120"; * @return {S} */ class SharedClass { ->SharedClass : SharedClass +>SharedClass : SharedClass constructor() { /** @type {SharedId} */ @@ -36,10 +36,10 @@ class SharedClass { /** @type {SharedId} */ var outside = n => n + 1; >outside : SharedId ->n => n + 1 : (n: any) => any ->n : any ->n + 1 : any ->n : any +>n => n + 1 : (n: number) => number +>n : number +>n + 1 : number +>n : number >1 : 1 /** @type {Final<{ fantasy }, { heroes }>} */ diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt deleted file mode 100644 index 0ea6446b4b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTag3.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -cb.js(4,12): error TS2304: Cannot find name 'Miracle'. - - -==== cb.js (1 errors) ==== - /** @callback Miracle - * @returns {string} What were you expecting - */ - /** @type {Miracle} smallId */ - ~~~~~~~ -!!! error TS2304: Cannot find name 'Miracle'. - var sid = () => "!"; - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt deleted file mode 100644 index 654e48ca41..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -a.js(9,12): error TS2304: Cannot find name 'C'. -a.js(10,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -a.js(10,25): error TS7006: Parameter 'b' implicitly has an 'any' type. -a.js(11,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - - -==== a.js (4 errors) ==== - /** - * @callback C - * @this {{ a: string, b: number }} - * @param {string} a - * @param {number} b - * @returns {boolean} - */ - - /** @type {C} */ - ~ -!!! error TS2304: Cannot find name 'C'. - const cb = function (a, b) { - ~ -!!! error TS7006: Parameter 'a' implicitly has an 'any' type. - ~ -!!! error TS7006: Parameter 'b' implicitly has an 'any' type. - this - ~~~~ -!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - return true - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols b/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols index 29354bb035..231ef8be6a 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols @@ -16,6 +16,9 @@ const cb = function (a, b) { >b : Symbol(b, Decl(a.js, 9, 23)) this +>this : Symbol(@this {{ a: string, b: number }} + * , Decl(a.js, 2, 3)) + return true } diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols.diff b/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols.diff index 1b2a5b9d18..45965ff9ec 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.symbols.diff @@ -13,6 +13,8 @@ this ->this : Symbol(this) -- ++>this : Symbol(@this {{ a: string, b: number }} ++ * , Decl(a.js, 2, 3)) + return true - } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTag4.types b/testdata/baselines/reference/submodule/conformance/callbackTag4.types index 5e7d68b92d..51f0c8ac25 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTag4.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTag4.types @@ -12,12 +12,12 @@ /** @type {C} */ const cb = function (a, b) { >cb : C ->function (a, b) { this return true} : (a: any, b: any) => boolean ->a : any ->b : any +>function (a, b) { this return true} : (this: { a: string; b: number; }, a: string, b: number) => true +>a : string +>b : number this ->this : any +>this : { a: string; b: number; } return true >true : true diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt deleted file mode 100644 index fa694a91df..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -cb_nested.js(11,12): error TS2304: Cannot find name 'WorksWithPeopleCallback'. - - -==== cb_nested.js (1 errors) ==== - /** - * @callback WorksWithPeopleCallback - * @param {Object} person - * @param {string} person.name - * @param {number} [person.age] - * @returns {void} - */ - - /** - * For each person, calls your callback. - * @param {WorksWithPeopleCallback} callback - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'WorksWithPeopleCallback'. - * @returns {void} - */ - function eachPerson(callback) { - callback({ name: "Empty" }); - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types index f51212f4e6..1ab84666b7 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.types @@ -19,7 +19,7 @@ function eachPerson(callback) { >callback : WorksWithPeopleCallback callback({ name: "Empty" }); ->callback({ name: "Empty" }) : any +>callback({ name: "Empty" }) : void >callback : WorksWithPeopleCallback >{ name: "Empty" } : { name: string; } >name : string diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt index 79b28e665e..b6e60aa623 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.errors.txt @@ -1,4 +1,4 @@ -callbackTagVariadicType.js(7,12): error TS2304: Cannot find name 'Foo'. +callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. ==== callbackTagVariadicType.js (1 errors) ==== @@ -9,8 +9,8 @@ callbackTagVariadicType.js(7,12): error TS2304: Cannot find name 'Foo'. */ /** @type {Foo} */ - ~~~ -!!! error TS2304: Cannot find name 'Foo'. export const x = () => 1 var res = x('a', 'b') + ~~~ +!!! error TS2554: Expected 1 arguments, but got 2. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types index a80d7af3a7..a19532cb4f 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types +++ b/testdata/baselines/reference/submodule/conformance/callbackTagVariadicType.types @@ -14,8 +14,8 @@ export const x = () => 1 >1 : 1 var res = x('a', 'b') ->res : any ->x('a', 'b') : any +>res : number +>x('a', 'b') : number >x : Foo >'a' : "a" >'b' : "b" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt index 1120047dc2..6735c424bd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.errors.txt @@ -1,4 +1,3 @@ -test.js(3,19): error TS2304: Cannot find name 'U'. test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. @@ -6,12 +5,10 @@ test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'stri ==== t.d.ts (0 errors) ==== type A = { a: T } -==== test.js (3 errors) ==== +==== test.js (2 errors) ==== /** Also should error for jsdoc typedefs * @template {string} U * @typedef {{ b: U }} B - ~ -!!! error TS2304: Cannot find name 'U'. */ /** @type {A} */ ~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types index 5004b47a1a..ac41a8e0d4 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypeTag4.types @@ -16,5 +16,5 @@ var a; /** @type {B} */ var b; ->b : { b: U; } +>b : { b: number; } diff --git a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt index 35cf4728a3..ba00327c67 100644 --- a/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/errorOnFunctionReturnType.errors.txt @@ -1,5 +1,7 @@ -foo.js(20,12): error TS2304: Cannot find name 'FunctionReturningPromise'. -foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. +foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. + Type 'void' is not assignable to type 'Promise'. +foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. + Type 'void' is not assignable to type 'never'. ==== foo.js (2 errors) ==== @@ -23,9 +25,10 @@ foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. } /** @type {FunctionReturningPromise} */ - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'FunctionReturningPromise'. var testPromise4 = function() { + ~~~~~~~~~~~~ +!!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. +!!! error TS2322: Type 'void' is not assignable to type 'Promise'. console.log("test") } @@ -49,8 +52,9 @@ foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. } /** @type {FunctionReturningNever} */ - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'FunctionReturningNever'. var testNever4 = function() { + ~~~~~~~~~~ +!!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. +!!! error TS2322: Type 'void' is not assignable to type 'never'. console.log("test") } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt deleted file mode 100644 index f346a8c3e3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -instantiateTemplateTagTypeParameterOnVariableStatement.js(12,5): error TS2322: Type 'T' is not assignable to type 'string'. -instantiateTemplateTagTypeParameterOnVariableStatement.js(12,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. - - -==== instantiateTemplateTagTypeParameterOnVariableStatement.js (2 errors) ==== - /** - * @template T - * @param {T} a - * @returns {(b: T) => T} - */ - const seq = a => b => b; - - const text1 = "hello"; - const text2 = "world"; - - /** @type {string} */ - var text3 = seq(text1)(text2); - ~~~~~ -!!! error TS2322: Type 'T' is not assignable to type 'string'. -!!! related TS2208 instantiateTemplateTagTypeParameterOnVariableStatement.js:2:14: This type parameter might need an `extends string` constraint. - ~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types index 3c17660135..72bbe8f04d 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types +++ b/testdata/baselines/reference/submodule/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types @@ -25,8 +25,8 @@ const text2 = "world"; /** @type {string} */ var text3 = seq(text1)(text2); >text3 : string ->seq(text1)(text2) : T ->seq(text1) : (b: T) => T +>seq(text1)(text2) : string +>seq(text1) : (b: string) => string >seq : (a: T) => (b: T) => T >text1 : "hello" >text2 : "world" diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt index eb9ed27e87..810b53ae05 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt @@ -1,5 +1,6 @@ base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? +file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? ==== base.js (1 errors) ==== @@ -17,13 +18,15 @@ file.js(1,15): error TS1340: Module './base' does not refer to a type, but is us ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== file.js (1 errors) ==== +==== file.js (2 errors) ==== /** @typedef {import('./base')} BaseFactory */ ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? /** * @callback BaseFactoryFactory * @param {import('./base')} factory + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? */ /** @enum {import('./base')} */ const couldntThinkOfAny = {} diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt deleted file mode 100644 index 7c1013c965..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction.errors.txt +++ /dev/null @@ -1,34 +0,0 @@ -templateTagOnConstructorFunctions.js(3,18): error TS2304: Cannot find name 'U'. -templateTagOnConstructorFunctions.js(3,24): error TS2304: Cannot find name 'U'. - - -==== templateTagOnConstructorFunctions.js (2 errors) ==== - /** - * @template U - * @typedef {(u: U) => U} Id - ~ -!!! error TS2304: Cannot find name 'U'. - ~ -!!! error TS2304: Cannot find name 'U'. - */ - /** - * @param {T} t - * @template T - */ - function Zet(t) { - /** @type {T} */ - this.u - this.t = t - } - /** - * @param {T} v - * @param {Id} id - */ - Zet.prototype.add = function(v, id) { - this.u = v || this.t - return id(this.u) - } - var z = new Zet(1) - z.t = 2 - z.u = false - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt index f503b09c3b..acd63b1e17 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.errors.txt @@ -1,7 +1,9 @@ +a.js(14,29): error TS2339: Property 'a' does not exist on type 'U'. +a.js(14,35): error TS2339: Property 'b' does not exist on type 'U'. a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -==== a.js (1 errors) ==== +==== a.js (3 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? @@ -16,6 +18,10 @@ a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but r */ function f(t, u, v, w, x) { if(t.a + t.b.length > u.a - u.b.length && v.c) { + ~ +!!! error TS2339: Property 'a' does not exist on type 'U'. + ~ +!!! error TS2339: Property 'b' does not exist on type 'U'. return w; } return x; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols index 4488412bdb..9e581c8ac1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols @@ -30,14 +30,8 @@ function f(t, u, v, w, x) { >t : Symbol(t, Decl(a.js, 12, 11)) >b : Symbol(b, Decl(a.js, 1, 26)) >length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ->u.a : Symbol(a, Decl(a.js, 1, 15)) >u : Symbol(u, Decl(a.js, 12, 13)) ->a : Symbol(a, Decl(a.js, 1, 15)) ->u.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ->u.b : Symbol(b, Decl(a.js, 1, 26)) >u : Symbol(u, Decl(a.js, 12, 13)) ->b : Symbol(b, Decl(a.js, 1, 26)) ->length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >v.c : Symbol(c, Decl(a.js, 2, 15)) >v : Symbol(v, Decl(a.js, 12, 16)) >c : Symbol(c, Decl(a.js, 2, 15)) diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff index d50b29b8fc..c16a1f47f6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.symbols.diff @@ -10,17 +10,7 @@ >t : Symbol(t, Decl(a.js, 12, 11)) >b : Symbol(b, Decl(a.js, 1, 26)) ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) -->u : Symbol(u, Decl(a.js, 12, 13)) -->u : Symbol(u, Decl(a.js, 12, 13)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) -+>u.a : Symbol(a, Decl(a.js, 1, 15)) -+>u : Symbol(u, Decl(a.js, 12, 13)) -+>a : Symbol(a, Decl(a.js, 1, 15)) -+>u.b.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) -+>u.b : Symbol(b, Decl(a.js, 1, 26)) -+>u : Symbol(u, Decl(a.js, 12, 13)) -+>b : Symbol(b, Decl(a.js, 1, 26)) -+>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) - >v.c : Symbol(c, Decl(a.js, 2, 15)) - >v : Symbol(v, Decl(a.js, 12, 16)) - >c : Symbol(c, Decl(a.js, 2, 15)) \ No newline at end of file + >u : Symbol(u, Decl(a.js, 12, 13)) + >u : Symbol(u, Decl(a.js, 12, 13)) + >v.c : Symbol(c, Decl(a.js, 2, 15)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types index 5d9b438876..a8dd23bfab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag3.types @@ -14,7 +14,7 @@ * @return {W | X} */ function f(t, u, v, w, x) { ->f : (t: T, u: U, v: V, w: W, x: X) => W | X +>f : (t: T, u: U, v: V, w: W, x: X) => W | X >t : T >u : U >v : V @@ -34,14 +34,14 @@ function f(t, u, v, w, x) { >b : string >length : number >u.a - u.b.length : number ->u.a : number +>u.a : any >u : U ->a : number ->u.b.length : number ->u.b : string +>a : any +>u.b.length : any +>u.b : any >u : U ->b : string ->length : number +>b : any +>length : any >v.c : boolean >v : V >c : boolean @@ -55,7 +55,7 @@ function f(t, u, v, w, x) { f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); >f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : "nope" | 101 ->f : (t: T, u: U, v: V, w: W, x: X) => W | X +>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12, b: 'hi', c: null } : { a: number; b: string; c: null; } >a : number >12 : 12 @@ -75,7 +75,7 @@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101 f({ a: 12 }, undefined, undefined, 101, 'nope'); >f({ a: 12 }, undefined, undefined, 101, 'nope') : "nope" | 101 ->f : (t: T, u: U, v: V, w: W, x: X) => W | X +>f : (t: T, u: U, v: V, w: W, x: X) => W | X >{ a: 12 } : { a: number; } >a : number >12 : 12 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt new file mode 100644 index 0000000000..7dc6690cfb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag6.errors.txt @@ -0,0 +1,112 @@ +a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(14,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(26,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(37,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(48,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(59,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(68,18): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + + +==== a.js (7 errors) ==== + /** + * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {T} x + * @returns {T} + */ + function f1(x) { + return x; + } + const t1 = f1("a"); + const t2 = f1(["a", ["b", "c"]]); + const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); + + /** + * @template const T, U + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {T} x + * @returns {T} + */ + function f2(x) { + return x; + }; + const t4 = f2('a'); + const t5 = f2(['a', ['b', 'c']]); + const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); + + /** + * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {T} x + * @returns {T[]} + */ + function f3(x) { + return [x]; + } + const t7 = f3("hello"); + const t8 = f3("hello"); + + /** + * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {[T, T]} x + * @returns {T} + */ + function f4(x) { + return x[0]; + } + const t9 = f4([[1, "x"], [2, "y"]]); + const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); + + /** + * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {{ x: T, y: T}} obj + * @returns {T} + */ + function f5(obj) { + return obj.x; + } + const t11 = f5({ x: [1, "x"], y: [2, "y"] }); + const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); + + /** + * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + */ + class C { + /** + * @param {T} x + */ + constructor(x) {} + + /** + * @template const U + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + * @param {U} x + */ + foo(x) { + return x; + } + } + + const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); + const t14 = t13.foo(["a", ["b", "c"]]); + + /** + * @template {readonly unknown[]} const T + * @param {T} args + * @returns {T} + */ + function f6(...args) { + return args; + } + const t15 = f6(1, 'b', { a: 1, b: 'x' }); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt index 6d5770242e..dcc4c36af3 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag7.errors.txt @@ -1,8 +1,9 @@ a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class +a.js(7,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter -==== a.js (2 errors) ==== +==== a.js (3 errors) ==== /** * @template const T ~~~~~ @@ -12,6 +13,8 @@ a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter /** * @template const T + ~~~~~ +!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class */ class C { } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt index ae538f84f5..6ad768a099 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.errors.txt @@ -1,34 +1,22 @@ -file.js(3,15): error TS2304: Cannot find name 'T'. -file.js(17,17): error TS2304: Cannot find name 'T'. -file.js(18,15): error TS2304: Cannot find name 'T'. -file.js(18,18): error TS2304: Cannot find name 'U'. -file.js(23,15): error TS2304: Cannot find name 'T'. -file.js(28,15): error TS2304: Cannot find name 'T'. +file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. file.js(33,14): error TS2706: Required type parameters may not follow optional type parameters. -file.js(34,15): error TS2304: Cannot find name 'T'. -file.js(34,18): error TS2304: Cannot find name 'U'. -file.js(38,17): error TS2304: Cannot find name 'U'. -file.js(39,17): error TS2304: Cannot find name 'T'. -file.js(40,15): error TS2304: Cannot find name 'T'. -file.js(40,18): error TS2304: Cannot find name 'U'. -file.js(45,17): error TS2304: Cannot find name 'T'. +file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. -file.js(60,17): error TS2304: Cannot find name 'U'. -file.js(61,17): error TS2304: Cannot find name 'T'. +file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -==== file.js (17 errors) ==== +==== file.js (5 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A - ~ -!!! error TS2304: Cannot find name 'T'. */ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; /** @type {A} */ // ok, `T` is provided for `A` @@ -37,27 +25,17 @@ file.js(61,17): error TS2304: Cannot find name 'T'. /** * @template T * @template [U=T] - ok: default can reference earlier type parameter - ~ -!!! error TS2304: Cannot find name 'T'. * @typedef {[T, U]} B - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'U'. */ /** * @template {string | number} [T] - error: default requires an `=type` * @typedef {[T]} C - ~ -!!! error TS2304: Cannot find name 'T'. */ /** * @template {string | number} [T=] - error: default requires a `type` * @typedef {[T]} D - ~ -!!! error TS2304: Cannot find name 'T'. */ /** @@ -66,31 +44,19 @@ file.js(61,17): error TS2304: Cannot find name 'T'. ~ !!! error TS2706: Required type parameters may not follow optional type parameters. * @typedef {[T, U]} E - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'U'. */ /** * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. ~ -!!! error TS2304: Cannot find name 'U'. +!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. * @template [U=T] - ~ -!!! error TS2304: Cannot find name 'T'. * @typedef {[T, U]} G - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'U'. */ /** * @template T * @template [U=T] - ok: default can reference earlier type parameter - ~ -!!! error TS2304: Cannot find name 'T'. * @param {T} a * @param {U} b */ @@ -109,10 +75,8 @@ file.js(61,17): error TS2304: Cannot find name 'T'. /** * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. ~ -!!! error TS2304: Cannot find name 'U'. +!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. * @template [U=T] - ~ -!!! error TS2304: Cannot find name 'T'. * @param {T} a * @param {U} b */ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types index 00903619bd..33c2ea62d1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagDefault.types @@ -8,25 +8,25 @@ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; ->aDefault1 : [T] +>aDefault1 : [string] >[""] : [string] >"" : "" /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; ->aDefault2 : [T] +>aDefault2 : [string] >[0] : [number] >0 : 0 /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; ->aString : [T] +>aString : [string] >[""] : [string] >"" : "" /** @type {A} */ // ok, `T` is provided for `A` const aNumber = [0]; ->aNumber : [T] +>aNumber : [number] >[0] : [number] >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt index 5aa1f20558..64df35ea66 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.errors.txt @@ -1,22 +1,16 @@ -file.js(3,21): error TS2304: Cannot find name 'T'. -file.js(4,14): error TS2304: Cannot find name 'T'. -file.js(4,16): error TS2304: Cannot find name 'K'. +file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. -==== file.js (3 errors) ==== +==== file.js (1 errors) ==== /** * @template T * @template {keyof T} K - ~ -!!! error TS2304: Cannot find name 'T'. * @typedef {T[K]} Foo - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'K'. */ const x = { a: 1 }; /** @type {Foo} */ - const y = "a"; \ No newline at end of file + const y = "a"; + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types index 5d05ab34ac..4c85f4f3fc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTagNameResolution.types @@ -15,6 +15,6 @@ const x = { a: 1 }; /** @type {Foo} */ const y = "a"; ->y : T +>y : number >"a" : "a" diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt index b1b00c3e37..3fcc55219f 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.errors.txt @@ -1,18 +1,10 @@ bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. -bug39372.js(9,17): error TS2304: Cannot find name 'T'. -bug39372.js(9,32): error TS2304: Cannot find name 'T'. -bug39372.js(12,17): error TS2304: Cannot find name 'T'. -bug39372.js(14,10): error TS2304: Cannot find name 'T'. -bug39372.js(14,55): error TS2304: Cannot find name 'T'. -bug39372.js(18,15): error TS2304: Cannot find name 'T'. -bug39372.js(19,5): error TS2304: Cannot find name 'T'. -bug39372.js(20,19): error TS2304: Cannot find name 'T'. -bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; }'. - Type '{}' is missing the following properties from type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; }': $A, $O +bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. + Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -==== bug39372.js (11 errors) ==== +==== bug39372.js (3 errors) ==== /** @typedef {ReadonlyArray} JsonArray */ ~~~~~~~~~ !!! error TS2456: Type alias 'JsonArray' circularly references itself. @@ -26,39 +18,23 @@ bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { [x * @typedef {{ $A: { [K in keyof T]?: XMLObject[] - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'T'. }, $O: { [K in keyof T]?: { - ~ -!!! error TS2304: Cannot find name 'T'. $$?: Record } & (T[K] extends string ? {$:string} : XMLObject) - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'T'. }, $$?: Record, } & { [K in keyof T]?: ( - ~ -!!! error TS2304: Cannot find name 'T'. T[K] extends string ? string - ~ -!!! error TS2304: Cannot find name 'T'. : XMLObject - ~ -!!! error TS2304: Cannot find name 'T'. ) }} XMLObject */ /** @type {XMLObject<{foo:string}>} */ const p = {}; ~ -!!! error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; }'. -!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; }': $A, $O +!!! error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. +!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types index 9fdf08e13f..13e0bb4968 100644 --- a/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types +++ b/testdata/baselines/reference/submodule/conformance/recursiveTypeReferences2.types @@ -26,6 +26,6 @@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ->p : { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; } +>p : { $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; } >{} : {} diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt index 4c695adbe3..48940af384 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.errors.txt @@ -1,4 +1,4 @@ -templateInsideCallback.js(15,11): error TS2304: Cannot find name 'Call'. +templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. templateInsideCallback.js(29,5): error TS7012: This overload implicitly returns the type 'any' because it lacks a return type annotation. @@ -21,8 +21,8 @@ templateInsideCallback.js(37,5): error TS7012: This overload implicitly returns /** * @template T * @type {Call} - ~~~~ -!!! error TS2304: Cannot find name 'Call'. + ~~~~~~~ +!!! error TS2315: Type 'Call' is not generic. ~ !!! error TS2304: Cannot find name 'T'. */ diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types index ad48fc800f..c3d8c4e306 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types @@ -18,7 +18,7 @@ * @type {Call} */ const identity = x => x; ->identity : Call +>identity : any >x => x : (x: any) => any >x : any >x : any @@ -52,10 +52,10 @@ const identity = x => x; * @returns {unknown[]} */ function flatMap(array, iterable = identity) { ->flatMap : { (): any; (): any; } +>flatMap : { (): any; (): any; } >array : unknown[] >iterable : (x: unknown) => unknown ->identity : Call +>identity : any /** @type {unknown[]} */ const result = []; diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt index 71b0b2cce5..6104c81d3a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.errors.txt @@ -1,14 +1,14 @@ -typeTagNoErasure.js(1,39): error TS2304: Cannot find name 'T'. +typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. ==== typeTagNoErasure.js (1 errors) ==== /** @template T @typedef {(data: T1) => T1} Test */ - ~ -!!! error TS2304: Cannot find name 'T'. /** @type {Test} */ const test = dibbity => dibbity test(1) // ok, T=1 test('hi') // error, T=number + ~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types index ef248f206c..4ed98d54bc 100644 --- a/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types +++ b/testdata/baselines/reference/submodule/conformance/typeTagNoErasure.types @@ -5,18 +5,18 @@ /** @type {Test} */ const test = dibbity => dibbity ->test : (data: T1) => T1 ->dibbity => dibbity : (dibbity: T1) => T1 +>test : (data: T1) => T1 +>dibbity => dibbity : (dibbity: T1) => T1 >dibbity : T1 >dibbity : T1 test(1) // ok, T=1 >test(1) : 1 ->test : (data: T1) => T1 +>test : (data: T1) => T1 >1 : 1 test('hi') // error, T=number ->test('hi') : "hi" ->test : (data: T1) => T1 +>test('hi') : number +>test : (data: T1) => T1 >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt index 5570c99ce3..430e0df3e9 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.errors.txt @@ -1,30 +1,15 @@ -a.js(6,19): error TS2304: Cannot find name 'T'. -a.js(6,25): error TS2304: Cannot find name 'U'. -a.js(6,31): error TS2304: Cannot find name 'V'. -a.js(6,37): error TS2304: Cannot find name 'W'. -a.js(6,43): error TS2304: Cannot find name 'X'. a.js(12,23): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. a.js(15,12): error TS2314: Generic type 'Everything' requires 5 type argument(s). test.ts(1,23): error TS2304: Cannot find name 'Everything'. -==== a.js (7 errors) ==== +==== a.js (2 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? * @template W * @template X That last one had no comment * @typedef {{ t: T, u: U, v: V, w: W, x: X }} Everything - ~ -!!! error TS2304: Cannot find name 'T'. - ~ -!!! error TS2304: Cannot find name 'U'. - ~ -!!! error TS2304: Cannot find name 'V'. - ~ -!!! error TS2304: Cannot find name 'W'. - ~ -!!! error TS2304: Cannot find name 'X'. */ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ diff --git a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types index 34308527f8..4da165b585 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types +++ b/testdata/baselines/reference/submodule/conformance/typedefMultipleTypeParameters.types @@ -11,11 +11,11 @@ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; ->tuvwx : { t: T; u: U; v: V; w: W; x: X; } +>tuvwx : { t: { a: number; b: "hi"; c: never; }; u: undefined; v: { c: true; d: 1; }; w: number; x: string; } /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; ->wrong : { t: T; u: U; v: V; w: W; x: X; } +>wrong : { t: { a: number; }; u: undefined; v: { c: 1; d: 1; }; w: number; x: string; } /** @type {Everything<{ a: number }>} */ var insufficient; diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt index 8d39add592..3372ce2456 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.errors.txt @@ -1,5 +1,5 @@ github20832.js(2,15): error TS2304: Cannot find name 'U'. -github20832.js(26,12): error TS2304: Cannot find name 'Cb'. +github20832.js(17,12): error TS2304: Cannot find name 'V'. ==== github20832.js (2 errors) ==== @@ -22,6 +22,8 @@ github20832.js(26,12): error TS2304: Cannot find name 'Cb'. /** * @callback Cb * @param {V} firstParam + ~ +!!! error TS2304: Cannot find name 'V'. */ /** * @template V @@ -31,7 +33,5 @@ github20832.js(26,12): error TS2304: Cannot find name 'Cb'. } /** @type {Cb} */ - ~~ -!!! error TS2304: Cannot find name 'Cb'. const cb = x => {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types index 7261c71574..81e8c54752 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagTypeResolution.types @@ -37,6 +37,6 @@ function g(vvvvv) { /** @type {Cb} */ const cb = x => {} >cb : Cb ->x => {} : (x: any) => void ->x : any +>x => {} : (x: V) => void +>x : V diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff index 54d0a0203a..24a1d9bbd3 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.errors.txt.diff @@ -6,9 +6,10 @@ +index.js(2,42): error TS2304: Cannot find name 'A'. +index.js(2,48): error TS2304: Cannot find name 'B'. +index.js(2,67): error TS2304: Cannot find name 'B'. ++index.js(10,12): error TS2315: Type 'Funcs' is not generic. + + -+==== index.js (4 errors) ==== ++==== index.js (5 errors) ==== + /** + * @typedef {{ [K in keyof B]: { fn: (a: A, b: B) => void; thing: B[K]; } }} Funcs + ~ @@ -27,6 +28,8 @@ + * @template A + * @template {Record} B + * @param {Funcs} fns ++ ~~~~~~~~~~~ ++!!! error TS2315: Type 'Funcs' is not generic. + * @returns {[A, B]} + */ + function foo(fns) { diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff index e1e77fd2e1..477ca60070 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff @@ -6,8 +6,8 @@ function foo(fns) { ->foo : >(fns: Funcs) => [A, B] ->fns : Funcs -+>foo : >(fns: { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; }) => [A, B] -+>fns : { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; } ++>foo : >(fns: any) => [A, B] ++>fns : any return /** @type {any} */ (null); >(null) : any @@ -19,7 +19,7 @@ ->foo : >(fns: Funcs) => [A, B] +>result : [unknown, Record] +>foo({ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },}) : [unknown, Record] -+>foo : >(fns: { [x: string]: { fn: (a: A, b: B) => void; thing: B; }; }) => [A, B] ++>foo : >(fns: any) => [A, B] >{ bar: { fn: /** @param {string} a */ (a) => {}, thing: "asd", },} : { bar: { fn: (a: string) => void; thing: string; }; } bar: { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff index da567cd68b..6569dcf3a6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff @@ -2,18 +2,15 @@ +++ new.expandoFunctionContextualTypesJs.errors.txt @@= skipped -0, +0 lines =@@ - -+input.js(5,48): error TS2304: Cannot find name 'P'. +input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== input.js (2 errors) ==== ++==== input.js (1 errors) ==== + /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + + /** + * @template P + * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ -+ ~ -+!!! error TS2304: Cannot find name 'P'. + + /** + * @type {StatelessComponent} diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff index 3e5d73d956..bf6224e8ee 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.types.diff @@ -6,27 +6,22 @@ const MyComponent = () => /* @type {any} */(null); ->MyComponent : StatelessComponent ->() => /* @type {any} */(null) : { (): any; defaultProps: Partial; } -+>MyComponent : { (): any; defaultProps?: P; } -+>() => /* @type {any} */(null) : { (): any; defaultProps: { color: string; }; } ++>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } ++>() => /* @type {any} */(null) : { (): any; defaultProps: { color: "red"; }; } >(null) : null MyComponent.defaultProps = { -->MyComponent.defaultProps = { color: "red"} : { color: "red"; } + >MyComponent.defaultProps = { color: "red"} : { color: "red"; } ->MyComponent.defaultProps : Partial ->MyComponent : StatelessComponent ->defaultProps : Partial -->{ color: "red"} : { color: "red"; } -+>MyComponent.defaultProps = { color: "red"} : { color: string; } -+>MyComponent.defaultProps : P -+>MyComponent : { (): any; defaultProps?: P; } -+>defaultProps : P -+>{ color: "red"} : { color: string; } ++>MyComponent.defaultProps : Partial<{ color: "blue" | "red"; }> ++>MyComponent : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } ++>defaultProps : Partial<{ color: "blue" | "red"; }> + >{ color: "red"} : { color: "red"; } color: "red" -->color : "red" -+>color : string - >"red" : "red" - +@@= skipped -18, +18 lines =@@ }; const MyComponent2 = () => null; @@ -49,13 +44,13 @@ >{ color: "red"} : { color: "red"; } color: "red" -@@= skipped -40, +40 lines =@@ +@@= skipped -22, +22 lines =@@ * @type {StatelessComponent} */ const check = MyComponent2; ->check : StatelessComponent ->MyComponent2 : { (): any; defaultProps: MyComponentProps; } -+>check : { (): any; defaultProps?: P; } ++>check : { (): any; defaultProps?: Partial<{ color: "blue" | "red"; }>; } +>MyComponent2 : { (): any; defaultProps: { color: "blue" | "red"; }; } /** diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff new file mode 100644 index 0000000000..fd4bb23a14 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff @@ -0,0 +1,15 @@ +--- old.jsFileFunctionOverloads2.types ++++ new.jsFileFunctionOverloads2.types +@@= skipped -54, +54 lines =@@ + * @returns {unknown[]} + */ + function flatMap(array, iterable = identity) { +->flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } ++>flatMap : { (array: T[], iterable: (x: T) => U[]): U[]; (array: T[][]): T[]; } + >array : unknown[] + >iterable : (x: unknown) => unknown +->identity : (x: T_1) => T_1 ++>identity : (x: T) => T + + /** @type {unknown[]} */ + const result = []; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff index 898c7c1668..6f1b9f6984 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileMethodOverloads2.types.diff @@ -17,7 +17,7 @@ */ transform(fn) { ->transform : { (fn: (y: T) => U): U; (): T; } -+>transform : { (fn: (y: T) => U): U; (): T; } ++>transform : { (fn: (y: T) => U): U; (): T; } >fn : (y: T) => unknown return fn ? fn(this.value) : this.value; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff deleted file mode 100644 index 5fb54d024c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocCallbackAndType.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.jsdocCallbackAndType.errors.txt -+++ new.jsdocCallbackAndType.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(8,3): error TS2554: Expected 0 arguments, but got 1. -+/a.js(5,12): error TS2304: Cannot find name 'B'. - - - ==== /a.js (1 errors) ==== -@@= skipped -6, +6 lines =@@ - * @callback B - */ - /** @type {B} */ -+ ~ -+!!! error TS2304: Cannot find name 'B'. - let b; - b(); - b(1); -- ~ --!!! error TS2554: Expected 0 arguments, but got 1. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff index 1b23f849fb..c9d3ac59df 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/unmetTypeConstraintInJSDocImportCall.errors.txt.diff @@ -5,26 +5,20 @@ - - -==== file1.js (0 errors) ==== -+file1.js(3,21): error TS2304: Cannot find name 'T'. -+ -+ -+==== file1.js (1 errors) ==== - /** - * @template {string} T - * @typedef {{ foo: T }} Foo -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - - export default {}; - +- /** +- * @template {string} T +- * @typedef {{ foo: T }} Foo +- */ +- +- export default {}; +- -==== file2.js (1 errors) ==== -+==== file2.js (0 errors) ==== - /** - * @template T - * @typedef {import('./file1').Foo} Bar +- /** +- * @template T +- * @typedef {import('./file1').Foo} Bar - ~ -!!! error TS2344: Type 'T' does not satisfy the constraint 'string'. -!!! related TS2208 file2.js:2:14: This type parameter might need an `extends string` constraint. - */ - \ No newline at end of file +- */ +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff index a6e3de196a..5a82cdee21 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.errors.txt.diff @@ -9,20 +9,19 @@ - The types returned by 'then(...)' are incompatible between these types. - Type 'void' is not assignable to type 'PromiseLike'. +/a.js(21,14): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? -+/a.js(27,12): error TS2304: Cannot find name 'T1'. -+/a.js(40,12): error TS2304: Cannot find name 'T2'. -+/a.js(45,12): error TS2304: Cannot find name 'T3'. ++/a.js(28,7): error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. ++ Type 'Promise' is not assignable to type 'string'. ==== /types.d.ts (0 errors) ==== declare class Thenable { then(): void; } -==== /a.js (3 errors) ==== -+==== /a.js (4 errors) ==== ++==== /a.js (2 errors) ==== /** * @callback T1 * @param {string} str -@@= skipped -32, +29 lines =@@ +@@= skipped -32, +28 lines =@@ * @param {string} str * @returns {string} ~~~~~~ @@ -31,34 +30,29 @@ */ const f1 = async str => { return str; -@@= skipped -8, +8 lines =@@ + } /** @type {T1} */ - ~~ +- ~~ -!!! error TS1065: The return type of an async function or method must be the global Promise type. -!!! related TS1055 /a.js:4:14: Type 'string' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -+!!! error TS2304: Cannot find name 'T1'. const f2 = async str => { ++ ~~ ++!!! error TS2322: Type '(str: string) => Promise' is not assignable to type 'T1'. ++!!! error TS2322: Type 'Promise' is not assignable to type 'string'. return str; } -@@= skipped -15, +14 lines =@@ - } - /** @type {T2} */ -+ ~~ -+!!! error TS2304: Cannot find name 'T2'. - const f4 = async str => { - return str; +@@= skipped -28, +28 lines =@@ } /** @type {T3} */ - ~~ +- ~~ -!!! error TS1065: The return type of an async function or method must be the global Promise type. -!!! error TS1065: Type 'typeof Thenable' is not a valid async function return type in ES5 because it does not refer to a Promise-compatible constructor value. -!!! error TS1065: Construct signature return types 'Thenable' and 'PromiseLike' are incompatible. -!!! error TS1065: The types returned by 'then(...)' are incompatible between these types. -!!! error TS1065: Type 'void' is not assignable to type 'PromiseLike'. -+!!! error TS2304: Cannot find name 'T3'. const f5 = async str => { return str; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff index 29c905826e..f2b0c3bdee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/asyncFunctionDeclaration16_es5.types.diff @@ -5,39 +5,16 @@ const f2 = async str => { >f2 : T1 ->async str => { return str;} : (str: string) => string -->str : string -+>async str => { return str;} : (str: any) => Promise -+>str : any ++>async str => { return str;} : (str: string) => Promise + >str : string return str; -->str : string -+>str : any - } - - /** -@@= skipped -23, +23 lines =@@ - /** @type {T2} */ - const f4 = async str => { - >f4 : T2 -->async str => { return str;} : (str: string) => Promise -->str : string -+>async str => { return str;} : (str: any) => Promise -+>str : any - - return str; -->str : string -+>str : any - } - +@@= skipped -33, +33 lines =@@ /** @type {T3} */ const f5 = async str => { >f5 : T3 ->async str => { return str;} : (str: string) => Thenable -->str : string -+>async str => { return str;} : (str: any) => Promise -+>str : any ++>async str => { return str;} : (str: string) => Promise + >str : string - return str; -->str : string -+>str : any - } + return str; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff index 7e0b3df97e..b3e507b55d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff @@ -2,15 +2,18 @@ +++ new.callbackCrossModule.errors.txt @@= skipped -0, +0 lines =@@ - ++mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. + + -+==== mod1.js (0 errors) ==== ++==== mod1.js (1 errors) ==== + /** @callback Con - some kind of continuation + * @param {object | undefined} error + * @return {any} I don't even know what this should return + */ + module.exports = C ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + function C() { + this.p = 1 + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff index e528658544..032097ac51 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.errors.txt.diff @@ -2,11 +2,10 @@ +++ new.callbackTag1.errors.txt @@= skipped -0, +0 lines =@@ - -+cb.js(7,12): error TS2304: Cannot find name 'Sid'. +cb.js(11,12): error TS2304: Cannot find name 'NoReturn'. + + -+==== cb.js (2 errors) ==== ++==== cb.js (1 errors) ==== + /** @callback Sid + * @param {string} s + * @returns {string} What were you expecting @@ -14,8 +13,6 @@ + var x = 1 + + /** @type {Sid} smallId */ -+ ~~~ -+!!! error TS2304: Cannot find name 'Sid'. + var sid = s => s + "!"; + + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff index 9e296cb641..18401abc49 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag1.types.diff @@ -1,19 +1,6 @@ --- old.callbackTag1.types +++ new.callbackTag1.types -@@= skipped -11, +11 lines =@@ - /** @type {Sid} smallId */ - var sid = s => s + "!"; - >sid : Sid -->s => s + "!" : (s: string) => string -->s : string -+>s => s + "!" : (s: any) => string -+>s : any - >s + "!" : string -->s : string -+>s : any - >"!" : "!" - - +@@= skipped -21, +21 lines =@@ /** @type {NoReturn} */ var noreturn = obj => void obj.title >noreturn : NoReturn diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff index aa6969cc49..c8b92dbd79 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.errors.txt.diff @@ -5,26 +5,15 @@ - - -==== cb.js (1 errors) ==== -+cb.js(8,12): error TS2304: Cannot find name 'Id'. -+cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. -+cb.js(22,12): error TS2304: Cannot find name 'SharedId'. ++cb.js(19,14): error TS2339: Property 'id' does not exist on type 'SharedClass'. +cb.js(25,12): error TS2304: Cannot find name 'Final'. + + -+==== cb.js (4 errors) ==== ++==== cb.js (2 errors) ==== /** @template T * @callback Id * @param {T} t -@@= skipped -9, +12 lines =@@ - var x = 1 - - /** @type {Id} I actually wanted to write `const "120"` */ -+ ~~ -+!!! error TS2304: Cannot find name 'Id'. - var one_twenty = s => "120"; - - /** @template S -@@= skipped -10, +12 lines =@@ +@@= skipped -19, +20 lines =@@ class SharedClass { constructor() { /** @type {SharedId} */ @@ -32,12 +21,10 @@ -!!! error TS2304: Cannot find name 'S'. this.id; + ~~ -+!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. ++!!! error TS2339: Property 'id' does not exist on type 'SharedClass'. } } /** @type {SharedId} */ -+ ~~~~~~~~ -+!!! error TS2304: Cannot find name 'SharedId'. var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff index 9ba5f5627c..c4d4ea8e20 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag2.types.diff @@ -1,23 +1,6 @@ --- old.callbackTag2.types +++ new.callbackTag2.types -@@= skipped -12, +12 lines =@@ - /** @type {Id} I actually wanted to write `const "120"` */ - var one_twenty = s => "120"; - >one_twenty : Id -->s => "120" : (s: string) => string -->s : string -+>s => "120" : (s: any) => string -+>s : any - >"120" : "120" - - /** @template S -@@= skipped -10, +10 lines =@@ - * @return {S} - */ - class SharedClass { -->SharedClass : SharedClass -+>SharedClass : SharedClass - +@@= skipped -27, +27 lines =@@ constructor() { /** @type {SharedId} */ this.id; @@ -29,18 +12,7 @@ } } /** @type {SharedId} */ - var outside = n => n + 1; - >outside : SharedId -->n => n + 1 : (n: number) => number -->n : number -->n + 1 : number -->n : number -+>n => n + 1 : (n: any) => any -+>n : any -+>n + 1 : any -+>n : any - >1 : 1 - +@@= skipped -17, +17 lines =@@ /** @type {Final<{ fantasy }, { heroes }>} */ var noreturn = (barts, tidus, noctis) => "cecil" >noreturn : Final<{ fantasy: any; }, { heroes: any; }> diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff deleted file mode 100644 index 9ca1901018..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag3.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.callbackTag3.errors.txt -+++ new.callbackTag3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+cb.js(4,12): error TS2304: Cannot find name 'Miracle'. -+ -+ -+==== cb.js (1 errors) ==== -+ /** @callback Miracle -+ * @returns {string} What were you expecting -+ */ -+ /** @type {Miracle} smallId */ -+ ~~~~~~~ -+!!! error TS2304: Cannot find name 'Miracle'. -+ var sid = () => "!"; -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff deleted file mode 100644 index 35dae3943c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.callbackTag4.errors.txt -+++ new.callbackTag4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(9,12): error TS2304: Cannot find name 'C'. -+a.js(10,22): error TS7006: Parameter 'a' implicitly has an 'any' type. -+a.js(10,25): error TS7006: Parameter 'b' implicitly has an 'any' type. -+a.js(11,5): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+ -+ -+==== a.js (4 errors) ==== -+ /** -+ * @callback C -+ * @this {{ a: string, b: number }} -+ * @param {string} a -+ * @param {number} b -+ * @returns {boolean} -+ */ -+ -+ /** @type {C} */ -+ ~ -+!!! error TS2304: Cannot find name 'C'. -+ const cb = function (a, b) { -+ ~ -+!!! error TS7006: Parameter 'a' implicitly has an 'any' type. -+ ~ -+!!! error TS7006: Parameter 'b' implicitly has an 'any' type. -+ this -+ ~~~~ -+!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+ return true -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff index 654f4bbda3..95b1f667bc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTag4.types.diff @@ -5,15 +5,6 @@ const cb = function (a, b) { >cb : C ->function (a, b) { this return true} : (this: { a: string; b: number; }, a: string, b: number) => boolean -->a : string -->b : number -+>function (a, b) { this return true} : (a: any, b: any) => boolean -+>a : any -+>b : any - - this -->this : { a: string; b: number; } -+>this : any - - return true - >true : true \ No newline at end of file ++>function (a, b) { this return true} : (this: { a: string; b: number; }, a: string, b: number) => true + >a : string + >b : number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff deleted file mode 100644 index 9d5cf2c0a8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.callbackTagNestedParameter.errors.txt -+++ new.callbackTagNestedParameter.errors.txt -@@= skipped -0, +0 lines =@@ -- -+cb_nested.js(11,12): error TS2304: Cannot find name 'WorksWithPeopleCallback'. -+ -+ -+==== cb_nested.js (1 errors) ==== -+ /** -+ * @callback WorksWithPeopleCallback -+ * @param {Object} person -+ * @param {string} person.name -+ * @param {number} [person.age] -+ * @returns {void} -+ */ -+ -+ /** -+ * For each person, calls your callback. -+ * @param {WorksWithPeopleCallback} callback -+ ~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2304: Cannot find name 'WorksWithPeopleCallback'. -+ * @returns {void} -+ */ -+ function eachPerson(callback) { -+ callback({ name: "Empty" }); -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff deleted file mode 100644 index 4dbfd17516..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagNestedParameter.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.callbackTagNestedParameter.types -+++ new.callbackTagNestedParameter.types -@@= skipped -18, +18 lines =@@ - >callback : WorksWithPeopleCallback - - callback({ name: "Empty" }); -->callback({ name: "Empty" }) : void -+>callback({ name: "Empty" }) : any - >callback : WorksWithPeopleCallback - >{ name: "Empty" } : { name: string; } - >name : string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff index 2ba749b09c..20cd34bc46 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.errors.txt.diff @@ -2,7 +2,7 @@ +++ new.callbackTagVariadicType.errors.txt @@= skipped -0, +0 lines =@@ - -+callbackTagVariadicType.js(7,12): error TS2304: Cannot find name 'Foo'. ++callbackTagVariadicType.js(9,18): error TS2554: Expected 1 arguments, but got 2. + + +==== callbackTagVariadicType.js (1 errors) ==== @@ -13,8 +13,8 @@ + */ + + /** @type {Foo} */ -+ ~~~ -+!!! error TS2304: Cannot find name 'Foo'. + export const x = () => 1 + var res = x('a', 'b') ++ ~~~ ++!!! error TS2554: Expected 1 arguments, but got 2. + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff deleted file mode 100644 index c5cb06be10..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackTagVariadicType.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.callbackTagVariadicType.types -+++ new.callbackTagVariadicType.types -@@= skipped -13, +13 lines =@@ - >1 : 1 - - var res = x('a', 'b') -->res : number -->x('a', 'b') : number -+>res : any -+>x('a', 'b') : any - >x : Foo - >'a' : "a" - >'b' : "b" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff deleted file mode 100644 index 1bf5bf0abb..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.checkJsdocTypeTag4.errors.txt -+++ new.checkJsdocTypeTag4.errors.txt -@@= skipped -0, +0 lines =@@ -+test.js(3,19): error TS2304: Cannot find name 'U'. - test.js(5,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. - test.js(7,14): error TS2344: Type 'number' does not satisfy the constraint 'string'. - -@@= skipped -4, +5 lines =@@ - ==== t.d.ts (0 errors) ==== - type A = { a: T } - --==== test.js (2 errors) ==== -+==== test.js (3 errors) ==== - /** Also should error for jsdoc typedefs - * @template {string} U - * @typedef {{ b: U }} B -+ ~ -+!!! error TS2304: Cannot find name 'U'. - */ - /** @type {A} */ - ~~~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff index 255f9cb7cd..1df5adda50 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypeTag4.types.diff @@ -5,4 +5,4 @@ /** @type {B} */ var b; ->b : B -+>b : { b: U; } ++>b : { b: number; } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff index 66c441659d..edfe5ae50a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/errorOnFunctionReturnType.errors.txt.diff @@ -14,15 +14,17 @@ - - -==== foo.js (10 errors) ==== -+foo.js(20,12): error TS2304: Cannot find name 'FunctionReturningPromise'. -+foo.js(44,12): error TS2304: Cannot find name 'FunctionReturningNever'. ++foo.js(21,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. ++ Type 'void' is not assignable to type 'Promise'. ++foo.js(45,5): error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. ++ Type 'void' is not assignable to type 'never'. + + +==== foo.js (2 errors) ==== /** * @callback FunctionReturningPromise * @returns {Promise} -@@= skipped -17, +9 lines =@@ +@@= skipped -17, +11 lines =@@ /** @type {FunctionReturningPromise} */ function testPromise1() { @@ -47,15 +49,16 @@ } /** @type {FunctionReturningPromise} */ -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2304: Cannot find name 'FunctionReturningPromise'. var testPromise4 = function() { - ~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value. ++ ~~~~~~~~~~~~ ++!!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningPromise'. ++!!! error TS2322: Type 'void' is not assignable to type 'Promise'. console.log("test") } -@@= skipped -34, +26 lines =@@ +@@= skipped -34, +27 lines =@@ /** @type {FunctionReturningNever} */ function testNever1() { @@ -81,10 +84,11 @@ } /** @type {FunctionReturningNever} */ -+ ~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2304: Cannot find name 'FunctionReturningNever'. var testNever4 = function() { - ~~~~~~~~ -!!! error TS2534: A function returning 'never' cannot have a reachable end point. ++ ~~~~~~~~~~ ++!!! error TS2322: Type '() => void' is not assignable to type 'FunctionReturningNever'. ++!!! error TS2322: Type 'void' is not assignable to type 'never'. console.log("test") } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff deleted file mode 100644 index a5e7999e31..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt -+++ new.instantiateTemplateTagTypeParameterOnVariableStatement.errors.txt -@@= skipped -0, +0 lines =@@ -- -+instantiateTemplateTagTypeParameterOnVariableStatement.js(12,5): error TS2322: Type 'T' is not assignable to type 'string'. -+instantiateTemplateTagTypeParameterOnVariableStatement.js(12,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. -+ 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -+ -+ -+==== instantiateTemplateTagTypeParameterOnVariableStatement.js (2 errors) ==== -+ /** -+ * @template T -+ * @param {T} a -+ * @returns {(b: T) => T} -+ */ -+ const seq = a => b => b; -+ -+ const text1 = "hello"; -+ const text2 = "world"; -+ -+ /** @type {string} */ -+ var text3 = seq(text1)(text2); -+ ~~~~~ -+!!! error TS2322: Type 'T' is not assignable to type 'string'. -+!!! related TS2208 instantiateTemplateTagTypeParameterOnVariableStatement.js:2:14: This type parameter might need an `extends string` constraint. -+ ~~~~~ -+!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'T'. -+!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff deleted file mode 100644 index 8ea8637f9c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/instantiateTemplateTagTypeParameterOnVariableStatement.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.instantiateTemplateTagTypeParameterOnVariableStatement.types -+++ new.instantiateTemplateTagTypeParameterOnVariableStatement.types -@@= skipped -24, +24 lines =@@ - /** @type {string} */ - var text3 = seq(text1)(text2); - >text3 : string -->seq(text1)(text2) : string -->seq(text1) : (b: string) => string -+>seq(text1)(text2) : T -+>seq(text1) : (b: T) => T - >seq : (a: T) => (b: T) => T - >text1 : "hello" - >text2 : "world" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff index b502563d51..b2112d421b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.errors.txt.diff @@ -4,6 +4,7 @@ - +base.js(11,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +file.js(1,15): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? ++file.js(4,12): error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? + + +==== base.js (1 errors) ==== @@ -21,13 +22,15 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + -+==== file.js (1 errors) ==== ++==== file.js (2 errors) ==== + /** @typedef {import('./base')} BaseFactory */ + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? + /** + * @callback BaseFactoryFactory + * @param {import('./base')} factory ++ ~~~~~~~~~~~~~~~~ ++!!! error TS1340: Module './base' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./base')'? + */ + /** @enum {import('./base')} */ + const couldntThinkOfAny = {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff index a361c709e1..fd8c906846 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction.errors.txt.diff @@ -5,25 +5,31 @@ - - -==== templateTagOnConstructorFunctions.js (1 errors) ==== -+templateTagOnConstructorFunctions.js(3,18): error TS2304: Cannot find name 'U'. -+templateTagOnConstructorFunctions.js(3,24): error TS2304: Cannot find name 'U'. -+ -+ -+==== templateTagOnConstructorFunctions.js (2 errors) ==== - /** - * @template U - * @typedef {(u: U) => U} Id -+ ~ -+!!! error TS2304: Cannot find name 'U'. -+ ~ -+!!! error TS2304: Cannot find name 'U'. - */ - /** - * @param {T} t -@@= skipped -25, +30 lines =@@ - var z = new Zet(1) - z.t = 2 - z.u = false +- /** +- * @template U +- * @typedef {(u: U) => U} Id +- */ +- /** +- * @param {T} t +- * @template T +- */ +- function Zet(t) { +- /** @type {T} */ +- this.u +- this.t = t +- } +- /** +- * @param {T} v +- * @param {Id} id +- */ +- Zet.prototype.add = function(v, id) { +- this.u = v || this.t +- return id(this.u) +- } +- var z = new Zet(1) +- z.t = 2 +- z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. - \ No newline at end of file +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff index 25e532c9b0..a30dd9f14c 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.errors.txt.diff @@ -1,8 +1,8 @@ --- old.jsdocTemplateTag3.errors.txt +++ new.jsdocTemplateTag3.errors.txt @@= skipped -0, +0 lines =@@ --a.js(14,29): error TS2339: Property 'a' does not exist on type 'U'. --a.js(14,35): error TS2339: Property 'b' does not exist on type 'U'. + a.js(14,29): error TS2339: Property 'a' does not exist on type 'U'. + a.js(14,35): error TS2339: Property 'b' does not exist on type 'U'. -a.js(21,3): error TS2345: Argument of type '{ a: number; }' is not assignable to parameter of type '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -a.js(24,15): error TS2304: Cannot find name 'NoLongerAllowed'. @@ -13,22 +13,11 @@ +a.js(21,3): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. + + -+==== a.js (1 errors) ==== ++==== a.js (3 errors) ==== /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? -@@= skipped -20, +15 lines =@@ - */ - function f(t, u, v, w, x) { - if(t.a + t.b.length > u.a - u.b.length && v.c) { -- ~ --!!! error TS2339: Property 'a' does not exist on type 'U'. -- ~ --!!! error TS2339: Property 'b' does not exist on type 'U'. - return w; - } - return x; -@@= skipped -12, +8 lines =@@ +@@= skipped -32, +29 lines =@@ f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); f({ a: 12 }, undefined, undefined, 101, 'nope'); ~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff deleted file mode 100644 index 8ba1223a70..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag3.types.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.jsdocTemplateTag3.types -+++ new.jsdocTemplateTag3.types -@@= skipped -13, +13 lines =@@ - * @return {W | X} - */ - function f(t, u, v, w, x) { -->f : (t: T, u: U, v: V, w: W, x: X) => W | X -+>f : (t: T, u: U, v: V, w: W, x: X) => W | X - >t : T - >u : U - >v : V -@@= skipped -20, +20 lines =@@ - >b : string - >length : number - >u.a - u.b.length : number -->u.a : any -->u : U -->a : any -->u.b.length : any -->u.b : any -->u : U -->b : any -->length : any -+>u.a : number -+>u : U -+>a : number -+>u.b.length : number -+>u.b : string -+>u : U -+>b : string -+>length : number - >v.c : boolean - >v : V - >c : boolean -@@= skipped -21, +21 lines =@@ - - f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope'); - >f({ a: 12, b: 'hi', c: null }, undefined, { c: false, d: 12, b: undefined }, 101, 'nope') : "nope" | 101 -->f : (t: T, u: U, v: V, w: W, x: X) => W | X -+>f : (t: T, u: U, v: V, w: W, x: X) => W | X - >{ a: 12, b: 'hi', c: null } : { a: number; b: string; c: null; } - >a : number - >12 : 12 -@@= skipped -20, +20 lines =@@ - - f({ a: 12 }, undefined, undefined, 101, 'nope'); - >f({ a: 12 }, undefined, undefined, 101, 'nope') : "nope" | 101 -->f : (t: T, u: U, v: V, w: W, x: X) => W | X -+>f : (t: T, u: U, v: V, w: W, x: X) => W | X - >{ a: 12 } : { a: number; } - >a : number - >12 : 12 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff new file mode 100644 index 0000000000..ad27c1d2fb --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag6.errors.txt.diff @@ -0,0 +1,116 @@ +--- old.jsdocTemplateTag6.errors.txt ++++ new.jsdocTemplateTag6.errors.txt +@@= skipped -0, +0 lines =@@ +- ++a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(14,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(26,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(37,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(48,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(59,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(68,18): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ ++ ++==== a.js (7 errors) ==== ++ /** ++ * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {T} x ++ * @returns {T} ++ */ ++ function f1(x) { ++ return x; ++ } ++ const t1 = f1("a"); ++ const t2 = f1(["a", ["b", "c"]]); ++ const t3 = f1({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ++ ++ /** ++ * @template const T, U ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {T} x ++ * @returns {T} ++ */ ++ function f2(x) { ++ return x; ++ }; ++ const t4 = f2('a'); ++ const t5 = f2(['a', ['b', 'c']]); ++ const t6 = f2({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ++ ++ /** ++ * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {T} x ++ * @returns {T[]} ++ */ ++ function f3(x) { ++ return [x]; ++ } ++ const t7 = f3("hello"); ++ const t8 = f3("hello"); ++ ++ /** ++ * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {[T, T]} x ++ * @returns {T} ++ */ ++ function f4(x) { ++ return x[0]; ++ } ++ const t9 = f4([[1, "x"], [2, "y"]]); ++ const t10 = f4([{ a: 1, b: "x" }, { a: 2, b: "y" }]); ++ ++ /** ++ * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {{ x: T, y: T}} obj ++ * @returns {T} ++ */ ++ function f5(obj) { ++ return obj.x; ++ } ++ const t11 = f5({ x: [1, "x"], y: [2, "y"] }); ++ const t12 = f5({ x: { a: 1, b: "x" }, y: { a: 2, b: "y" } }); ++ ++ /** ++ * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ */ ++ class C { ++ /** ++ * @param {T} x ++ */ ++ constructor(x) {} ++ ++ /** ++ * @template const U ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++ * @param {U} x ++ */ ++ foo(x) { ++ return x; ++ } ++ } ++ ++ const t13 = new C({ a: 1, b: "c", d: ["e", 2, true, { f: "g" }] }); ++ const t14 = t13.foo(["a", ["b", "c"]]); ++ ++ /** ++ * @template {readonly unknown[]} const T ++ * @param {T} args ++ * @returns {T} ++ */ ++ function f6(...args) { ++ return args; ++ } ++ const t15 = f6(1, 'b', { a: 1, b: 'x' }); ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff new file mode 100644 index 0000000000..c7e3efdbb8 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag7.errors.txt.diff @@ -0,0 +1,22 @@ +--- old.jsdocTemplateTag7.errors.txt ++++ new.jsdocTemplateTag7.errors.txt +@@= skipped -0, +0 lines =@@ + a.js(2,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class ++a.js(7,14): error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + a.js(12,14): error TS1273: 'private' modifier cannot appear on a type parameter + + +-==== a.js (2 errors) ==== ++==== a.js (3 errors) ==== + /** + * @template const T + ~~~~~ +@@= skipped -11, +12 lines =@@ + + /** + * @template const T ++ ~~~~~ ++!!! error TS1277: 'const' modifier can only appear on a type parameter of a function, method or class + */ + class C { } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff index 1589ca977c..31ea3f1da6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.errors.txt.diff @@ -1,70 +1,27 @@ --- old.jsdocTemplateTagDefault.errors.txt +++ new.jsdocTemplateTagDefault.errors.txt @@= skipped -0, +0 lines =@@ --file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. + file.js(9,20): error TS2322: Type 'number' is not assignable to type 'string'. -file.js(22,34): error TS1005: '=' expected. -file.js(27,35): error TS1110: Type expected. -+file.js(3,15): error TS2304: Cannot find name 'T'. -+file.js(17,17): error TS2304: Cannot find name 'T'. -+file.js(18,15): error TS2304: Cannot find name 'T'. -+file.js(18,18): error TS2304: Cannot find name 'U'. -+file.js(23,15): error TS2304: Cannot find name 'T'. -+file.js(28,15): error TS2304: Cannot find name 'T'. file.js(33,14): error TS2706: Required type parameters may not follow optional type parameters. --file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -+file.js(34,15): error TS2304: Cannot find name 'T'. -+file.js(34,18): error TS2304: Cannot find name 'U'. -+file.js(38,17): error TS2304: Cannot find name 'U'. -+file.js(39,17): error TS2304: Cannot find name 'T'. -+file.js(40,15): error TS2304: Cannot find name 'T'. -+file.js(40,18): error TS2304: Cannot find name 'U'. -+file.js(45,17): error TS2304: Cannot find name 'T'. + file.js(38,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. file.js(53,14): error TS2706: Required type parameters may not follow optional type parameters. --file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. -- -- + file.js(60,17): error TS2744: Type parameter defaults can only reference previously declared type parameters. + + -==== file.js (7 errors) ==== -+file.js(60,17): error TS2304: Cannot find name 'U'. -+file.js(61,17): error TS2304: Cannot find name 'T'. -+ -+ -+==== file.js (17 errors) ==== ++==== file.js (5 errors) ==== /** * @template {string | number} [T=string] - ok: defaults are permitted * @typedef {[T]} A -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - - /** @type {A} */ // ok, default for `T` in `A` is `string` - const aDefault1 = [""]; - /** @type {A} */ // error: `number` is not assignable to string` - const aDefault2 = [0]; -- ~ --!!! error TS2322: Type 'number' is not assignable to type 'string'. - /** @type {A} */ // ok, `T` is provided for `A` - const aString = [""]; - /** @type {A} */ // ok, `T` is provided for `A` -@@= skipped -26, +36 lines =@@ - /** - * @template T - * @template [U=T] - ok: default can reference earlier type parameter -+ ~ -+!!! error TS2304: Cannot find name 'T'. - * @typedef {[T, U]} B -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'U'. - */ +@@= skipped -31, +29 lines =@@ /** * @template {string | number} [T] - error: default requires an `=type` - ~ -!!! error TS1005: '=' expected. * @typedef {[T]} C -+ ~ -+!!! error TS2304: Cannot find name 'T'. */ /** @@ -72,53 +29,5 @@ - ~ -!!! error TS1110: Type expected. * @typedef {[T]} D -+ ~ -+!!! error TS2304: Cannot find name 'T'. - */ - - /** -@@= skipped -23, +29 lines =@@ - ~ - !!! error TS2706: Required type parameters may not follow optional type parameters. - * @typedef {[T, U]} E -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'U'. */ - - /** - * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. - ~ --!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. -+!!! error TS2304: Cannot find name 'U'. - * @template [U=T] -+ ~ -+!!! error TS2304: Cannot find name 'T'. - * @typedef {[T, U]} G -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'U'. - */ - - /** - * @template T - * @template [U=T] - ok: default can reference earlier type parameter -+ ~ -+!!! error TS2304: Cannot find name 'T'. - * @param {T} a - * @param {U} b - */ -@@= skipped -31, +43 lines =@@ - /** - * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters. - ~ --!!! error TS2744: Type parameter defaults can only reference previously declared type parameters. -+!!! error TS2304: Cannot find name 'U'. - * @template [U=T] -+ ~ -+!!! error TS2304: Cannot find name 'T'. - * @param {T} a - * @param {U} b - */ \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff index e37ba40364..b8f6c5d302 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagDefault.types.diff @@ -5,27 +5,27 @@ /** @type {A} */ // ok, default for `T` in `A` is `string` const aDefault1 = [""]; ->aDefault1 : A -+>aDefault1 : [T] ++>aDefault1 : [string] >[""] : [string] >"" : "" /** @type {A} */ // error: `number` is not assignable to string` const aDefault2 = [0]; ->aDefault2 : A -+>aDefault2 : [T] ++>aDefault2 : [string] >[0] : [number] >0 : 0 /** @type {A} */ // ok, `T` is provided for `A` const aString = [""]; ->aString : A -+>aString : [T] ++>aString : [string] >[""] : [string] >"" : "" /** @type {A} */ // ok, `T` is provided for `A` const aNumber = [0]; ->aNumber : A -+>aNumber : [T] ++>aNumber : [number] >[0] : [number] >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff deleted file mode 100644 index 2fd7f9ad3e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.errors.txt.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.jsdocTemplateTagNameResolution.errors.txt -+++ new.jsdocTemplateTagNameResolution.errors.txt -@@= skipped -0, +0 lines =@@ --file.js(10,7): error TS2322: Type 'string' is not assignable to type 'number'. -- -- --==== file.js (1 errors) ==== -+file.js(3,21): error TS2304: Cannot find name 'T'. -+file.js(4,14): error TS2304: Cannot find name 'T'. -+file.js(4,16): error TS2304: Cannot find name 'K'. -+ -+ -+==== file.js (3 errors) ==== - /** - * @template T - * @template {keyof T} K -+ ~ -+!!! error TS2304: Cannot find name 'T'. - * @typedef {T[K]} Foo -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'K'. - */ - - const x = { a: 1 }; - - /** @type {Foo} */ - const y = "a"; -- ~ --!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff deleted file mode 100644 index 93b74d0464..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTagNameResolution.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.jsdocTemplateTagNameResolution.types -+++ new.jsdocTemplateTagNameResolution.types -@@= skipped -14, +14 lines =@@ - - /** @type {Foo} */ - const y = "a"; -->y : number -+>y : T - >"a" : "a" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff index 280af9ed37..1953446aba 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.errors.txt.diff @@ -8,19 +8,11 @@ -==== bug39372.js (1 errors) ==== +bug39372.js(1,36): error TS2456: Type alias 'JsonArray' circularly references itself. +bug39372.js(3,88): error TS2456: Type alias 'Json' circularly references itself. -+bug39372.js(9,17): error TS2304: Cannot find name 'T'. -+bug39372.js(9,32): error TS2304: Cannot find name 'T'. -+bug39372.js(12,17): error TS2304: Cannot find name 'T'. -+bug39372.js(14,10): error TS2304: Cannot find name 'T'. -+bug39372.js(14,55): error TS2304: Cannot find name 'T'. -+bug39372.js(18,15): error TS2304: Cannot find name 'T'. -+bug39372.js(19,5): error TS2304: Cannot find name 'T'. -+bug39372.js(20,19): error TS2304: Cannot find name 'T'. -+bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; }'. -+ Type '{}' is missing the following properties from type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; }': $A, $O ++bug39372.js(25,7): error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. ++ Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O + + -+==== bug39372.js (11 errors) ==== ++==== bug39372.js (3 errors) ==== /** @typedef {ReadonlyArray} JsonArray */ + ~~~~~~~~~ +!!! error TS2456: Type alias 'JsonArray' circularly references itself. @@ -31,44 +23,12 @@ /** * @template T - * @typedef {{ - $A: { - [K in keyof T]?: XMLObject[] -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - }, - $O: { - [K in keyof T]?: { -+ ~ -+!!! error TS2304: Cannot find name 'T'. - $$?: Record - } & (T[K] extends string ? {$:string} : XMLObject) -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'T'. - }, - $$?: Record, - } & { - [K in keyof T]?: ( -+ ~ -+!!! error TS2304: Cannot find name 'T'. - T[K] extends string ? string -+ ~ -+!!! error TS2304: Cannot find name 'T'. - : XMLObject -+ ~ -+!!! error TS2304: Cannot find name 'T'. - ) - }} XMLObject */ - +@@= skipped -28, +34 lines =@@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ~ -!!! error TS2322: Type '{}' is not assignable to type 'XMLObject<{ foo: string; }>'. -!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: XMLObject[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O -+!!! error TS2322: Type '{}' is not assignable to type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; }'. -+!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; }': $A, $O ++!!! error TS2322: Type '{}' is not assignable to type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; }'. ++!!! error TS2322: Type '{}' is missing the following properties from type '{ $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; }': $A, $O \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff index 327afad014..60d6c6455a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/recursiveTypeReferences2.types.diff @@ -5,5 +5,5 @@ /** @type {XMLObject<{foo:string}>} */ const p = {}; ->p : XMLObject<{ foo: string; }> -+>p : { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & { [x: string]: string | { $A: { [x: string]: (any & { [x: string]: string | any & any; })[]; }; $O: { [x: string]: { $$?: Record; } & ({ $: string; } | any & { [x: string]: string | any & any; }); }; $$?: Record; } & any; } ++>p : { $A: { foo?: ({ $A: string; $O: string; $$?: Record; } & string)[]; }; $O: { foo?: { $$?: Record; } & { $: string; }; }; $$?: Record; } & { foo?: string; } >{} : {} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff index 9c1d2fbd78..2164c25069 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.errors.txt.diff @@ -5,8 +5,7 @@ -templateInsideCallback.js(2,13): error TS8021: JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags. -templateInsideCallback.js(9,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag -templateInsideCallback.js(10,12): error TS2304: Cannot find name 'T'. --templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. -+templateInsideCallback.js(15,11): error TS2304: Cannot find name 'Call'. + templateInsideCallback.js(15,11): error TS2315: Type 'Call' is not generic. +templateInsideCallback.js(15,16): error TS2304: Cannot find name 'T'. templateInsideCallback.js(17,18): error TS7006: Parameter 'x' implicitly has an 'any' type. -templateInsideCallback.js(23,5): error TS8039: A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag @@ -46,18 +45,16 @@ * @returns {T} */ /** - * @template T +@@= skipped -12, +8 lines =@@ * @type {Call} -- ~~~~~~~ --!!! error TS2315: Type 'Call' is not generic. -+ ~~~~ -+!!! error TS2304: Cannot find name 'Call'. + ~~~~~~~ + !!! error TS2315: Type 'Call' is not generic. + ~ +!!! error TS2304: Cannot find name 'T'. */ const identity = x => x; ~ -@@= skipped -22, +20 lines =@@ +@@= skipped -10, +12 lines =@@ * @property {Object} oh * @property {number} oh.no * @template T diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff index ce416d86d6..86460e76ae 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff @@ -1,20 +1,11 @@ --- old.templateInsideCallback.types +++ new.templateInsideCallback.types -@@= skipped -17, +17 lines =@@ - * @type {Call} +@@= skipped -51, +51 lines =@@ + * @returns {unknown[]} */ - const identity = x => x; -->identity : any -+>identity : Call - >x => x : (x: any) => any - >x : any - >x : any -@@= skipped -37, +37 lines =@@ - >flatMap : { (): any; (): any; } + function flatMap(array, iterable = identity) { +->flatMap : { (): any; (): any; } ++>flatMap : { (): any; (): any; } >array : unknown[] >iterable : (x: unknown) => unknown -->identity : any -+>identity : Call - - /** @type {unknown[]} */ - const result = []; \ No newline at end of file + >identity : any \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff deleted file mode 100644 index 3e84646baf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.typeTagNoErasure.errors.txt -+++ new.typeTagNoErasure.errors.txt -@@= skipped -0, +0 lines =@@ --typeTagNoErasure.js(7,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -+typeTagNoErasure.js(1,39): error TS2304: Cannot find name 'T'. - - - ==== typeTagNoErasure.js (1 errors) ==== - /** @template T @typedef {(data: T1) => T1} Test */ -+ ~ -+!!! error TS2304: Cannot find name 'T'. - - /** @type {Test} */ - const test = dibbity => dibbity - - test(1) // ok, T=1 - test('hi') // error, T=number -- ~~~~ --!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff index 10c8a0f52e..c008b3849f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typeTagNoErasure.types.diff @@ -5,21 +5,19 @@ /** @type {Test} */ const test = dibbity => dibbity ->test : Test -->dibbity => dibbity : (dibbity: T1) => T1 -+>test : (data: T1) => T1 -+>dibbity => dibbity : (dibbity: T1) => T1 ++>test : (data: T1) => T1 + >dibbity => dibbity : (dibbity: T1) => T1 >dibbity : T1 >dibbity : T1 test(1) // ok, T=1 >test(1) : 1 ->test : Test -+>test : (data: T1) => T1 ++>test : (data: T1) => T1 >1 : 1 test('hi') // error, T=number -->test('hi') : number + >test('hi') : number ->test : Test -+>test('hi') : "hi" -+>test : (data: T1) => T1 ++>test : (data: T1) => T1 >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff index dde9d36fb2..917202641a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.errors.txt.diff @@ -3,42 +3,15 @@ @@= skipped -0, +0 lines =@@ -a.js(12,23): error TS2344: Type '{ a: number; }' does not satisfy the constraint '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -+a.js(6,19): error TS2304: Cannot find name 'T'. -+a.js(6,25): error TS2304: Cannot find name 'U'. -+a.js(6,31): error TS2304: Cannot find name 'V'. -+a.js(6,37): error TS2304: Cannot find name 'W'. -+a.js(6,43): error TS2304: Cannot find name 'X'. +a.js(12,23): error TS2741: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. a.js(15,12): error TS2314: Generic type 'Everything' requires 5 type argument(s). -test.ts(1,34): error TS2344: Type '{ a: number; }' does not satisfy the constraint '{ a: number; b: string; }'. - Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'. -- -- --==== a.js (2 errors) ==== +test.ts(1,23): error TS2304: Cannot find name 'Everything'. -+ -+ -+==== a.js (7 errors) ==== - /** - * @template {{ a: number, b: string }} T,U A Comment - * @template {{ c: boolean }} V uh ... are comments even supported?? - * @template W - * @template X That last one had no comment - * @typedef {{ t: T, u: U, v: V, w: W, x: X }} Everything -+ ~ -+!!! error TS2304: Cannot find name 'T'. -+ ~ -+!!! error TS2304: Cannot find name 'U'. -+ ~ -+!!! error TS2304: Cannot find name 'V'. -+ ~ -+!!! error TS2304: Cannot find name 'W'. -+ ~ -+!!! error TS2304: Cannot find name 'X'. - */ - - /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ -@@= skipped -18, +31 lines =@@ + + + ==== a.js (2 errors) ==== +@@= skipped -18, +16 lines =@@ /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ ~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff index 50ccd76b6f..feb6000a0b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefMultipleTypeParameters.types.diff @@ -5,12 +5,12 @@ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; ->tuvwx : Everything<{ a: number; b: "hi"; c: never; }, undefined, { c: true; d: 1; }, number, string> -+>tuvwx : { t: T; u: U; v: V; w: W; x: X; } ++>tuvwx : { t: { a: number; b: "hi"; c: never; }; u: undefined; v: { c: true; d: 1; }; w: number; x: string; } /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; ->wrong : Everything<{ a: number; }, undefined, { c: 1; d: 1; }, number, string> -+>wrong : { t: T; u: U; v: V; w: W; x: X; } ++>wrong : { t: { a: number; }; u: undefined; v: { c: 1; d: 1; }; w: number; x: string; } /** @type {Everything<{ a: number }>} */ var insufficient; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff deleted file mode 100644 index dc4fa924c7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.typedefTagTypeResolution.errors.txt -+++ new.typedefTagTypeResolution.errors.txt -@@= skipped -0, +0 lines =@@ - github20832.js(2,15): error TS2304: Cannot find name 'U'. --github20832.js(17,12): error TS2304: Cannot find name 'V'. -+github20832.js(26,12): error TS2304: Cannot find name 'Cb'. - - - ==== github20832.js (2 errors) ==== -@@= skipped -21, +21 lines =@@ - /** - * @callback Cb - * @param {V} firstParam -- ~ --!!! error TS2304: Cannot find name 'V'. - */ - /** - * @template V -@@= skipped -11, +9 lines =@@ - } - - /** @type {Cb} */ -+ ~~ -+!!! error TS2304: Cannot find name 'Cb'. - const cb = x => {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff index f6504ab132..9c031442af 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagTypeResolution.types.diff @@ -14,6 +14,5 @@ const cb = x => {} >cb : Cb ->x => {} : (x: V) => any -->x : V -+>x => {} : (x: any) => void -+>x : any ++>x => {} : (x: V) => void + >x : V