diff --git a/pkg/ast/parseoptions.go b/pkg/ast/parseoptions.go index bf8b2eb8e..02700589d 100644 --- a/pkg/ast/parseoptions.go +++ b/pkg/ast/parseoptions.go @@ -31,8 +31,8 @@ func GetSourceFileAffectingCompilerOptions(fileName string, options *core.Compil } type ExternalModuleIndicatorOptions struct { - jsx bool - force bool + JSX bool + Force bool } func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOptions, metadata SourceFileMetaData) ExternalModuleIndicatorOptions { @@ -43,7 +43,7 @@ func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOp switch options.GetEmitModuleDetectionKind() { case core.ModuleDetectionKindForce: // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule - return ExternalModuleIndicatorOptions{force: true} + return ExternalModuleIndicatorOptions{Force: true} case core.ModuleDetectionKindLegacy: // Files are modules if they have imports, exports, or import.meta return ExternalModuleIndicatorOptions{} @@ -52,8 +52,8 @@ func GetExternalModuleIndicatorOptions(fileName string, options *core.CompilerOp // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness return ExternalModuleIndicatorOptions{ - jsx: options.Jsx == core.JsxEmitReactJSX || options.Jsx == core.JsxEmitReactJSXDev, - force: isFileForcedToBeModuleByFormat(fileName, options, metadata), + JSX: options.Jsx == core.JsxEmitReactJSX || options.Jsx == core.JsxEmitReactJSXDev, + Force: isFileForcedToBeModuleByFormat(fileName, options, metadata), } default: return ExternalModuleIndicatorOptions{} @@ -89,13 +89,13 @@ func getExternalModuleIndicator(file *SourceFile, opts ExternalModuleIndicatorOp return nil } - if opts.jsx { + if opts.JSX { if node := isFileModuleFromUsingJSXTag(file); node != nil { return node } } - if opts.force { + if opts.Force { return file.AsNode() } @@ -112,6 +112,9 @@ func isFileProbablyExternalModule(sourceFile *SourceFile) *Node { } func isAnExternalModuleIndicatorNode(node *Node) bool { + if node.Flags&NodeFlagsReparsed != 0 { + return false + } return HasSyntacticModifier(node, ModifierFlagsExport) || IsImportEqualsDeclaration(node) && IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) || IsImportDeclaration(node) || IsExportAssignment(node) || IsExportDeclaration(node) diff --git a/pkg/ast/utilities.go b/pkg/ast/utilities.go index 43b07afb7..573a3bf7c 100644 --- a/pkg/ast/utilities.go +++ b/pkg/ast/utilities.go @@ -3921,3 +3921,12 @@ func HasContextSensitiveParameters(node *Node) bool { func IsInfinityOrNaNString(name string) bool { return name == "Infinity" || name == "-Infinity" || name == "NaN" } + +func GetFirstConstructorWithBody(node *Node) *Node { + for _, member := range node.Members() { + if IsConstructorDeclaration(member) && NodeIsPresent(member.Body()) { + return member + } + } + return nil +} diff --git a/pkg/checker/checker.go b/pkg/checker/checker.go index d8da627d8..719aca36f 100644 --- a/pkg/checker/checker.go +++ b/pkg/checker/checker.go @@ -1518,12 +1518,14 @@ func (c *Checker) onFailedToResolveSymbol(errorLocation *ast.Node, name string, suggestion := c.getSuggestedSymbolForNonexistentSymbol(errorLocation, name, meaning) if suggestion != nil && !(suggestion.ValueDeclaration != nil && ast.IsAmbientModule(suggestion.ValueDeclaration) && ast.IsGlobalScopeAugmentation(suggestion.ValueDeclaration)) { suggestionName := c.symbolToString(suggestion) - message := core.IfElse(meaning == ast.SymbolFlagsNamespace, diagnostics.Cannot_find_namespace_0_Did_you_mean_1, diagnostics.Cannot_find_name_0_Did_you_mean_1) + isUncheckedJS := c.isUncheckedJSSuggestion(errorLocation, suggestion, false /*excludeClasses*/) + message := core.IfElse(meaning == ast.SymbolFlagsNamespace, diagnostics.Cannot_find_namespace_0_Did_you_mean_1, + core.IfElse(isUncheckedJS, diagnostics.Could_not_find_name_0_Did_you_mean_1, diagnostics.Cannot_find_name_0_Did_you_mean_1)) diagnostic := NewDiagnosticForNode(errorLocation, message, name, suggestionName) if suggestion.ValueDeclaration != nil { diagnostic.AddRelatedInfo(NewDiagnosticForNode(suggestion.ValueDeclaration, diagnostics.X_0_is_declared_here, suggestionName)) } - c.diagnostics.Add(diagnostic) + c.addErrorOrSuggestion(!isUncheckedJS, diagnostic) return } // And then fall back to unspecified "not found" @@ -10873,11 +10875,10 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l if c.checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol) { return c.errorType } - // !!! - // containingClass := getContainingClassExcludingClassDecorators(right) - // if containingClass && isPlainJSFile(ast.GetSourceFileOfNode(containingClass), c.compilerOptions.checkJs) { - // c.grammarErrorOnNode(right, diagnostics.Private_field_0_must_be_declared_in_an_enclosing_class, right.Text()) - // } + containingClass := getContainingClassExcludingClassDecorators(right) + if containingClass != nil && ast.IsPlainJSFile(ast.GetSourceFileOfNode(containingClass), c.compilerOptions.CheckJs) { + c.grammarErrorOnNode(right, diagnostics.Private_field_0_must_be_declared_in_an_enclosing_class, right.Text()) + } } else { isSetonlyAccessor := prop.Flags&ast.SymbolFlagsSetAccessor != 0 && prop.Flags&ast.SymbolFlagsGetAccessor == 0 if isSetonlyAccessor && assignmentKind != AssignmentKindDefinite { @@ -10904,6 +10905,10 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l indexInfo = c.getApplicableIndexInfoForName(apparentType, right.Text()) } if indexInfo == nil { + isUncheckedJS := c.isUncheckedJSSuggestion(node, leftType.symbol, true /*excludeClasses*/) + if !isUncheckedJS && c.isJSLiteralType(leftType) { + return c.anyType + } if leftType.symbol == c.globalThisSymbol { globalSymbol := c.globalThisSymbol.Exports[right.Text()] if globalSymbol != nil && globalSymbol.Flags&ast.SymbolFlagsBlockScoped != 0 { @@ -10914,7 +10919,7 @@ func (c *Checker) checkPropertyAccessExpressionOrQualifiedName(node *ast.Node, l return c.anyType } if right.Text() != "" && !c.checkAndReportErrorForExtendingInterface(node) { - c.reportNonexistentProperty(right, core.IfElse(isThisTypeParameter(leftType), apparentType, leftType)) + c.reportNonexistentProperty(right, core.IfElse(isThisTypeParameter(leftType), apparentType, leftType), isUncheckedJS) } return c.errorType } @@ -11091,7 +11096,7 @@ func (c *Checker) checkPrivateIdentifierPropertyAccess(leftType *Type, right *as return false } -func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *Type) { +func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType *Type, isUncheckedJS bool) { if ast.IsJSDocNameReferenceContext(propNode) { return } @@ -11123,7 +11128,8 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType * suggestion := c.getSuggestedSymbolForNonexistentProperty(propNode, containingType) if suggestion != nil { suggestedName := ast.SymbolName(suggestion) - diagnostic = NewDiagnosticChainForNode(diagnostic, propNode, diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName) + message := core.IfElse(isUncheckedJS, diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2, diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2) + diagnostic = NewDiagnosticChainForNode(diagnostic, propNode, message, missingProperty, container, suggestedName) if suggestion.ValueDeclaration != nil { diagnostic.AddRelatedInfo(NewDiagnosticForNode(suggestion.ValueDeclaration, diagnostics.X_0_is_declared_here, suggestedName)) } @@ -11140,7 +11146,7 @@ func (c *Checker) reportNonexistentProperty(propNode *ast.Node, containingType * } } } - c.diagnostics.Add(diagnostic) + c.addErrorOrSuggestion(!isUncheckedJS || diagnostic.Code() != diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.Code(), diagnostic) } func (c *Checker) getSuggestedLibForNonExistentProperty(missingProperty string, containingType *Type) string { @@ -12609,7 +12615,8 @@ func (c *Checker) checkInExpression(left *ast.Expression, right *ast.Expression, // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors if c.symbolNodeLinks.Get(left).resolvedSymbol == nil && ast.GetContainingClass(left) != nil { - c.reportNonexistentProperty(left, rightType) + isUncheckedJS := c.isUncheckedJSSuggestion(left, rightType.symbol, true /*excludeClasses*/) + c.reportNonexistentProperty(left, rightType, isUncheckedJS) } } else { // The type of the left operand must be assignable to string, number, or symbol. @@ -12714,6 +12721,9 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type } result := c.newAnonymousType(node.Symbol(), propertiesTable, nil, nil, indexInfos) result.objectFlags |= objectFlags | ObjectFlagsObjectLiteral | ObjectFlagsContainsObjectOrArrayLiteral + if contextualType == nil && ast.IsInJSFile(node) && !ast.IsInJsonFile(node) { + result.objectFlags |= ObjectFlagsJSLiteral + } if patternWithComputedProperties { result.objectFlags |= ObjectFlagsObjectLiteralPatternWithComputedProperties } @@ -17598,6 +17608,10 @@ func (c *Checker) widenTypeForVariableLikeDeclaration(t *Type, declaration *ast. } func (c *Checker) reportImplicitAny(declaration *ast.Node, t *Type, wideningKind WideningKind) { + if ast.IsInJSFile(declaration) && !ast.IsCheckJSEnabledForFile(ast.GetSourceFileOfNode(declaration), c.compilerOptions) { + // Only report implicit any errors/suggestions in TS and ts-check JS files + return + } typeAsString := c.TypeToString(c.getWidenedType(t)) var diagnostic *diagnostics.Message switch declaration.Kind { @@ -26321,6 +26335,9 @@ func (c *Checker) getPropertyTypeForIndexType(originalObjectType *Type, objectTy if indexType.flags&TypeFlagsNever != 0 { return c.neverType } + if c.isJSLiteralType(objectType) { + return c.anyType + } if accessExpression != nil && !isConstEnumObjectType(objectType) { if isObjectLiteralType(objectType) { if c.noImplicitAny && indexType.flags&(TypeFlagsStringLiteral|TypeFlagsNumberLiteral) != 0 { @@ -26378,6 +26395,9 @@ func (c *Checker) getPropertyTypeForIndexType(originalObjectType *Type, objectTy if accessFlags&AccessFlagsAllowMissing != 0 && isObjectLiteralType(objectType) { return c.undefinedType } + if c.isJSLiteralType(objectType) { + return c.anyType + } if accessNode != nil { indexNode := getIndexNodeForAccessExpression(accessNode) if indexNode.Kind != ast.KindBigIntLiteral && indexType.flags&(TypeFlagsStringLiteral|TypeFlagsNumberLiteral) != 0 { diff --git a/pkg/checker/utilities.go b/pkg/checker/utilities.go index 1ad7cfc15..89182e1ce 100644 --- a/pkg/checker/utilities.go +++ b/pkg/checker/utilities.go @@ -1825,3 +1825,92 @@ func nodeStartsNewLexicalEnvironment(node *ast.Node) bool { } return false } + +// Determines whether a did-you-mean error should be a suggestion in an unchecked JS file. +// Only applies to unchecked JS files without checkJS, // @ts-check or // @ts-nocheck +// It does not suggest when the suggestion: +// - Is from a global file that is different from the reference file, or +// - (optionally) Is a class, or is a this.x property access expression +func (c *Checker) isUncheckedJSSuggestion(node *ast.Node, suggestion *ast.Symbol, excludeClasses bool) bool { + file := ast.GetSourceFileOfNode(node) + if file != nil { + if c.compilerOptions.CheckJs.IsUnknown() && file.CheckJsDirective == nil && (file.ScriptKind == core.ScriptKindJS || file.ScriptKind == core.ScriptKindJSX) { + var declarationFile *ast.SourceFile + if suggestion != nil { + if firstDeclaration := core.FirstOrNil(suggestion.Declarations); firstDeclaration != nil { + declarationFile = ast.GetSourceFileOfNode(firstDeclaration) + } + } + suggestionHasNoExtendsOrDecorators := suggestion == nil || + suggestion.ValueDeclaration == nil || + !ast.IsClassLike(suggestion.ValueDeclaration) || + len(ast.GetExtendsHeritageClauseElements(suggestion.ValueDeclaration)) != 0 || + classOrConstructorParameterIsDecorated(suggestion.ValueDeclaration) + return !(file != declarationFile && declarationFile != nil && ast.IsGlobalSourceFile(declarationFile.AsNode())) && + !(excludeClasses && suggestion != nil && suggestion.Flags&ast.SymbolFlagsClass != 0 && suggestionHasNoExtendsOrDecorators) && + !(node != nil && excludeClasses && ast.IsPropertyAccessExpression(node) && node.Expression().Kind == ast.KindThisKeyword && suggestionHasNoExtendsOrDecorators) + } + } + return false +} + +func classOrConstructorParameterIsDecorated(node *ast.Node) bool { + if nodeIsDecorated(node, nil, nil) { + return true + } + constructor := ast.GetFirstConstructorWithBody(node) + return constructor != nil && childIsDecorated(constructor, node) +} + +func nodeIsDecorated(node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { + return ast.HasDecorators(node) && nodeCanBeDecorated(false, node, parent, grandparent) +} + +func nodeOrChildIsDecorated(node *ast.Node, parent *ast.Node, grandparent *ast.Node) bool { + return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent) +} + +func childIsDecorated(node *ast.Node, parent *ast.Node) bool { + switch node.Kind { + case ast.KindClassDeclaration, ast.KindClassExpression: + return core.Some(node.Members(), func(m *ast.Node) bool { + return nodeOrChildIsDecorated(m, node, parent) + }) + case ast.KindMethodDeclaration, + ast.KindSetAccessor, + ast.KindConstructor: + return core.Some(node.Parameters(), func(p *ast.Node) bool { + return nodeIsDecorated(p, node, parent) + }) + default: + return false + } +} + +// Returns if a type is or consists of a JSLiteral object type +// In addition to objects which are directly literals, +// * unions where every element is a jsliteral +// * intersections where at least one element is a jsliteral +// * and instantiable types constrained to a jsliteral +// Should all count as literals and not print errors on access or assignment of possibly existing properties. +// This mirrors the behavior of the index signature propagation, to which this behaves similarly (but doesn't affect assignability or inference). +func (c *Checker) isJSLiteralType(t *Type) bool { + if c.noImplicitAny { + return false + // Flag is meaningless under `noImplicitAny` mode + } + if t.objectFlags&ObjectFlagsJSLiteral != 0 { + return true + } + if t.flags&TypeFlagsUnion != 0 { + return core.Every(t.AsUnionType().types, c.isJSLiteralType) + } + if t.flags&TypeFlagsIntersection != 0 { + return core.Some(t.AsIntersectionType().types, c.isJSLiteralType) + } + if t.flags&TypeFlagsInstantiable != 0 { + constraint := c.getResolvedBaseConstraint(t, nil) + return constraint != t && c.isJSLiteralType(constraint) + } + return false +} diff --git a/pkg/core/compileroptions.go b/pkg/core/compileroptions.go index ec0ebfaef..b97a21c9c 100644 --- a/pkg/core/compileroptions.go +++ b/pkg/core/compileroptions.go @@ -232,12 +232,11 @@ func (options *CompilerOptions) GetEmitModuleDetectionKind() ModuleDetectionKind if options.ModuleDetection != ModuleDetectionKindNone { return options.ModuleDetection } - switch options.GetEmitModuleKind() { - case ModuleKindNode16, ModuleKindNode20, ModuleKindNodeNext: + moduleKind := options.GetEmitModuleKind() + if ModuleKindNode16 <= moduleKind && moduleKind <= ModuleKindNodeNext { return ModuleDetectionKindForce - default: - return ModuleDetectionKindAuto } + return ModuleDetectionKindAuto } func (options *CompilerOptions) GetResolvePackageJsonExports() bool { diff --git a/pkg/format/indent.go b/pkg/format/indent.go index 9a7d632dd..cf147ce9f 100644 --- a/pkg/format/indent.go +++ b/pkg/format/indent.go @@ -66,8 +66,11 @@ func getIndentationForNodeWorker( // }, { itself contributes nothing. // prop: 1 L3 - The indentation of the second object literal is best understood by // }) looking at the relationship between the list and *first* list item. - listLine, _ := getStartLineAndCharacterForNode(firstListChild, sourceFile) - listIndentsChild := firstListChild != nil && listLine > containingListOrParentStartLine + var listIndentsChild bool + if firstListChild != nil { + listLine, _ := getStartLineAndCharacterForNode(firstListChild, sourceFile) + listIndentsChild = listLine > containingListOrParentStartLine + } actualIndentation := getActualIndentationForListItem(current, sourceFile, options, listIndentsChild) if actualIndentation != -1 { return actualIndentation + indentationDelta diff --git a/pkg/ls/format_test.go b/pkg/ls/format_test.go index e9ce15427..c6d540700 100644 --- a/pkg/ls/format_test.go +++ b/pkg/ls/format_test.go @@ -70,3 +70,66 @@ func TestGetFormattingEditsAfterKeystroke_SimpleStatement(t *testing.T) { // Should return nil or empty edits, not panic _ = edits } + +// Test for issue: Crash in range formatting when requested on a line that is different from the containing function +// This reproduces the panic when formatting a range inside a function body +func TestGetFormattingEditsForRange_FunctionBody(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + text string + startPos int + endPos int + }{ + { + name: "return statement in function", + text: "function foo() {\n return (1 + 2);\n}", + startPos: 21, // Start of "return" + endPos: 38, // End of ");" + }, + { + name: "function with newline after keyword", + text: "function\nf() {\n}", + startPos: 9, // After "function\n" + endPos: 13, // Inside or after function + }, + { + name: "empty function body", + text: "function f() {\n \n}", + startPos: 15, // Inside body + endPos: 17, // Inside body + }, + { + name: "after function closing brace", + text: "function f() {\n}", + startPos: 15, // After closing brace + endPos: 15, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + sourceFile := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/test.ts", + Path: "/test.ts", + }, tc.text, core.ScriptKindTS) + + langService := &LanguageService{} + ctx := context.Background() + options := format.GetDefaultFormatCodeSettings("\n") + + // This should not panic + edits := langService.getFormattingEditsForRange( + ctx, + sourceFile, + options, + core.NewTextRange(tc.startPos, tc.endPos), + ) + + // Should not panic + _ = edits // Just ensuring no panic + }) + } +} diff --git a/pkg/parser/jsdoc.go b/pkg/parser/jsdoc.go index 74f4b6bff..f3a34dd94 100644 --- a/pkg/parser/jsdoc.go +++ b/pkg/parser/jsdoc.go @@ -918,8 +918,14 @@ func (p *Parser) parseTypedefTag(start int, tagName *ast.IdentifierNode, indent if childTypeTag != nil && childTypeTag.TypeExpression != nil && !isObjectOrObjectArrayTypeReference(childTypeTag.TypeExpression.Type()) { typeExpression = childTypeTag.TypeExpression } else { - typeExpression = p.finishNode(jsdocTypeLiteral, jsdocPropertyTags[0].Pos()) + // !!! This differs from Strada but prevents a crash + pos := start + if len(jsdocPropertyTags) > 0 { + pos = jsdocPropertyTags[0].Pos() + } + typeExpression = p.finishNode(jsdocTypeLiteral, pos) } + end = typeExpression.End() } } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 3c7f537d5..413433161 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -503,7 +503,7 @@ func (p *Parser) parseListIndex(kind ParsingContext, parseElement func(p *Parser list := make([]*ast.Node, 0, 16) for i := 0; !p.isListTerminator(kind); i++ { if p.isListElement(kind, false /*inErrorRecovery*/) { - elt := parseElement(p, i) + elt := parseElement(p, len(list)) if len(p.reparseList) > 0 { for _, e := range p.reparseList { // Propagate @typedef type alias declarations outwards to a context that permits them. @@ -1029,8 +1029,12 @@ func (p *Parser) parseDeclaration() *ast.Statement { func (p *Parser) parseDeclarationWorker(pos int, hasJSDoc bool, modifiers *ast.ModifierList) *ast.Statement { switch p.token { - case ast.KindVarKeyword, ast.KindLetKeyword, ast.KindConstKeyword, ast.KindUsingKeyword, ast.KindAwaitKeyword: + case ast.KindVarKeyword, ast.KindLetKeyword, ast.KindConstKeyword, ast.KindUsingKeyword: return p.parseVariableStatement(pos, hasJSDoc, modifiers) + case ast.KindAwaitKeyword: + if p.isAwaitUsingDeclaration() { + return p.parseVariableStatement(pos, hasJSDoc, modifiers) + } case ast.KindFunctionKeyword: return p.parseFunctionDeclaration(pos, hasJSDoc, modifiers) case ast.KindClassKeyword: @@ -6397,6 +6401,9 @@ func skipNonBlanks(text string, pos int) int { } func skipTo(text string, pos int, s string) int { + if pos >= len(text) { + return -1 + } i := strings.Index(text[pos:], s) if i < 0 { return -1 diff --git a/pkg/parser/parser_test.go b/pkg/parser/parser_test.go index 36e7504ed..1a33849ab 100644 --- a/pkg/parser/parser_test.go +++ b/pkg/parser/parser_test.go @@ -1,4 +1,4 @@ -package parser +package parser_test import ( "io/fs" @@ -10,7 +10,9 @@ import ( "github.com/buke/typescript-go-internal/pkg/ast" "github.com/buke/typescript-go-internal/pkg/collections" "github.com/buke/typescript-go-internal/pkg/core" + "github.com/buke/typescript-go-internal/pkg/parser" "github.com/buke/typescript-go-internal/pkg/repo" + "github.com/buke/typescript-go-internal/pkg/testrunner" "github.com/buke/typescript-go-internal/pkg/testutil/fixtures" "github.com/buke/typescript-go-internal/pkg/tspath" "github.com/buke/typescript-go-internal/pkg/vfs/osvfs" @@ -46,7 +48,7 @@ func BenchmarkParse(b *testing.B) { } for b.Loop() { - ParseSourceFile(opts, sourceText, scriptKind) + parser.ParseSourceFile(opts, sourceText, scriptKind) } }) } @@ -94,7 +96,6 @@ func FuzzParser(f *testing.F) { "src", "scripts", "Herebyfile.mjs", - // "tests/cases", } var extensions collections.Set[string] @@ -111,19 +112,53 @@ func FuzzParser(f *testing.F) { sourceText, err := os.ReadFile(file.path) assert.NilError(f, err) extension := tspath.TryGetExtensionFromPath(file.path) - f.Add(extension, string(sourceText), int32(core.ScriptTargetESNext), uint8(ast.JSDocParsingModeParseAll)) + f.Add(extension, string(sourceText), uint8(ast.JSDocParsingModeParseAll), false, false) } } - f.Fuzz(func(t *testing.T, extension string, sourceText string, scriptTarget_ int32, jsdocParsingMode_ uint8) { - scriptTarget := core.ScriptTarget(scriptTarget_) - jsdocParsingMode := ast.JSDocParsingMode(jsdocParsingMode_) + testDirs := []string{ + filepath.Join(repo.TypeScriptSubmodulePath, "tests/cases/compiler"), + filepath.Join(repo.TypeScriptSubmodulePath, "tests/cases/conformance"), + filepath.Join(repo.TestDataPath, "tests/cases/compiler"), + } - if !extensions.Has(extension) { - t.Skip() + for _, testDir := range testDirs { + if _, err := os.Stat(testDir); os.IsNotExist(err) { + continue + } + + for file := range allParsableFiles(f, testDir) { + sourceText, err := os.ReadFile(file.path) + assert.NilError(f, err) + + type testFile struct { + content string + name string + } + + testUnits, _, _, _, err := testrunner.ParseTestFilesAndSymlinks( + string(sourceText), + file.path, + func(filename string, content string, fileOptions map[string]string) (testFile, error) { + return testFile{content: content, name: filename}, nil + }, + ) + assert.NilError(f, err) + + for _, unit := range testUnits { + extension := tspath.TryGetExtensionFromPath(unit.name) + if extension == "" { + continue + } + f.Add(extension, unit.content, uint8(ast.JSDocParsingModeParseAll), false, false) + } } + } + + f.Fuzz(func(t *testing.T, extension string, sourceText string, jsdocParsingMode_ uint8, externalModuleIndicatorOptionsJSX bool, externalModuleIndicatorOptionsForce bool) { + jsdocParsingMode := ast.JSDocParsingMode(jsdocParsingMode_) - if scriptTarget < core.ScriptTargetNone || scriptTarget > core.ScriptTargetLatest { + if !extensions.Has(extension) { t.Skip() } @@ -138,8 +173,12 @@ func FuzzParser(f *testing.F) { FileName: fileName, Path: path, JSDocParsingMode: jsdocParsingMode, + ExternalModuleIndicatorOptions: ast.ExternalModuleIndicatorOptions{ + JSX: externalModuleIndicatorOptionsJSX, + Force: externalModuleIndicatorOptionsForce, + }, } - ParseSourceFile(opts, sourceText, core.GetScriptKindFromFileName(fileName)) + parser.ParseSourceFile(opts, sourceText, core.GetScriptKindFromFileName(fileName)) }) } diff --git a/pkg/parser/reparser.go b/pkg/parser/reparser.go index 34a2ac673..54d2b3ceb 100644 --- a/pkg/parser/reparser.go +++ b/pkg/parser/reparser.go @@ -134,6 +134,10 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD signature = p.factory.NewFunctionDeclaration(clonedModifiers, nil, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) case ast.KindMethodDeclaration, ast.KindMethodSignature: signature = p.factory.NewMethodDeclaration(clonedModifiers, nil, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil, nil) + case ast.KindGetAccessor: + signature = p.factory.NewGetAccessorDeclaration(clonedModifiers, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) + case ast.KindSetAccessor: + signature = p.factory.NewSetAccessorDeclaration(clonedModifiers, p.factory.DeepCloneReparse(fun.Name()), nil, nil, nil, nil, nil) case ast.KindConstructor: signature = p.factory.NewConstructorDeclaration(clonedModifiers, nil, nil, nil, nil, nil) case ast.KindJSDocCallbackTag: @@ -319,7 +323,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } case ast.KindReturnStatement, ast.KindParenthesizedExpression: - if tag.AsJSDocTypeTag().TypeExpression != nil { + if parent.Expression() != nil && tag.AsJSDocTypeTag().TypeExpression != nil { parent.AsMutable().SetExpression(p.makeNewCast( p.factory.DeepCloneReparse(tag.AsJSDocTypeTag().TypeExpression.Type()), p.factory.DeepCloneReparse(parent.Expression()), @@ -352,7 +356,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } case ast.KindVariableDeclaration, ast.KindCommonJSExport, - ast.KindPropertyDeclaration, ast.KindPropertyAssignment, ast.KindShorthandPropertyAssignment: + ast.KindPropertyDeclaration, ast.KindPropertyAssignment: if parent.Initializer() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { parent.AsMutable().SetInitializer(p.makeNewCast( p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), @@ -360,6 +364,15 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) false /*isAssertion*/)) p.finishMutatedNode(parent) } + case ast.KindShorthandPropertyAssignment: + shorthand := parent.AsShorthandPropertyAssignment() + if shorthand.ObjectAssignmentInitializer != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { + shorthand.ObjectAssignmentInitializer = p.makeNewCast( + p.factory.DeepCloneReparse(tag.AsJSDocSatisfiesTag().TypeExpression.Type()), + p.factory.DeepCloneReparse(shorthand.ObjectAssignmentInitializer), + false /*isAssertion*/) + p.finishMutatedNode(parent) + } case ast.KindReturnStatement, ast.KindParenthesizedExpression, ast.KindExportAssignment, ast.KindJSExportAssignment: if parent.Expression() != nil && tag.AsJSDocSatisfiesTag().TypeExpression != nil { diff --git a/pkg/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a b/pkg/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a index 6bd4a7bcd..dff3eb936 100644 --- a/pkg/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a +++ b/pkg/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a @@ -1,5 +1,6 @@ go test fuzz v1 string(".ts") -string("/**@0\n * */0") -int32(99) -uint8(0) +string("") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 b/pkg/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 new file mode 100644 index 000000000..3199b9709 --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/0ec0d5de7f0264d9 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("00000000000000000000000000000000000000000000000000000000000\"00000000000000000000000\n/**@type */return") +byte('\x00') +bool(true) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 b/pkg/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 new file mode 100644 index 000000000..702503625 --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/3d59c16f3abc20e1 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/**@typedef @type object00") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff b/pkg/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff new file mode 100644 index 000000000..fb1b7aa81 --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/4c0324cd37d955ff @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("@00await") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/6944735deac09149 b/pkg/parser/testdata/fuzz/FuzzParser/6944735deac09149 new file mode 100644 index 000000000..c9caf93eb --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/6944735deac09149 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/*/") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 b/pkg/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 new file mode 100644 index 000000000..8a57001ea --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/7d4c688e1df61349 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("0%{\n/**@satisfies */A") +byte('\x00') +bool(true) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe b/pkg/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe index 7ba034ca1..dff3eb936 100644 --- a/pkg/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe +++ b/pkg/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe @@ -1,5 +1,6 @@ go test fuzz v1 string(".ts") -string("/") -int32(99) -uint8(1) +string("") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 b/pkg/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 new file mode 100644 index 000000000..505e4516a --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/c5dc3279768e5a11 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string("/**") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca b/pkg/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca new file mode 100644 index 000000000..14b3a7639 --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/f48591d3b8f41eca @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".js") +string("c(0000{\n/**@overload */get 0") +byte('\x00') +bool(false) +bool(true) diff --git a/pkg/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 b/pkg/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 new file mode 100644 index 000000000..315b16bfa --- /dev/null +++ b/pkg/parser/testdata/fuzz/FuzzParser/f6dbdaa8568c9488 @@ -0,0 +1,6 @@ +go test fuzz v1 +string(".ts") +string(")import A,await") +byte('\x00') +bool(false) +bool(false) diff --git a/pkg/parser/utilities.go b/pkg/parser/utilities.go index ba7a19eb5..578b9d665 100644 --- a/pkg/parser/utilities.go +++ b/pkg/parser/utilities.go @@ -41,7 +41,9 @@ func GetJSDocCommentRanges(f *ast.NodeFactory, commentRanges []ast.CommentRange, } // Keep if the comment starts with '/**' but not if it is '/**/' return slices.DeleteFunc(commentRanges, func(comment ast.CommentRange) bool { - return comment.End() > node.End() || text[comment.Pos()+1] != '*' || text[comment.Pos()+2] != '*' || text[comment.Pos()+3] == '/' + commentStart := comment.Pos() + commentLen := comment.End() - commentStart + return comment.End() > node.End() || commentLen < 4 || text[commentStart+1] != '*' || text[commentStart+2] != '*' || text[commentStart+3] == '/' }) } diff --git a/pkg/transformers/declarations/transform.go b/pkg/transformers/declarations/transform.go index aa373fc9d..59b9e054c 100644 --- a/pkg/transformers/declarations/transform.go +++ b/pkg/transformers/declarations/transform.go @@ -1343,7 +1343,7 @@ func (tx *DeclarationTransformer) transformClassDeclaration(input *ast.ClassDecl modifiers := tx.ensureModifiers(input.AsNode()) typeParameters := tx.ensureTypeParams(input.AsNode(), input.TypeParameters) - ctor := getFirstConstructorWithBody(input.AsNode()) + ctor := ast.GetFirstConstructorWithBody(input.AsNode()) var parameterProperties []*ast.Node if ctor != nil { oldDiag := tx.state.getSymbolAccessibilityDiagnostic diff --git a/pkg/transformers/declarations/util.go b/pkg/transformers/declarations/util.go index d6f7e810c..50de98b22 100644 --- a/pkg/transformers/declarations/util.go +++ b/pkg/transformers/declarations/util.go @@ -203,15 +203,6 @@ func shouldEmitFunctionProperties(input *ast.FunctionDeclaration) bool { return len(overloadSignatures) == 0 || overloadSignatures[len(overloadSignatures)-1] == input.AsNode() } -func getFirstConstructorWithBody(node *ast.Node) *ast.Node { - for _, member := range node.Members() { - if ast.IsConstructorDeclaration(member) && ast.NodeIsPresent(member.Body()) { - return member - } - } - return nil -} - func getEffectiveBaseTypeNode(node *ast.Node) *ast.Node { baseType := ast.GetClassExtendsHeritageElement(node) // !!! TODO: JSDoc support diff --git a/pkg/transformers/moduletransforms/commonjsmodule.go b/pkg/transformers/moduletransforms/commonjsmodule.go index 4f60263d2..3226f13bc 100644 --- a/pkg/transformers/moduletransforms/commonjsmodule.go +++ b/pkg/transformers/moduletransforms/commonjsmodule.go @@ -247,7 +247,7 @@ func (tx *CommonJSModuleTransformer) visitSourceFile(node *ast.SourceFile) *ast. func (tx *CommonJSModuleTransformer) shouldEmitUnderscoreUnderscoreESModule() bool { if tspath.FileExtensionIsOneOf(tx.currentSourceFile.FileName(), tspath.SupportedJSExtensionsFlat) && tx.currentSourceFile.CommonJSModuleIndicator != nil && - (tx.currentSourceFile.ExternalModuleIndicator == nil /*|| tx.currentSourceFile.ExternalModuleIndicator == true*/) { // !!! + (tx.currentSourceFile.ExternalModuleIndicator == nil || tx.currentSourceFile.ExternalModuleIndicator.Kind == ast.KindSourceFile) { return false } if tx.currentModuleInfo.exportEquals == nil && ast.IsExternalModule(tx.currentSourceFile) { diff --git a/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js index 0f64fde1d..76829952b 100644 --- a/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js +++ b/testdata/baselines/reference/compiler/jsDeclarationExportDefaultAssignmentCrash.js @@ -7,8 +7,6 @@ exports.default = () => { //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var default = () => { return 1234; }; diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt index 1fafa07a8..6914d1436 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt @@ -1,6 +1,4 @@ ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. -ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. -ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. ==== typing.d.ts (0 errors) ==== @@ -12,7 +10,7 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type } export = BaseClass; } -==== ExtendedClass.js (3 errors) ==== +==== ExtendedClass.js (1 errors) ==== define("lib/ExtendedClass", ["deps/BaseClass"], /** * {typeof import("deps/BaseClass")} @@ -32,9 +30,5 @@ ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type module.exports = ExtendedClass ~~~~~~ !!! error TS1231: An export assignment must be at the top level of a file or module declaration. - ~~~~~~~ -!!! error TS2339: Property 'exports' does not exist on type '{}'. return module.exports; - ~~~~~~~ -!!! error TS2339: Property 'exports' does not exist on type '{}'. }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff index c2a498e7f..51c1d157e 100644 --- a/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/amdLikeInputDeclarationEmit.errors.txt.diff @@ -3,8 +3,6 @@ @@= skipped -0, +0 lines =@@ - +ExtendedClass.js(17,5): error TS1231: An export assignment must be at the top level of a file or module declaration. -+ExtendedClass.js(17,12): error TS2339: Property 'exports' does not exist on type '{}'. -+ExtendedClass.js(18,19): error TS2339: Property 'exports' does not exist on type '{}'. + + +==== typing.d.ts (0 errors) ==== @@ -16,7 +14,7 @@ + } + export = BaseClass; + } -+==== ExtendedClass.js (3 errors) ==== ++==== ExtendedClass.js (1 errors) ==== + define("lib/ExtendedClass", ["deps/BaseClass"], + /** + * {typeof import("deps/BaseClass")} @@ -36,9 +34,5 @@ + module.exports = ExtendedClass + ~~~~~~ +!!! error TS1231: An export assignment must be at the top level of a file or module declaration. -+ ~~~~~~~ -+!!! error TS2339: Property 'exports' does not exist on type '{}'. + return module.exports; -+ ~~~~~~~ -+!!! error TS2339: Property 'exports' does not exist on type '{}'. + }); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt deleted file mode 100644 index eec29dde0..000000000 --- a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -index.js(3,8): error TS2339: Property 'devtools' does not exist on type '{}'. - - -==== index.js (1 errors) ==== - var chrome = {} - Object.defineProperty(chrome, 'devtools', { value: {}, enumerable: true }) - chrome.devtools.inspectedWindow = {} - ~~~~~~~~ -!!! error TS2339: Property 'devtools' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt.diff deleted file mode 100644 index 9ab1f70ba..000000000 --- a/testdata/baselines/reference/submodule/compiler/jsExpandoObjectDefineProperty.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.jsExpandoObjectDefineProperty.errors.txt -+++ new.jsExpandoObjectDefineProperty.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(3,8): error TS2339: Property 'devtools' does not exist on type '{}'. -+ -+ -+==== index.js (1 errors) ==== -+ var chrome = {} -+ Object.defineProperty(chrome, 'devtools', { value: {}, enumerable: true }) -+ chrome.devtools.inspectedWindow = {} -+ ~~~~~~~~ -+!!! error TS2339: Property 'devtools' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js index 6a374721c..8fbcf1ca1 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js @@ -55,11 +55,9 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.js] -"use strict"; // These are a few examples of existing alternative uses of @overload tag. // They will not work as expected with our implementation, but we are // trying to make sure that our changes do not result in any crashes here. -Object.defineProperty(exports, "__esModule", { value: true }); const example1 = { /** * @overload Example1(value) @@ -108,17 +106,115 @@ const example3 = { //// [jsFileAlternativeUseOfOverloadTag.d.ts] +declare function Example1(value: any): any; +declare const example1: { + /** + * @overload Example1(value) + * Creates Example1 + * @param value [String] + */ + constructor: (value: any, options: any) => void; +}; +declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; +declare function Example2(): any; +declare const example2: { + /** + * Example 2 + * + * @overload Example2(value) + * Creates Example2 + * @param value [String] + * @param secretAccessKey [String] + * @param sessionToken [String] + * @example Creates with string value + * const example = new Example(''); + * @overload Example2(options) + * Creates Example2 + * @option options value [String] + * @example Creates with options object + * const example = new Example2({ + * value: '', + * }); + */ + constructor: () => void; +}; +declare function evaluate(): any; export type callback = (error: any, result: any) ; +declare const example3: { + /** + * @overload evaluate(options = {}, [callback]) + * Evaluate something + * @note Something interesting + * @param options [map] + * @return [string] returns evaluation result + * @return [null] returns nothing if callback provided + * @callback callback function (error, result) + * If callback is provided it will be called with evaluation result + * @param error [Error] + * @param result [String] + * @see callback + */ + evaluate: (options: any, callback: any) => void; +}; //// [DtsFileErrors] -dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. +dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,50): error TS1005: '=>' expected. ==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== + declare function Example1(value: any): any; + declare const example1: { + /** + * @overload Example1(value) + * Creates Example1 + * @param value [String] + */ + constructor: (value: any, options: any) => void; + }; + declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; + declare function Example2(): any; + declare const example2: { + /** + * Example 2 + * + * @overload Example2(value) + * Creates Example2 + * @param value [String] + * @param secretAccessKey [String] + * @param sessionToken [String] + * @example Creates with string value + * const example = new Example(''); + * @overload Example2(options) + * Creates Example2 + * @option options value [String] + * @example Creates with options object + * const example = new Example2({ + * value: '', + * }); + */ + constructor: () => void; + }; + declare function evaluate(): any; export type callback = (error: any, result: any) ; ~ !!! error TS1005: '=>' expected. + declare const example3: { + /** + * @overload evaluate(options = {}, [callback]) + * Evaluate something + * @note Something interesting + * @param options [map] + * @return [string] returns evaluation result + * @return [null] returns nothing if callback provided + * @callback callback function (error, result) + * If callback is provided it will be called with evaluation result + * @param error [Error] + * @param result [String] + * @see callback + */ + evaluate: (options: any, callback: any) => void; + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff index 8dae32a23..e6be9c01f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff +++ b/testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff @@ -1,27 +1,17 @@ --- old.jsFileAlternativeUseOfOverloadTag.js +++ new.jsFileAlternativeUseOfOverloadTag.js -@@= skipped -54, +54 lines =@@ - - - //// [jsFileAlternativeUseOfOverloadTag.js] -+"use strict"; - // These are a few examples of existing alternative uses of @overload tag. - // They will not work as expected with our implementation, but we are - // trying to make sure that our changes do not result in any crashes here. -+Object.defineProperty(exports, "__esModule", { value: true }); - const example1 = { - /** - * @overload Example1(value) -@@= skipped -51, +53 lines =@@ +@@= skipped -105, +105 lines =@@ //// [jsFileAlternativeUseOfOverloadTag.d.ts] -declare namespace example1 { -- /** -- * @overload Example1(value) -- * Creates Example1 -- * @param value [String] -- */ ++declare function Example1(value: any): any; ++declare const example1: { + /** + * @overload Example1(value) + * Creates Example1 + * @param value [String] + */ - function constructor(value: any): any; -} -declare namespace example2 { @@ -66,19 +56,41 @@ - export { constructor_1 as constructor }; -} -declare namespace example3 { -- /** -- * @overload evaluate(options = {}, [callback]) -- * Evaluate something -- * @note Something interesting -- * @param options [map] -- * @return [string] returns evaluation result -- * @return [null] returns nothing if callback provided -- * @callback callback function (error, result) -- * If callback is provided it will be called with evaluation result -- * @param error [Error] -- * @param result [String] -- * @see callback -- */ ++ constructor: (value: any, options: any) => void; ++}; ++declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; ++declare function Example2(): any; ++declare const example2: { ++ /** ++ * Example 2 ++ * ++ * @overload Example2(value) ++ * Creates Example2 ++ * @param value [String] ++ * @param secretAccessKey [String] ++ * @param sessionToken [String] ++ * @example Creates with string value ++ * const example = new Example(''); ++ * @overload Example2(options) ++ * Creates Example2 ++ * @option options value [String] ++ * @example Creates with options object ++ * const example = new Example2({ ++ * value: '', ++ * }); ++ */ ++ constructor: () => void; ++}; ++declare function evaluate(): any; ++export type callback = (error: any, result: any) ; ++declare const example3: { + /** + * @overload evaluate(options = {}, [callback]) + * Evaluate something +@@= skipped -63, +48 lines =@@ + * @param result [String] + * @see callback + */ - function evaluate(): any; -} -/** @@ -86,17 +98,67 @@ - * If callback is provided it will be called with evaluation result - */ -type callback = (error: any, result: any) => any; -+export type callback = (error: any, result: any) ; ++ evaluate: (options: any, callback: any) => void; ++}; + + +//// [DtsFileErrors] + + -+dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected. ++dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,50): error TS1005: '=>' expected. + + +==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ==== ++ declare function Example1(value: any): any; ++ declare const example1: { ++ /** ++ * @overload Example1(value) ++ * Creates Example1 ++ * @param value [String] ++ */ ++ constructor: (value: any, options: any) => void; ++ }; ++ declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any; ++ declare function Example2(): any; ++ declare const example2: { ++ /** ++ * Example 2 ++ * ++ * @overload Example2(value) ++ * Creates Example2 ++ * @param value [String] ++ * @param secretAccessKey [String] ++ * @param sessionToken [String] ++ * @example Creates with string value ++ * const example = new Example(''); ++ * @overload Example2(options) ++ * Creates Example2 ++ * @option options value [String] ++ * @example Creates with options object ++ * const example = new Example2({ ++ * value: '', ++ * }); ++ */ ++ constructor: () => void; ++ }; ++ declare function evaluate(): any; + export type callback = (error: any, result: any) ; + ~ +!!! error TS1005: '=>' expected. ++ declare const example3: { ++ /** ++ * @overload evaluate(options = {}, [callback]) ++ * Evaluate something ++ * @note Something interesting ++ * @param options [map] ++ * @return [string] returns evaluation result ++ * @return [null] returns nothing if callback provided ++ * @callback callback function (error, result) ++ * If callback is provided it will be called with evaluation result ++ * @param error [Error] ++ * @param result [String] ++ * @see callback ++ */ ++ evaluate: (options: any, callback: any) => void; ++ }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt index 7f1f8dbaf..2a64d7ccf 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt @@ -2,7 +2,6 @@ /main1.ts(3,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /main1.ts(19,4): error TS2339: Property 'default' does not exist on type '() => void'. /main1.ts(23,8): error TS1192: Module '"/e"' has no default export. -/main1.ts(30,4): error TS2339: Property 'default' does not exist on type '0'. /main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'. /main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /main2.mts(14,8): error TS1192: Module '"/e"' has no default export. @@ -43,7 +42,7 @@ ==== /g.js (0 errors) ==== exports.default = 0; -==== /main1.ts (4 errors) ==== +==== /main1.ts (3 errors) ==== import { x, y } from "./a"; // No y import a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS @@ -80,8 +79,6 @@ import g1 from "./g"; // { default: 0 } g1.default; - ~~~~~~~ -!!! error TS2339: Property 'default' does not exist on type '0'. import g2 = require("./g"); // { default: 0 } g2.default; diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt.diff index 4a43b58d4..63b7095c8 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.errors.txt.diff @@ -8,7 +8,6 @@ /main1.ts(19,4): error TS2339: Property 'default' does not exist on type '() => void'. /main1.ts(23,8): error TS1192: Module '"/e"' has no default export. -/main2.mts(1,13): error TS2305: Module '"./a"' has no exported member 'y'. -+/main1.ts(30,4): error TS2339: Property 'default' does not exist on type '0'. /main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'. /main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /main2.mts(14,8): error TS1192: Module '"/e"' has no default export. @@ -18,7 +17,7 @@ /main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. /main3.cjs(5,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. /main3.cjs(8,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. -@@= skipped -18, +16 lines =@@ +@@= skipped -18, +15 lines =@@ /main3.cjs(17,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. @@ -31,21 +30,19 @@ ==== /b.ts (0 errors) ==== export default 0; -@@= skipped -30, +28 lines =@@ +@@= skipped -28, +26 lines =@@ + ==== /g.js (0 errors) ==== + exports.default = 0; - ==== /main1.ts (4 errors) ==== +-==== /main1.ts (4 errors) ==== ++==== /main1.ts (3 errors) ==== import { x, y } from "./a"; // No y - ~ -!!! error TS2305: Module '"./a"' has no exported member 'y'. import a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS ~~~~~~~ -@@= skipped -37, +35 lines =@@ - - import g1 from "./g"; // { default: 0 } - g1.default; -+ ~~~~~~~ -+!!! error TS2339: Property 'default' does not exist on type '0'. +@@= skipped -42, +40 lines =@@ import g2 = require("./g"); // { default: 0 } g2.default; @@ -57,7 +54,7 @@ import a1 = require("./a"); // { x: 0 } a1.x; a1.default.x; // Arguably should exist but doesn't -@@= skipped -38, +38 lines =@@ +@@= skipped -35, +33 lines =@@ ~ !!! error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'. ~ diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols b/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols index ec9a19af9..3cace490b 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols @@ -133,15 +133,17 @@ import g1 from "./g"; // { default: 0 } >g1 : Symbol(g1, Decl(main1.ts, 28, 6)) g1.default; +>g1.default : Symbol(g1.default, Decl(g.js, 0, 0)) >g1 : Symbol(g1, Decl(main1.ts, 28, 6)) +>default : Symbol(g1.default, Decl(g.js, 0, 0)) import g2 = require("./g"); // { default: 0 } >g2 : Symbol(g2, Decl(main1.ts, 29, 11)) g2.default; ->g2.default : Symbol(g1, Decl(g.js, 0, 0)) +>g2.default : Symbol(g1.default, Decl(g.js, 0, 0)) >g2 : Symbol(g2, Decl(main1.ts, 29, 11)) ->default : Symbol(g1, Decl(g.js, 0, 0)) +>default : Symbol(g1.default, Decl(g.js, 0, 0)) === /main2.mts === import { x, y } from "./a"; // No y @@ -257,7 +259,7 @@ import g1 from "./g"; // { default: 0 } const g2 = require("./g"); // { default: 0 } >g2 : Symbol(g2, Decl(main3.cjs, 17, 5)) >require : Symbol(require) ->"./g" : Symbol(g2, Decl(g.js, 0, 0)) +>"./g" : Symbol(g1, Decl(g.js, 0, 0)) === /main4.cjs === exports.x = require("./g"); diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols.diff b/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols.diff index 2cf5e1aeb..6d95c25f3 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.symbols.diff @@ -21,33 +21,7 @@ >default : Symbol(default, Decl(g.js, 0, 0)) === /main1.ts === -@@= skipped -96, +96 lines =@@ - >g1 : Symbol(g1, Decl(main1.ts, 28, 6)) - - g1.default; -->g1.default : Symbol(g1.default, Decl(g.js, 0, 0)) - >g1 : Symbol(g1, Decl(main1.ts, 28, 6)) -->default : Symbol(g1.default, Decl(g.js, 0, 0)) - - import g2 = require("./g"); // { default: 0 } - >g2 : Symbol(g2, Decl(main1.ts, 29, 11)) - - g2.default; -->g2.default : Symbol(g1.default, Decl(g.js, 0, 0)) -+>g2.default : Symbol(g1, Decl(g.js, 0, 0)) - >g2 : Symbol(g2, Decl(main1.ts, 29, 11)) -->default : Symbol(g1.default, Decl(g.js, 0, 0)) -+>default : Symbol(g1, Decl(g.js, 0, 0)) - - === /main2.mts === - import { x, y } from "./a"; // No y -@@= skipped -126, +124 lines =@@ - const g2 = require("./g"); // { default: 0 } - >g2 : Symbol(g2, Decl(main3.cjs, 17, 5)) - >require : Symbol(require) -->"./g" : Symbol(g1, Decl(g.js, 0, 0)) -+>"./g" : Symbol(g2, Decl(g.js, 0, 0)) - +@@= skipped -227, +227 lines =@@ === /main4.cjs === exports.x = require("./g"); >exports.x : Symbol(x, Decl(main4.cjs, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.types b/testdata/baselines/reference/submodule/compiler/modulePreserve4.types index 868beda53..cb6b2aaba 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.types +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.types @@ -152,19 +152,19 @@ f2.default; >default : 0 import g1 from "./g"; // { default: 0 } ->g1 : 0 +>g1 : typeof g1 g1.default; ->g1.default : any ->g1 : 0 ->default : any +>g1.default : 0 +>g1 : typeof g1 +>default : 0 import g2 = require("./g"); // { default: 0 } ->g2 : typeof g2 +>g2 : typeof g1 g2.default; >g2.default : 0 ->g2 : typeof g2 +>g2 : typeof g1 >default : 0 === /main2.mts === @@ -224,10 +224,10 @@ import f2 = require("./f.cjs"); // { default: 0 } >f2 : typeof f2 import g1 from "./g"; // { default: 0 } ->g1 : 0 +>g1 : typeof g1 import g2 = require("./g"); // { default: 0 } ->g2 : typeof g2 +>g2 : typeof g1 === /main3.cjs === import { x, y } from "./a"; // No y @@ -289,11 +289,11 @@ const f2 = require("./f.cjs"); // { default: 0 } >"./f.cjs" : "./f.cjs" import g1 from "./g"; // { default: 0 } ->g1 : 0 +>g1 : typeof g1 const g2 = require("./g"); // { default: 0 } ->g2 : typeof g2 ->require("./g") : typeof g2 +>g2 : typeof g1 +>require("./g") : typeof g1 >require : any >"./g" : "./g" diff --git a/testdata/baselines/reference/submodule/compiler/modulePreserve4.types.diff b/testdata/baselines/reference/submodule/compiler/modulePreserve4.types.diff index 632c2c34e..0c92c4837 100644 --- a/testdata/baselines/reference/submodule/compiler/modulePreserve4.types.diff +++ b/testdata/baselines/reference/submodule/compiler/modulePreserve4.types.diff @@ -26,31 +26,7 @@ import a1 = require("./a"); // { x: 0 } >a1 : typeof a1 -@@= skipped -101, +101 lines =@@ - >default : 0 - - import g1 from "./g"; // { default: 0 } -->g1 : typeof g1 -+>g1 : 0 - - g1.default; -->g1.default : 0 -->g1 : typeof g1 -->default : 0 -+>g1.default : any -+>g1 : 0 -+>default : any - - import g2 = require("./g"); // { default: 0 } -->g2 : typeof g1 -+>g2 : typeof g2 - - g2.default; - >g2.default : 0 -->g2 : typeof g1 -+>g2 : typeof g2 - >default : 0 - +@@= skipped -119, +119 lines =@@ === /main2.mts === import { x, y } from "./a"; // No y >x : 0 @@ -59,17 +35,7 @@ import a1 = require("./a"); // { x: 0 } >a1 : typeof a1 -@@= skipped -72, +72 lines =@@ - >f2 : typeof f2 - - import g1 from "./g"; // { default: 0 } -->g1 : typeof g1 -+>g1 : 0 - - import g2 = require("./g"); // { default: 0 } -->g2 : typeof g1 -+>g2 : typeof g2 - +@@= skipped -62, +62 lines =@@ === /main3.cjs === import { x, y } from "./a"; // No y >x : 0 @@ -77,18 +43,4 @@ +>y : 0 import a1 = require("./a"); // Error in JS - >a1 : typeof a1 -@@= skipped -65, +65 lines =@@ - >"./f.cjs" : "./f.cjs" - - import g1 from "./g"; // { default: 0 } -->g1 : typeof g1 -+>g1 : 0 - - const g2 = require("./g"); // { default: 0 } -->g2 : typeof g1 -->require("./g") : typeof g1 -+>g2 : typeof g2 -+>require("./g") : typeof g2 - >require : any - >"./g" : "./g" + >a1 : typeof a1 \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js b/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js index 08eb0d982..92605e72b 100644 --- a/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js +++ b/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js @@ -22,8 +22,6 @@ exports.equal() /// var myAssert = require('assert'); //// [app.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var equal = myAssert.equal; exports.equal = myAssert.equal; exports.equal(); diff --git a/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js.diff b/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js.diff index ed275fe23..5a80a0943 100644 --- a/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js.diff +++ b/testdata/baselines/reference/submodule/compiler/resolveNameWithNamspace.js.diff @@ -4,8 +4,6 @@ /// var myAssert = require('assert'); //// [app.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var equal = myAssert.equal; exports.equal = myAssert.equal; exports.equal(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js index 89dd2c754..7c518b3b9 100644 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js +++ b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js @@ -14,5 +14,7 @@ interface GlobalThing { a: number } const a: GlobalThing = { a: 0 }; //// [usage.js] +"use strict"; /// +Object.defineProperty(exports, "__esModule", { value: true }); const a = { a: 0 }; diff --git a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js.diff b/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js.diff deleted file mode 100644 index c91fa848d..000000000 --- a/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.tripleSlashTypesReferenceWithMissingExports(module=node18).js -+++ new.tripleSlashTypesReferenceWithMissingExports(module=node18).js -@@= skipped -13, +13 lines =@@ - const a: GlobalThing = { a: 0 }; - - //// [usage.js] --"use strict"; - /// --Object.defineProperty(exports, "__esModule", { value: true }); - const a = { a: 0 }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js index 54f30a42d..99874afc2 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js +++ b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js @@ -8,8 +8,6 @@ exports.y = 2; //// [assignmentToVoidZero1.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // #38552 export var y = exports.x = void 0; // #38552 diff --git a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js.diff b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js.diff index 714b31fe2..704fed10b 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero1.js.diff @@ -1,14 +1,11 @@ --- old.assignmentToVoidZero1.js +++ new.assignmentToVoidZero1.js -@@= skipped -7, +7 lines =@@ - +@@= skipped -8, +8 lines =@@ //// [assignmentToVoidZero1.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+// #38552 -+export var y = exports.x = void 0; // #38552 ++export var y = exports.x = void 0; ++// #38552 exports.y = exports.x = void 0; +export var x = 1; exports.x = 1; diff --git a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js index 9b3221fcf..b9180916a 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js +++ b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js @@ -21,8 +21,6 @@ j + k //// [assignmentToVoidZero2.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var j = 1; exports.j = 1; export var k = void 0; diff --git a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js.diff b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js.diff index 1e6837ef2..bc38ad680 100644 --- a/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/assignmentToVoidZero2.js.diff @@ -4,15 +4,13 @@ //// [assignmentToVoidZero2.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var j = 1; exports.j = 1; +export var k = void 0; exports.k = void 0; var o = {}; o.x = 1; -@@= skipped -20, +24 lines =@@ +@@= skipped -20, +22 lines =@@ //// [assignmentToVoidZero2.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js index e4a6e2d04..6021aa159 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js @@ -33,3 +33,9 @@ export type WorksWithPeopleCallback = (person: { name: string; age?: number; }) => void; +/** + * For each person, calls your callback. + * @param {WorksWithPeopleCallback} callback + * @returns {void} + */ +declare function eachPerson(callback: WorksWithPeopleCallback): void; diff --git a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js.diff b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js.diff index 9a6867a5c..8fe8a594c 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js.diff +++ b/testdata/baselines/reference/submodule/conformance/callbackTagNestedParameter.js.diff @@ -4,14 +4,17 @@ * @param {number} [person.age] * @returns {void} */ --/** -- * For each person, calls your callback. -- * @param {WorksWithPeopleCallback} callback -- * @returns {void} -- */ --declare function eachPerson(callback: WorksWithPeopleCallback): void; --type WorksWithPeopleCallback = (person: { +export type WorksWithPeopleCallback = (person: { - name: string; - age?: number; - }) => void; \ No newline at end of file ++ name: string; ++ age?: number; ++}) => void; + /** + * For each person, calls your callback. + * @param {WorksWithPeopleCallback} callback + * @returns {void} + */ + declare function eachPerson(callback: WorksWithPeopleCallback): void; +-type WorksWithPeopleCallback = (person: { +- name: string; +- age?: number; +-}) => void; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt index 809cd632f..c58053a43 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt @@ -1,9 +1,8 @@ 0.js(6,21): error TS1003: Identifier expected. -0.js(8,9): error TS2339: Property 'SomeName' does not exist on type '{}'. 0.js(10,12): error TS2503: Cannot find namespace 'exports'. -==== 0.js (3 errors) ==== +==== 0.js (2 errors) ==== // @ts-check var exports = {}; @@ -15,8 +14,6 @@ !!! error TS1003: Identifier expected. exports.SomeName; - ~~~~~~~~ -!!! error TS2339: Property 'SomeName' does not exist on type '{}'. /** @type {exports.SomeName} */ ~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff index 2b38c2bb6..d1155e527 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefOnlySourceFile.errors.txt.diff @@ -6,11 +6,10 @@ - -==== 0.js (1 errors) ==== +0.js(6,21): error TS1003: Identifier expected. -+0.js(8,9): error TS2339: Property 'SomeName' does not exist on type '{}'. +0.js(10,12): error TS2503: Cannot find namespace 'exports'. + + -+==== 0.js (3 errors) ==== ++==== 0.js (2 errors) ==== // @ts-check var exports = {}; @@ -22,8 +21,6 @@ + +!!! error TS1003: Identifier expected. exports.SomeName; -+ ~~~~~~~~ -+!!! error TS2339: Property 'SomeName' does not exist on type '{}'. /** @type {exports.SomeName} */ - ~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js index fd0f4efd9..9f452a138 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js @@ -18,8 +18,6 @@ var diddy = funky(1) //// [commonJSAliasedExport.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const donkey = (ast) => ast; function funky(declaration) { return false; diff --git a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js.diff b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js.diff index 8f7d21d18..bc1e674cb 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js.diff +++ b/testdata/baselines/reference/submodule/conformance/commonJSAliasedExport.js.diff @@ -1,13 +1,6 @@ --- old.commonJSAliasedExport.js +++ new.commonJSAliasedExport.js -@@= skipped -17, +17 lines =@@ - - - //// [commonJSAliasedExport.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - const donkey = (ast) => ast; - function funky(declaration) { +@@= skipped -22, +22 lines =@@ return false; } module.exports = donkey; @@ -15,7 +8,7 @@ module.exports.funky = funky; //// [bug43713.js] const { funky } = require('./commonJSAliasedExport'); -@@= skipped -14, +17 lines =@@ +@@= skipped -9, +10 lines =@@ //// [commonJSAliasedExport.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js index 6d25b4835..75639dc8f 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js @@ -18,7 +18,6 @@ exports.K = K; //// [mod1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); class K { values() { return new K(); diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js.diff b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js.diff index b8983fb6e..6f1f5c052 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js.diff +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportClassTypeReference.js.diff @@ -1,12 +1,6 @@ --- old.commonJSImportClassTypeReference.js +++ new.commonJSImportClassTypeReference.js -@@= skipped -17, +17 lines =@@ - - //// [mod1.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - class K { - values() { +@@= skipped -22, +22 lines =@@ return new K(); } } @@ -14,7 +8,7 @@ exports.K = K; //// [main.js] "use strict"; -@@= skipped -16, +18 lines =@@ +@@= skipped -11, +12 lines =@@ //// [mod1.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js index 60789d061..ab7a08c87 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js @@ -16,7 +16,6 @@ exports.K = class K { //// [mod1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var K = class K { values() { } diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js.diff b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js.diff index eedc85ac5..b9fb130cc 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportExportedClassExpression.js.diff @@ -4,7 +4,6 @@ //// [mod1.js] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var K = class K { + values() { + } @@ -12,7 +11,7 @@ exports.K = class K { values() { } -@@= skipped -14, +19 lines =@@ +@@= skipped -14, +18 lines =@@ //// [mod1.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js index bd6dfdc33..f09940564 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js @@ -19,7 +19,6 @@ exports.K = NS.K; //// [mod1.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); var NS = {}; NS.K = class { values() { diff --git a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js.diff b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js.diff index 263c8c011..670320d42 100644 --- a/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js.diff +++ b/testdata/baselines/reference/submodule/conformance/commonJSImportNestedClassTypeReference.js.diff @@ -1,13 +1,6 @@ --- old.commonJSImportNestedClassTypeReference.js +++ new.commonJSImportNestedClassTypeReference.js -@@= skipped -18, +18 lines =@@ - - //// [mod1.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - var NS = {}; - NS.K = class { - values() { +@@= skipped -24, +24 lines =@@ return new NS.K(); } }; @@ -15,7 +8,7 @@ exports.K = NS.K; //// [main.js] "use strict"; -@@= skipped -17, +19 lines =@@ +@@= skipped -11, +12 lines =@@ //// [mod1.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt index 800958af5..1d4701cfc 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt @@ -2,10 +2,9 @@ a.js(24,13): error TS2749: 'Target' refers to a value, but is being used as a ty a.js(25,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? a.js(26,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? a.js(35,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? -a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. -==== a.js (5 errors) ==== +==== a.js (4 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -51,8 +50,6 @@ a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: s !!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' - ~~~~~~~ -!!! error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. v = Second.MISTAKE // meh..ok, I guess? v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums } diff --git a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt.diff index 4b31a93b3..3573efea6 100644 --- a/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/enumTag.errors.txt.diff @@ -3,15 +3,17 @@ @@= skipped -0, +0 lines =@@ -a.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. -a.js(12,5): error TS2322: Type 'string' is not assignable to type 'number'. +-a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. +- +- +-==== a.js (3 errors) ==== +a.js(24,13): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? +a.js(25,12): error TS2749: 'Second' refers to a value, but is being used as a type here. Did you mean 'typeof Second'? +a.js(26,12): error TS2749: 'Fs' refers to a value, but is being used as a type here. Did you mean 'typeof Fs'? +a.js(35,16): error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? - a.js(37,16): error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. - - --==== a.js (3 errors) ==== -+==== a.js (5 errors) ==== ++ ++ ++==== a.js (4 errors) ==== /** @enum {string} */ const Target = { START: "start", @@ -31,7 +33,7 @@ OK: 1, /** @type {number} */ FINE: 2, -@@= skipped -31, +29 lines =@@ +@@= skipped -31, +28 lines =@@ } /** @param {Target} t @@ -54,4 +56,8 @@ +!!! error TS2749: 'Target' refers to a value, but is being used as a type here. Did you mean 'typeof Target'? var v = Target.START v = Target.UNKNOWN // error, can't find 'UNKNOWN' - ~~~~~~~ \ No newline at end of file +- ~~~~~~~ +-!!! error TS2339: Property 'UNKNOWN' does not exist on type '{ START: string; MIDDLE: string; END: string; MISTAKE: number; OK_I_GUESS: number; }'. + v = Second.MISTAKE // meh..ok, I guess? + v = 'something else' // allowed, like Typescript's classic enums and unlike its string enums + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt b/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt index 1a32ab8bf..bc613fadb 100644 --- a/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt @@ -1,13 +1,11 @@ test.js(4,5): error TS2339: Property 'config' does not exist on type 'typeof Vue'. -test.js(12,8): error TS2339: Property 'y' does not exist on type '{ x: number; }'. -test.js(14,8): error TS2339: Property 'y' does not exist on type '{ x: number; }'. ==== vue.js (0 errors) ==== export class Vue {} export const config = { x: 0 }; -==== test.js (3 errors) ==== +==== test.js (1 errors) ==== import { Vue, config } from "./vue"; // Expando declarations aren't allowed on aliases. @@ -22,10 +20,6 @@ test.js(14,8): error TS2339: Property 'y' does not exist on type '{ x: number; } // This is not an expando declaration; it works because non-strict JS allows // loosey goosey assignment on objects. config.y = {}; - ~ -!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. config.x; config.y; - ~ -!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt.diff deleted file mode 100644 index 656721018..000000000 --- a/testdata/baselines/reference/submodule/conformance/expandoOnAlias.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.expandoOnAlias.errors.txt -+++ new.expandoOnAlias.errors.txt -@@= skipped -0, +0 lines =@@ - test.js(4,5): error TS2339: Property 'config' does not exist on type 'typeof Vue'. -+test.js(12,8): error TS2339: Property 'y' does not exist on type '{ x: number; }'. -+test.js(14,8): error TS2339: Property 'y' does not exist on type '{ x: number; }'. - - - ==== vue.js (0 errors) ==== - export class Vue {} - export const config = { x: 0 }; - --==== test.js (1 errors) ==== -+==== test.js (3 errors) ==== - import { Vue, config } from "./vue"; - - // Expando declarations aren't allowed on aliases. -@@= skipped -19, +21 lines =@@ - // This is not an expando declaration; it works because non-strict JS allows - // loosey goosey assignment on objects. - config.y = {}; -+ ~ -+!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. - config.x; - config.y; -+ ~ -+!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt index de19b0170..a02025e40 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt @@ -1,14 +1,10 @@ -mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. -use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -==== mod.js (1 errors) ==== +==== mod.js (0 errors) ==== exports.n = {}; exports.n.K = function () { - ~ -!!! error TS2339: Property 'K' does not exist on type '{}'. this.x = 10; } exports.Classic = class { @@ -17,12 +13,10 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (3 errors) ==== +==== use.js (2 errors) ==== import * as s from './mod' var k = new s.n.K() - ~ -!!! error TS2339: Property 'K' does not exist on type '{}'. k.x var classic = new s.Classic() diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt.diff index a86c615df..c15989764 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces.errors.txt.diff @@ -2,17 +2,13 @@ +++ new.exportNestedNamespaces.errors.txt @@= skipped -0, +0 lines =@@ - -+mod.js(2,11): error TS2339: Property 'K' does not exist on type '{}'. -+use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + + -+==== mod.js (1 errors) ==== ++==== mod.js (0 errors) ==== + exports.n = {}; + exports.n.K = function () { -+ ~ -+!!! error TS2339: Property 'K' does not exist on type '{}'. + this.x = 10; + } + exports.Classic = class { @@ -21,12 +17,10 @@ + } + } + -+==== use.js (3 errors) ==== ++==== use.js (2 errors) ==== + import * as s from './mod' + + var k = new s.n.K() -+ ~ -+!!! error TS2339: Property 'K' does not exist on type '{}'. + k.x + var classic = new s.Classic() + diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt index a9af2a61b..fc1092d2a 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt @@ -2,8 +2,6 @@ first.js(1,1): error TS2631: Cannot assign to '"first"' because it is a namespac first.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("first")'. second.js(1,1): error TS2631: Cannot assign to '"second"' because it is a namespace. second.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("second")'. -use.js(3,18): error TS2339: Property 'j' does not exist on type '{}'. -use.js(4,28): error TS2339: Property 'o' does not exist on type '{}'. ==== mod.js (0 errors) ==== @@ -28,13 +26,9 @@ use.js(4,28): error TS2339: Property 'o' does not exist on type '{}'. return v } -==== use.js (2 errors) ==== +==== use.js (0 errors) ==== import * as debug from './mod' debug.formatters.j - ~ -!!! error TS2339: Property 'j' does not exist on type '{}'. var one = debug.formatters.o(1) - ~ -!!! error TS2339: Property 'o' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt.diff index a07b25017..d4c5b4940 100644 --- a/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/exportNestedNamespaces2.errors.txt.diff @@ -5,8 +5,6 @@ first.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("first")'. +second.js(1,1): error TS2631: Cannot assign to '"second"' because it is a namespace. second.js(2,9): error TS2339: Property 'formatters' does not exist on type 'typeof import("second")'. -+use.js(3,18): error TS2339: Property 'j' does not exist on type '{}'. -+use.js(4,28): error TS2339: Property 'o' does not exist on type '{}'. ==== mod.js (0 errors) ==== @@ -29,18 +27,4 @@ +!!! error TS2631: Cannot assign to '"second"' because it is a namespace. exports.formatters.o = function (v) { ~~~~~~~~~~ - !!! error TS2339: Property 'formatters' does not exist on type 'typeof import("second")'. - return v - } - --==== use.js (0 errors) ==== -+==== use.js (2 errors) ==== - import * as debug from './mod' - - debug.formatters.j -+ ~ -+!!! error TS2339: Property 'j' does not exist on type '{}'. - var one = debug.formatters.o(1) -+ ~ -+!!! error TS2339: Property 'o' does not exist on type '{}'. - \ No newline at end of file + !!! error TS2339: Property 'formatters' does not exist on type 'typeof import("second")'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js index 31c1fad1c..d37c0296d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js @@ -18,8 +18,6 @@ class Bar { } module.exports = Bar; //// [cls.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const Bar = require("./bar"); const Strings = { a: "A", diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js.diff index c93936877..568fd10cb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassExtendsVisibility.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsClassExtendsVisibility.js +++ new.jsDeclarationsClassExtendsVisibility.js -@@= skipped -17, +17 lines =@@ - } - module.exports = Bar; - //// [cls.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - const Bar = require("./bar"); - const Strings = { - a: "A", -@@= skipped -8, +10 lines =@@ +@@= skipped -25, +25 lines =@@ class Foo extends Bar { } module.exports = Foo; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js index 7e863089e..701b2a08a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js @@ -26,8 +26,6 @@ module.exports.Strings = Strings //// [source.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); class Handler { static get OPTIONS() { return 1; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js.diff index bdce0b015..56d9a66f0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClassStatic.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsClassStatic.js +++ new.jsDeclarationsClassStatic.js -@@= skipped -25, +25 lines =@@ - - - //// [source.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - class Handler { - static get OPTIONS() { - return 1; -@@= skipped -13, +15 lines =@@ +@@= skipped -38, +38 lines =@@ b: "B" }; module.exports = Handler; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js index 50e909346..965f8d6f9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js @@ -18,8 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); function validate() { } exports.default = validate; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const m = require("./exporter"); module.exports = m.default; export var memberName = "thing"; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js.diff index 45ae30528..de434879a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsCrossfileMerge.js.diff @@ -1,11 +1,7 @@ --- old.jsDeclarationsCrossfileMerge.js +++ new.jsDeclarationsCrossfileMerge.js -@@= skipped -17, +17 lines =@@ - function validate() { } - exports.default = validate; +@@= skipped -19, +19 lines =@@ //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); const m = require("./exporter"); module.exports = m.default; +export var memberName = "thing"; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js index 3a002970d..c3a4dc55a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js @@ -17,8 +17,6 @@ module.exports.Sub = class { //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); module.exports = class { /** * @param {number} p diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js.diff index 635641bdd..66e636fb2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js +++ new.jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.js -@@= skipped -16, +16 lines =@@ - - - //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - module.exports = class { - /** - * @param {number} p -@@= skipped -8, +10 lines =@@ +@@= skipped -24, +24 lines =@@ this.t = 12 + p; } }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js index 1264eecc3..11608eeab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js @@ -16,8 +16,6 @@ module.exports.Another = Q; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); class A { member = new Q(); } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js.diff index 79f6d0a91..cf99f1dbf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassExpressionShadowing.js.diff @@ -1,11 +1,8 @@ --- old.jsDeclarationsExportAssignedClassExpressionShadowing.js +++ new.jsDeclarationsExportAssignedClassExpressionShadowing.js -@@= skipped -15, +15 lines =@@ - +@@= skipped -16, +16 lines =@@ //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); class A { - constructor() { - this.member = new Q(); diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js index 162fa1507..7a15e1b3e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js @@ -11,8 +11,6 @@ module.exports = new Foo(); module.exports.additional = 20; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); class Foo { static stat = 10; member = 10; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js.diff index 84b0f01f1..026beccd0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedClassInstance3.js.diff @@ -1,11 +1,8 @@ --- old.jsDeclarationsExportAssignedClassInstance3.js +++ new.jsDeclarationsExportAssignedClassInstance3.js -@@= skipped -10, +10 lines =@@ - module.exports.additional = 20; +@@= skipped -11, +11 lines =@@ //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); class Foo { - constructor() { - this.member = 10; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js index 50c7df536..b793c3672 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js @@ -12,8 +12,6 @@ module.exports.MyClass.prototype = { //// [jsDeclarationsExportAssignedConstructorFunction.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** @constructor */ export var MyClass = function () { this.x = 1; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js.diff index a1e3ca15d..b86c8da61 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunction.js.diff @@ -1,19 +1,17 @@ --- old.jsDeclarationsExportAssignedConstructorFunction.js +++ new.jsDeclarationsExportAssignedConstructorFunction.js -@@= skipped -11, +11 lines =@@ - +@@= skipped -12, +12 lines =@@ //// [jsDeclarationsExportAssignedConstructorFunction.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+/** @constructor */ + /** @constructor */ +export var MyClass = function () { + this.x = 1; +}; - /** @constructor */ ++/** @constructor */ module.exports.MyClass = function () { this.x = 1; -@@= skipped -11, +17 lines =@@ + }; +@@= skipped -10, +14 lines =@@ //// [jsDeclarationsExportAssignedConstructorFunction.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js index ace1f067b..f470e836c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js @@ -14,8 +14,6 @@ module.exports.Sub.prototype = { } //// [jsDeclarationsExportAssignedConstructorFunctionWithSub.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @param {number} p */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff index dfb3d0397..881613308 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignedConstructorFunctionWithSub.js.diff @@ -1,14 +1,6 @@ --- old.jsDeclarationsExportAssignedConstructorFunctionWithSub.js +++ new.jsDeclarationsExportAssignedConstructorFunctionWithSub.js -@@= skipped -13, +13 lines =@@ - - - //// [jsDeclarationsExportAssignedConstructorFunctionWithSub.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @param {number} p - */ +@@= skipped -19, +19 lines =@@ module.exports = function (p) { this.t = 12 + p; }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt index c381a8cc3..a3adfdfeb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt @@ -1,8 +1,7 @@ index.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -index.js(12,16): error TS2339: Property 'Strings' does not exist on type '{ thing: string; also: string; desc: { item: string; }; }'. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== const Strings = { a: "A", b: "B" @@ -23,6 +22,4 @@ index.js(12,16): error TS2339: Property 'Strings' does not exist on type '{ thin ~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. module.exports.Strings = Strings; - ~~~~~~~ -!!! error TS2339: Property 'Strings' does not exist on type '{ thing: string; also: string; desc: { item: string; }; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt.diff index b5e42cf6f..67f3321ba 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.errors.txt.diff @@ -3,10 +3,9 @@ @@= skipped -0, +0 lines =@@ - +index.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+index.js(12,16): error TS2339: Property 'Strings' does not exist on type '{ thing: string; also: string; desc: { item: string; }; }'. + + -+==== index.js (2 errors) ==== ++==== index.js (1 errors) ==== + const Strings = { + a: "A", + b: "B" @@ -27,6 +26,4 @@ + ~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + module.exports.Strings = Strings; -+ ~~~~~~~ -+!!! error TS2339: Property 'Strings' does not exist on type '{ thing: string; also: string; desc: { item: string; }; }'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js index 170d8236a..decef9438 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js @@ -16,8 +16,6 @@ module.exports.Strings = Strings; //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const Strings = { a: "A", b: "B" diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js.diff index 71fa78bdf..50b4c75cb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportAssignmentExpressionPlusSecondary.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsExportAssignmentExpressionPlusSecondary.js +++ new.jsDeclarationsExportAssignmentExpressionPlusSecondary.js -@@= skipped -15, +15 lines =@@ - - - //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - const Strings = { - a: "A", - b: "B" -@@= skipped -11, +13 lines =@@ +@@= skipped -26, +26 lines =@@ item: "ok" } }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js index 2eed1f908..abbe90cc0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js @@ -236,14 +236,10 @@ module.exports = { ns }; const ns = require("./cls"); module.exports = ns; //// [cjs3.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const ns = require("./cls"); export var ns = ns; module.exports.ns = ns; //// [cjs4.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const ns = require("./cls"); export var names = ns; module.exports.names = ns; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js.diff index b92e6340b..0a5572f0e 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportForms.js.diff @@ -1,23 +1,18 @@ --- old.jsDeclarationsExportForms.js +++ new.jsDeclarationsExportForms.js -@@= skipped -235, +235 lines =@@ - const ns = require("./cls"); +@@= skipped -236, +236 lines =@@ module.exports = ns; //// [cjs3.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); const ns = require("./cls"); +export var ns = ns; module.exports.ns = ns; //// [cjs4.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); const ns = require("./cls"); +export var names = ns; module.exports.names = ns; //// [includeAll.js] "use strict"; -@@= skipped -21, +27 lines =@@ +@@= skipped -20, +22 lines =@@ //// [cls.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js index a9880502f..803030091 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js @@ -10,8 +10,6 @@ module.exports = Foo; module.exports.Strings = Strings; //// [cls.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const Strings = { a: "A", b: "B" diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js.diff index 679f73626..da5054bf0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportSubAssignments.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsExportSubAssignments.js +++ new.jsDeclarationsExportSubAssignments.js -@@= skipped -9, +9 lines =@@ - module.exports.Strings = Strings; - - //// [cls.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - const Strings = { - a: "A", - b: "B" -@@= skipped -7, +9 lines =@@ +@@= skipped -16, +16 lines =@@ class Foo { } module.exports = Foo; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js index 218ee2e1e..7a2326088 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js @@ -16,8 +16,6 @@ MyClass.staticProperty = 123; */ //// [source.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); module.exports = MyClass; function MyClass() { } MyClass.staticMethod = function () { }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff index 45122829f..5c6c9bb91 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff @@ -1,15 +1,6 @@ --- old.jsDeclarationsFunctionPrototypeStatic.js +++ new.jsDeclarationsFunctionPrototypeStatic.js -@@= skipped -15, +15 lines =@@ - */ - - //// [source.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - module.exports = MyClass; - function MyClass() { } - MyClass.staticMethod = function () { }; -@@= skipped -16, +18 lines =@@ +@@= skipped -31, +31 lines =@@ //// [source.d.ts] export = MyClass; declare function MyClass(): void; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js index e8f0949e9..6ab4694cf 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js @@ -62,8 +62,6 @@ module.exports.j = function j() {} //// [index.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var a = function a() { }; module.exports.a = function a() { }; export var b = function b() { }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js.diff index 014da8651..ded27f170 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.js.diff @@ -4,8 +4,6 @@ //// [index.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var a = function a() { }; module.exports.a = function a() { }; +export var b = function b() { }; @@ -15,7 +13,7 @@ module.exports.c = function c() { }; module.exports.c.Cls = class { }; -@@= skipped -11, +16 lines =@@ +@@= skipped -11, +14 lines =@@ * @param {number} b * @return {string} */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js index e18c40a16..5806719ef 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js @@ -57,7 +57,6 @@ const couldntThinkOfAny = {}; const test = (base) => { return base; }; -export {}; //// [base.d.ts] @@ -70,5 +69,18 @@ declare namespace BaseFactory { } export = BaseFactory; //// [file.d.ts] -export type BaseFactory = import('./base'); +type BaseFactory = import('./base'); export type BaseFactoryFactory = (factory: import('./base')) ; +/** @typedef {import('./base')} BaseFactory */ +/** + * @callback BaseFactoryFactory + * @param {import('./base')} factory + */ +/** @enum {import('./base')} */ +declare const couldntThinkOfAny: {}; +/** + * + * @param {InstanceType} base + * @returns {InstanceType} + */ +declare const test: (base: any) => any; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js.diff index 4b9a4f0dd..192a51589 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js.diff @@ -1,10 +1,6 @@ --- old.jsDeclarationsParameterTagReusesInputNodeInEmit1.js +++ new.jsDeclarationsParameterTagReusesInputNodeInEmit1.js -@@= skipped -56, +56 lines =@@ - const test = (base) => { - return base; - }; -+export {}; +@@= skipped -59, +59 lines =@@ //// [base.d.ts] @@ -28,18 +24,15 @@ - new (): {}; - }; -}; --/** @typedef {import('./base')} BaseFactory */ --/** -- * @callback BaseFactoryFactory -- * @param {import('./base')} factory -- */ --/** @enum {import('./base')} */ --declare const couldntThinkOfAny: {}; --/** -- * -- * @param {InstanceType} base -- * @returns {InstanceType} -- */ ++type BaseFactory = import('./base'); ++export type BaseFactoryFactory = (factory: import('./base')) ; + /** @typedef {import('./base')} BaseFactory */ + /** + * @callback BaseFactoryFactory +@@= skipped -26, +23 lines =@@ + * @param {InstanceType} base + * @returns {InstanceType} + */ -declare function test(base: InstanceType): InstanceType; -type BaseFactory = { - (): {}; @@ -53,5 +46,4 @@ - new (): {}; - }; -}) => any; -+export type BaseFactory = import('./base'); -+export type BaseFactoryFactory = (factory: import('./base')) ; \ No newline at end of file ++declare const test: (base: any) => any; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt deleted file mode 100644 index 1b03e3dea..000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -index.js(5,18): error TS2339: Property 'B' does not exist on type '{}'. - - -==== index.js (1 errors) ==== - /// - - const Something = require("fs").Something; - module.exports.A = {} - module.exports.A.B = { - ~ -!!! error TS2339: Property 'B' does not exist on type '{}'. - thing: new Something() - } - -==== node_modules/@types/node/index.d.ts (0 errors) ==== - declare module "fs" { - export class Something {} - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt.diff deleted file mode 100644 index ef7b94fac..000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsDeclarationsTypeReferences3.errors.txt -+++ new.jsDeclarationsTypeReferences3.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.js(5,18): error TS2339: Property 'B' does not exist on type '{}'. -+ -+ -+==== index.js (1 errors) ==== -+ /// -+ -+ const Something = require("fs").Something; -+ module.exports.A = {} -+ module.exports.A.B = { -+ ~ -+!!! error TS2339: Property 'B' does not exist on type '{}'. -+ thing: new Something() -+ } -+ -+==== node_modules/@types/node/index.d.ts (0 errors) ==== -+ declare module "fs" { -+ export class Something {} -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js index 0469b5358..82f51d131 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js @@ -15,9 +15,7 @@ module.exports.A.B = { //// [index.js] -"use strict"; /// -Object.defineProperty(exports, "__esModule", { value: true }); const Something = require("fs").Something; export var A = {}; module.exports.A = {}; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js.diff index afd05f273..db8c49d5c 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeReferences3.js.diff @@ -1,18 +1,14 @@ --- old.jsDeclarationsTypeReferences3.js +++ new.jsDeclarationsTypeReferences3.js -@@= skipped -14, +14 lines =@@ - - +@@= skipped -16, +16 lines =@@ //// [index.js] -+"use strict"; /// -+Object.defineProperty(exports, "__esModule", { value: true }); const Something = require("fs").Something; +export var A = {}; module.exports.A = {}; module.exports.A.B = { thing: new Something() -@@= skipped -9, +12 lines =@@ +@@= skipped -7, +8 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js index 65b2dbedb..b87ec7836 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js @@ -8,8 +8,6 @@ exports["Does not work yet"] = D; //// [moduleExportAliasElementAccessExpression.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); function D() { } export var D = D; exports["D"] = D; diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js.diff index 5d2f55b2a..1160f9da4 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasElementAccessExpression.js.diff @@ -1,11 +1,8 @@ --- old.moduleExportAliasElementAccessExpression.js +++ new.moduleExportAliasElementAccessExpression.js -@@= skipped -7, +7 lines =@@ - +@@= skipped -8, +8 lines =@@ //// [moduleExportAliasElementAccessExpression.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); function D() { } +export var D = D; exports["D"] = D; diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types index 2a68c7781..87be3adf5 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types @@ -20,6 +20,6 @@ module.exports = alias === importer.js === import('./bug28014') ->import('./bug28014') : Promise<() => void> +>import('./bug28014') : Promise<{ default: () => void; }> >'./bug28014' : "./bug28014" diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types.diff index 23aa34c07..def0b9d72 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.types.diff @@ -31,5 +31,5 @@ === importer.js === import('./bug28014') ->import('./bug28014') : Promise<{ version: 1; default: { (): void; version: 1; }; }> -+>import('./bug28014') : Promise<() => void> ++>import('./bug28014') : Promise<{ default: () => void; }> >'./bug28014' : "./bug28014" diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js index 4ee7030d2..f761fbaae 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js @@ -14,7 +14,6 @@ apply() //// [moduleExportAliasDuplicateAlias.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var apply = undefined; exports.apply = undefined; function a() { } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js.diff b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js.diff index da8d0fc2d..10fb671f7 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias.js.diff @@ -4,7 +4,6 @@ //// [moduleExportAliasDuplicateAlias.js] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var apply = undefined; exports.apply = undefined; function a() { } @@ -13,7 +12,7 @@ exports.apply = a; exports.apply(); //// [test.js] -@@= skipped -12, +15 lines =@@ +@@= skipped -12, +14 lines =@@ //// [moduleExportAliasDuplicateAlias.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js index 464a44125..fc1e785f8 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js @@ -14,7 +14,6 @@ apply() //// [moduleExportAliasDuplicateAlias.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var apply = undefined; module.exports.apply = undefined; function a() { } diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js.diff b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js.diff index 51dfb3c53..9bc4e9ec7 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias2.js.diff @@ -4,7 +4,6 @@ //// [moduleExportAliasDuplicateAlias.js] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var apply = undefined; module.exports.apply = undefined; function a() { } @@ -14,7 +13,7 @@ module.exports.apply = a; module.exports.apply(); //// [test.js] -@@= skipped -12, +16 lines =@@ +@@= skipped -12, +15 lines =@@ //// [moduleExportAliasDuplicateAlias.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js index 1826f857f..d4b7eaebe 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js @@ -17,7 +17,6 @@ const result = apply.toFixed() //// [moduleExportAliasDuplicateAlias.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var apply = undefined; exports.apply = undefined; export var apply = undefined; diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js.diff b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js.diff index e091ce059..9142a2253 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportDuplicateAlias3.js.diff @@ -4,7 +4,6 @@ //// [moduleExportAliasDuplicateAlias.js] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var apply = undefined; exports.apply = undefined; +export var apply = undefined; @@ -20,7 +19,7 @@ exports.apply = 1; //// [test.js] "use strict"; -@@= skipped -15, +21 lines =@@ +@@= skipped -15, +20 lines =@@ //// [moduleExportAliasDuplicateAlias.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt index b3f788da0..a23b0530f 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt @@ -1,14 +1,10 @@ -mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. -use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? -==== mod.js (1 errors) ==== +==== mod.js (0 errors) ==== module.exports.n = {}; module.exports.n.K = function C() { - ~ -!!! error TS2339: Property 'K' does not exist on type '{}'. this.x = 10; } module.exports.Classic = class { @@ -17,12 +13,10 @@ use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as } } -==== use.js (3 errors) ==== +==== use.js (2 errors) ==== import * as s from './mod' var k = new s.n.K() - ~ -!!! error TS2339: Property 'K' does not exist on type '{}'. k.x var classic = new s.Classic() diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt.diff index de6a3161f..048f3dc44 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportNestedNamespaces.errors.txt.diff @@ -2,17 +2,13 @@ +++ new.moduleExportNestedNamespaces.errors.txt @@= skipped -0, +0 lines =@@ - -+mod.js(2,18): error TS2339: Property 'K' does not exist on type '{}'. -+use.js(3,17): error TS2339: Property 'K' does not exist on type '{}'. +use.js(8,15): error TS2694: Namespace '"mod"' has no exported member 'n'. +use.js(9,13): error TS2749: 's.Classic' refers to a value, but is being used as a type here. Did you mean 'typeof s.Classic'? + + -+==== mod.js (1 errors) ==== ++==== mod.js (0 errors) ==== + module.exports.n = {}; + module.exports.n.K = function C() { -+ ~ -+!!! error TS2339: Property 'K' does not exist on type '{}'. + this.x = 10; + } + module.exports.Classic = class { @@ -21,12 +17,10 @@ + } + } + -+==== use.js (3 errors) ==== ++==== use.js (2 errors) ==== + import * as s from './mod' + + var k = new s.n.K() -+ ~ -+!!! error TS2339: Property 'K' does not exist on type '{}'. + k.x + var classic = new s.Classic() + diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt index 3867a2f25..3281418cb 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt @@ -1,13 +1,10 @@ axios.js(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -axios.js(3,16): error TS2339: Property 'default' does not exist on type '{}'. -==== axios.js (2 errors) ==== +==== axios.js (1 errors) ==== var axios = {} module.exports = axios // both assignments should be ok ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. module.exports.default = axios - ~~~~~~~ -!!! error TS2339: Property 'default' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt.diff index adfb2521e..278fe385e 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportPropertyAssignmentDefault.errors.txt.diff @@ -3,15 +3,12 @@ @@= skipped -0, +0 lines =@@ - +axios.js(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+axios.js(3,16): error TS2339: Property 'default' does not exist on type '{}'. + + -+==== axios.js (2 errors) ==== ++==== axios.js (1 errors) ==== + var axios = {} + module.exports = axios // both assignments should be ok + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + module.exports.default = axios -+ ~~~~~~~ -+!!! error TS2339: Property 'default' does not exist on type '{}'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt index 0048e20c3..ce34bb996 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt @@ -1,24 +1,20 @@ -a.js(6,6): error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. mod1.js(2,1): error TS2322: Type 'string' is not assignable to type 'number'. mod1.js(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. mod1.js(8,1): error TS2322: Type 'string' is not assignable to type 'number'. -mod1.js(9,16): error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. -==== a.js (1 errors) ==== +==== a.js (0 errors) ==== /// var mod1 = require('./mod1') mod1.justExport.toFixed() mod1.bothBefore.toFixed() // error, 'toFixed' not on 'string | number' mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number' mod1.justProperty.length - ~~~~~~~~~~~~ -!!! error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. ==== requires.d.ts (0 errors) ==== declare var module: { exports: any }; declare function require(name: string): any; -==== mod1.js (4 errors) ==== +==== mod1.js (3 errors) ==== /// module.exports.bothBefore = 'string' ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -38,6 +34,4 @@ mod1.js(9,16): error TS2339: Property 'justProperty' does not exist on type '{ j ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'number'. module.exports.justProperty = 'string' - ~~~~~~~~~~~~ -!!! error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt.diff index 6982a01c0..f4da04415 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportWithExportPropertyAssignment3.errors.txt.diff @@ -8,14 +8,12 @@ - - -==== a.js (2 errors) ==== -+a.js(6,6): error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. +mod1.js(2,1): error TS2322: Type 'string' is not assignable to type 'number'. +mod1.js(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +mod1.js(8,1): error TS2322: Type 'string' is not assignable to type 'number'. -+mod1.js(9,16): error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. + + -+==== a.js (1 errors) ==== ++==== a.js (0 errors) ==== /// var mod1 = require('./mod1') mod1.justExport.toFixed() @@ -28,14 +26,12 @@ -!!! error TS2339: Property 'toFixed' does not exist on type 'number | "string"'. -!!! error TS2339: Property 'toFixed' does not exist on type '"string"'. mod1.justProperty.length -+ ~~~~~~~~~~~~ -+!!! error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. ==== requires.d.ts (0 errors) ==== declare var module: { exports: any }; declare function require(name: string): any; -==== mod1.js (0 errors) ==== -+==== mod1.js (4 errors) ==== ++==== mod1.js (3 errors) ==== /// module.exports.bothBefore = 'string' + ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -55,6 +51,4 @@ + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. module.exports.justProperty = 'string' -+ ~~~~~~~~~~~~ -+!!! error TS2339: Property 'justProperty' does not exist on type '{ justExport: number; bothBefore: number; bothAfter: number; }'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js b/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js index ea7a565f3..272a5a007 100644 --- a/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js +++ b/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js @@ -15,8 +15,6 @@ chalk //// [mod1.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); const chalk = { grey: {} }; diff --git a/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js.diff b/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js.diff index 09d98a3c3..fc8696b80 100644 --- a/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js.diff +++ b/testdata/baselines/reference/submodule/conformance/nestedDestructuringOfRequire.js.diff @@ -1,11 +1,6 @@ --- old.nestedDestructuringOfRequire.js +++ new.nestedDestructuringOfRequire.js -@@= skipped -14, +14 lines =@@ - - - //// [mod1.js] -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -17, +17 lines =@@ const chalk = { grey: {} }; @@ -13,7 +8,7 @@ module.exports.chalk = chalk; //// [main.js] const { chalk: { grey } } = require('./mod1'); -@@= skipped -11, +14 lines =@@ +@@= skipped -8, +9 lines =@@ //// [mod1.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js index a88f50540..bf4a19dcb 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js @@ -35,7 +35,6 @@ const a = {}; module.exports = a; //// [file.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // cjs format file const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js.diff index 699333ea8..6faef5e94 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node16).js.diff @@ -1,14 +1,6 @@ --- old.nodeModulesAllowJsExportAssignment(module=node16).js +++ new.nodeModulesAllowJsExportAssignment(module=node16).js -@@= skipped -34, +34 lines =@@ - module.exports = a; - //// [file.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - // cjs format file - const a = {}; - module.exports = a; -@@= skipped -15, +16 lines =@@ +@@= skipped -49, +49 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js index f2ed93381..bf4a19dcb 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js @@ -34,6 +34,7 @@ module.exports = a; const a = {}; module.exports = a; //// [file.js] +"use strict"; // cjs format file const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js.diff index 25030890c..92fd817b3 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node18).js.diff @@ -1,14 +1,6 @@ --- old.nodeModulesAllowJsExportAssignment(module=node18).js +++ new.nodeModulesAllowJsExportAssignment(module=node18).js -@@= skipped -33, +33 lines =@@ - const a = {}; - module.exports = a; - //// [file.js] --"use strict"; - // cjs format file - const a = {}; - module.exports = a; -@@= skipped -16, +15 lines =@@ +@@= skipped -49, +49 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js index a88f50540..bf4a19dcb 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js @@ -35,7 +35,6 @@ const a = {}; module.exports = a; //// [file.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // cjs format file const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js.diff index 14e8fb234..a3aca4c83 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=node20).js.diff @@ -1,14 +1,6 @@ --- old.nodeModulesAllowJsExportAssignment(module=node20).js +++ new.nodeModulesAllowJsExportAssignment(module=node20).js -@@= skipped -34, +34 lines =@@ - module.exports = a; - //// [file.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - // cjs format file - const a = {}; - module.exports = a; -@@= skipped -15, +16 lines =@@ +@@= skipped -49, +49 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js index a88f50540..bf4a19dcb 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js @@ -35,7 +35,6 @@ const a = {}; module.exports = a; //// [file.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); // cjs format file const a = {}; module.exports = a; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js.diff index aaf2b1bd7..d937bfc65 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsExportAssignment(module=nodenext).js.diff @@ -1,14 +1,6 @@ --- old.nodeModulesAllowJsExportAssignment(module=nodenext).js +++ new.nodeModulesAllowJsExportAssignment(module=nodenext).js -@@= skipped -34, +34 lines =@@ - module.exports = a; - //// [file.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - // cjs format file - const a = {}; - module.exports = a; -@@= skipped -15, +16 lines =@@ +@@= skipped -49, +49 lines =@@ //// [index.d.ts] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js index 750a0afa5..f87b35ece 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js @@ -22,11 +22,9 @@ three.foo; //// [1.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); module.exports = {}; //// [2.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js.diff index 6312e19c7..df2d0460b 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node18).js.diff @@ -1,14 +1,9 @@ --- old.nodeModulesCJSEmit1(module=node18).js +++ new.nodeModulesCJSEmit1(module=node18).js -@@= skipped -21, +21 lines =@@ - - //// [1.cjs] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -24, +24 lines =@@ module.exports = {}; //// [2.cjs] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js index 750a0afa5..f87b35ece 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js @@ -22,11 +22,9 @@ three.foo; //// [1.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); module.exports = {}; //// [2.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js.diff index 4986156d8..1d46e5068 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=node20).js.diff @@ -1,14 +1,9 @@ --- old.nodeModulesCJSEmit1(module=node20).js +++ new.nodeModulesCJSEmit1(module=node20).js -@@= skipped -21, +21 lines =@@ - - //// [1.cjs] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -24, +24 lines =@@ module.exports = {}; //// [2.cjs] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js index 750a0afa5..f87b35ece 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js @@ -22,11 +22,9 @@ three.foo; //// [1.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); module.exports = {}; //// [2.cjs] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js.diff index 821b4cd9c..d6396c3e8 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1(module=nodenext).js.diff @@ -1,14 +1,9 @@ --- old.nodeModulesCJSEmit1(module=nodenext).js +++ new.nodeModulesCJSEmit1(module=nodenext).js -@@= skipped -21, +21 lines =@@ - - //// [1.cjs] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -24, +24 lines =@@ module.exports = {}; //// [2.cjs] "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); +export var foo = 0; exports.foo = 0; //// [3.cjs] diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt new file mode 100644 index 000000000..a5d01e6f5 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt @@ -0,0 +1,14 @@ +plainJSGrammarErrors4.js(5,14): error TS1111: Private field '#b' must be declared in an enclosing class. + + +==== plainJSGrammarErrors4.js (1 errors) ==== + class A { + #a; + m() { + this.#a; // ok + this.#b; // error + ~~ +!!! error TS1111: Private field '#b' must be declared in an enclosing class. + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt.diff deleted file mode 100644 index da2dd12cf..000000000 --- a/testdata/baselines/reference/submodule/conformance/plainJSGrammarErrors4.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.plainJSGrammarErrors4.errors.txt -+++ new.plainJSGrammarErrors4.errors.txt -@@= skipped -0, +0 lines =@@ --plainJSGrammarErrors4.js(5,14): error TS1111: Private field '#b' must be declared in an enclosing class. -- -- --==== plainJSGrammarErrors4.js (1 errors) ==== -- class A { -- #a; -- m() { -- this.#a; // ok -- this.#b; // error -- ~~ --!!! error TS1111: Private field '#b' must be declared in an enclosing class. -- } -- } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt b/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt deleted file mode 100644 index 2ed5d876b..000000000 --- a/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -privateIdentifierExpando.js(2,3): error TS2339: Property '#bar' does not exist on type '{}'. - - -==== privateIdentifierExpando.js (1 errors) ==== - const x = {}; - x.#bar.baz = 20; - ~~~~ -!!! error TS2339: Property '#bar' does not exist on type '{}'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt.diff deleted file mode 100644 index 852316f42..000000000 --- a/testdata/baselines/reference/submodule/conformance/privateIdentifierExpando.errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.privateIdentifierExpando.errors.txt -+++ new.privateIdentifierExpando.errors.txt -@@= skipped -0, +0 lines =@@ -- -+privateIdentifierExpando.js(2,3): error TS2339: Property '#bar' does not exist on type '{}'. -+ -+ -+==== privateIdentifierExpando.js (1 errors) ==== -+ const x = {}; -+ x.#bar.baz = 20; -+ ~~~~ -+!!! error TS2339: Property '#bar' does not exist on type '{}'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt b/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt deleted file mode 100644 index bca5be8d9..000000000 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -bug24658.js(2,6): error TS2339: Property 'expando' does not exist on type '{}'. - - -==== mod1.js (0 errors) ==== - export var hurk = {} -==== bug24658.js (1 errors) ==== - import { hurk } from './mod1' - hurk.expando = 4 - ~~~~~~~ -!!! error TS2339: Property 'expando' does not exist on type '{}'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt.diff deleted file mode 100644 index 3d5a8c325..000000000 --- a/testdata/baselines/reference/submodule/conformance/propertyAssignmentOnImportedSymbol.errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.propertyAssignmentOnImportedSymbol.errors.txt -+++ new.propertyAssignmentOnImportedSymbol.errors.txt -@@= skipped -0, +0 lines =@@ -- -+bug24658.js(2,6): error TS2339: Property 'expando' does not exist on type '{}'. -+ -+ -+==== mod1.js (0 errors) ==== -+ export var hurk = {} -+==== bug24658.js (1 errors) ==== -+ import { hurk } from './mod1' -+ hurk.expando = 4 -+ ~~~~~~~ -+!!! error TS2339: Property 'expando' does not exist on type '{}'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js index 9b384afd8..26167e83c 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js @@ -59,7 +59,6 @@ function flatMap(array, iterable = identity) { //// [templateInsideCallback.js] "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); /** * @typedef Oops * @template T @@ -115,9 +114,28 @@ function flatMap(array, iterable = identity) { //// [templateInsideCallback.d.ts] export type Call = () ; -export type Nested = { +/** + * @typedef Oops + * @template T + * @property {T} a + * @property {T} b + */ +/** + * @callback Call + * @template T + * @param {T} x + * @returns {T} + */ +/** + * @template T + * @type {Call} + */ +declare const identity: Call; +type Nested = { oh: { no: number; noooooo: string; }; }; +declare function flatMap(): any; +declare function flatMap(): any; diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff index 6c9be2b1a..17015f261 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff @@ -1,14 +1,6 @@ --- old.templateInsideCallback.js +++ new.templateInsideCallback.js -@@= skipped -58, +58 lines =@@ - - //// [templateInsideCallback.js] - "use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); - /** - * @typedef Oops - * @template T -@@= skipped -47, +48 lines =@@ +@@= skipped -105, +105 lines =@@ /** @type {unknown[]} */ const result = []; for (let i = 0; i < array.length; i += 1) { @@ -36,30 +28,15 @@ - * @returns {T[]} - */ -declare function flatMap(): any; --/** -- * @typedef Oops -- * @template T -- * @property {T} a -- * @property {T} b -- */ --/** -- * @callback Call -- * @template T -- * @param {T} x -- * @returns {T} -- */ --/** -- * @template T -- * @type {Call} -- */ --declare const identity: Call; --type Nested = { +export type Call = () ; -+export type Nested = { - oh: { - no: number; + /** + * @typedef Oops + * @template T +@@= skipped -46, +31 lines =@@ noooooo: string; }; }; -type Oops = any; --type Call = () => any; \ No newline at end of file +-type Call = () => any; ++declare function flatMap(): any; ++declare function flatMap(): any; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt deleted file mode 100644 index 552d29dbc..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -module.js(7,17): error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -module.js(9,17): error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. - - -==== module.js (2 errors) ==== - var Inner = function() {} - Inner.prototype = { - m() { }, - i: 1 - } - // incremental assignments still work - Inner.prototype.j = 2 - ~ -!!! error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. - /** @type {string} */ - Inner.prototype.k; - ~ -!!! error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. - var inner = new Inner() - inner.m() - inner.i - inner.j - inner.k - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt.diff deleted file mode 100644 index 98eab4d8a..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment11.errors.txt.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.typeFromPropertyAssignment11.errors.txt -+++ new.typeFromPropertyAssignment11.errors.txt -@@= skipped -0, +0 lines =@@ -- -+module.js(7,17): error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -+module.js(9,17): error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. -+ -+ -+==== module.js (2 errors) ==== -+ var Inner = function() {} -+ Inner.prototype = { -+ m() { }, -+ i: 1 -+ } -+ // incremental assignments still work -+ Inner.prototype.j = 2 -+ ~ -+!!! error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -+ /** @type {string} */ -+ Inner.prototype.k; -+ ~ -+!!! error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. -+ var inner = new Inner() -+ inner.m() -+ inner.i -+ inner.j -+ inner.k -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt deleted file mode 100644 index 8546f2ec1..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -module.js(8,23): error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -module.js(10,23): error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. - - -==== module.js (2 errors) ==== - var Outer = {} - Outer.Inner = function() {} - Outer.Inner.prototype = { - m() { }, - i: 1 - } - // incremental assignments still work - Outer.Inner.prototype.j = 2 - ~ -!!! error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. - /** @type {string} */ - Outer.Inner.prototype.k; - ~ -!!! error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. - var inner = new Outer.Inner() - inner.m() - inner.i - inner.j - inner.k - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt.diff deleted file mode 100644 index f82063182..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment13.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.typeFromPropertyAssignment13.errors.txt -+++ new.typeFromPropertyAssignment13.errors.txt -@@= skipped -0, +0 lines =@@ -- -+module.js(8,23): error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -+module.js(10,23): error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. -+ -+ -+==== module.js (2 errors) ==== -+ var Outer = {} -+ Outer.Inner = function() {} -+ Outer.Inner.prototype = { -+ m() { }, -+ i: 1 -+ } -+ // incremental assignments still work -+ Outer.Inner.prototype.j = 2 -+ ~ -+!!! error TS2339: Property 'j' does not exist on type '{ m(): void; i: number; }'. -+ /** @type {string} */ -+ Outer.Inner.prototype.k; -+ ~ -+!!! error TS2339: Property 'k' does not exist on type '{ m(): void; i: number; }'. -+ var inner = new Outer.Inner() -+ inner.m() -+ inner.i -+ inner.j -+ inner.k -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt index aa43d4abe..3b3f52bd0 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt @@ -1,24 +1,17 @@ use.js(1,12): error TS2503: Cannot find namespace 'Outer'. -use.js(5,22): error TS2339: Property 'Inner' does not exist on type '{}'. -work.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. -work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. ==== def.js (0 errors) ==== var Outer = {}; -==== work.js (2 errors) ==== +==== work.js (0 errors) ==== Outer.Inner = function () {} - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. Outer.Inner.prototype = { - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. x: 1, m() { } } -==== use.js (2 errors) ==== +==== use.js (1 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. @@ -26,8 +19,6 @@ work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. inner.x inner.m() var inno = new Outer.Inner() - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. inno.x inno.m() diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt.diff index 3cf1ad4cc..639090bbd 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment14.errors.txt.diff @@ -3,26 +3,19 @@ @@= skipped -0, +0 lines =@@ - +use.js(1,12): error TS2503: Cannot find namespace 'Outer'. -+use.js(5,22): error TS2339: Property 'Inner' does not exist on type '{}'. -+work.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. -+work.js(2,7): error TS2339: Property 'Inner' does not exist on type '{}'. + + +==== def.js (0 errors) ==== + var Outer = {}; + -+==== work.js (2 errors) ==== ++==== work.js (0 errors) ==== + Outer.Inner = function () {} -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + Outer.Inner.prototype = { -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + x: 1, + m() { } + } + -+==== use.js (2 errors) ==== ++==== use.js (1 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. @@ -30,8 +23,6 @@ + inner.x + inner.m() + var inno = new Outer.Inner() -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + inno.x + inno.m() + diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt deleted file mode 100644 index 6aa3c8b8c..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -a.js(4,10): error TS2339: Property 'p' does not exist on type '{ q: number; }'. -a.js(7,10): error TS2339: Property 'p' does not exist on type '{ q: number; }'. -a.js(9,12): error TS2339: Property 'p' does not exist on type '{ q: number; }'. - - -==== a.js (3 errors) ==== - var GLOBSTAR = m.GLOBSTAR = {} - function m() { - } - GLOBSTAR.p = 1 - ~ -!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. - m.GLOBSTAR.q = 2 - - GLOBSTAR.p - ~ -!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. - GLOBSTAR.q - m.GLOBSTAR.p - ~ -!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. - m.GLOBSTAR.q - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt.diff deleted file mode 100644 index c31d60447..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment18.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.typeFromPropertyAssignment18.errors.txt -+++ new.typeFromPropertyAssignment18.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(4,10): error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+a.js(7,10): error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+a.js(9,12): error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+ -+ -+==== a.js (3 errors) ==== -+ var GLOBSTAR = m.GLOBSTAR = {} -+ function m() { -+ } -+ GLOBSTAR.p = 1 -+ ~ -+!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+ m.GLOBSTAR.q = 2 -+ -+ GLOBSTAR.p -+ ~ -+!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+ GLOBSTAR.q -+ m.GLOBSTAR.p -+ ~ -+!!! error TS2339: Property 'p' does not exist on type '{ q: number; }'. -+ m.GLOBSTAR.q -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt deleted file mode 100644 index 28af6754c..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -file2.js(1,12): error TS2339: Property 'a' does not exist on type '{}'. -file2.js(2,12): error TS2339: Property 'b' does not exist on type '{}'. - - -==== file1.js (0 errors) ==== - var N = {}; - N.commands = {}; - -==== file2.js (2 errors) ==== - N.commands.a = 111; - ~ -!!! error TS2339: Property 'a' does not exist on type '{}'. - N.commands.b = function () { }; - ~ -!!! error TS2339: Property 'b' does not exist on type '{}'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt.diff deleted file mode 100644 index f488e3750..000000000 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment34.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.typeFromPropertyAssignment34.errors.txt -+++ new.typeFromPropertyAssignment34.errors.txt -@@= skipped -0, +0 lines =@@ -- -+file2.js(1,12): error TS2339: Property 'a' does not exist on type '{}'. -+file2.js(2,12): error TS2339: Property 'b' does not exist on type '{}'. -+ -+ -+==== file1.js (0 errors) ==== -+ var N = {}; -+ N.commands = {}; -+ -+==== file2.js (2 errors) ==== -+ N.commands.a = 111; -+ ~ -+!!! error TS2339: Property 'a' does not exist on type '{}'. -+ N.commands.b = function () { }; -+ ~ -+!!! error TS2339: Property 'b' does not exist on type '{}'. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt index 5b0afce0f..54dae7d83 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt @@ -1,36 +1,24 @@ bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. -bug26877.js(4,23): error TS2339: Property 'D' does not exist on type '{}'. -bug26877.js(5,19): error TS2339: Property 'D' does not exist on type '{}'. -bug26877.js(7,5): error TS2339: Property 'D' does not exist on type '{}'. -second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. -==== bug26877.js (4 errors) ==== +==== bug26877.js (1 errors) ==== /** @param {Emu.D} x */ ~~~ !!! error TS2503: Cannot find namespace 'Emu'. function ollKorrect(x) { x._model const y = new Emu.D() - ~ -!!! error TS2339: Property 'D' does not exist on type '{}'. const z = Emu.D._wrapperInstance; - ~ -!!! error TS2339: Property 'D' does not exist on type '{}'. } Emu.D = class { - ~ -!!! error TS2339: Property 'D' does not exist on type '{}'. constructor() { this._model = 1 } } -==== second.js (1 errors) ==== +==== second.js (0 errors) ==== var Emu = {} /** @type {string} */ Emu.D._wrapperInstance; - ~ -!!! error TS2339: Property 'D' does not exist on type '{}'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt.diff index 1f444bc55..4ced6a0b3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment35.errors.txt.diff @@ -3,38 +3,26 @@ @@= skipped -0, +0 lines =@@ - +bug26877.js(1,13): error TS2503: Cannot find namespace 'Emu'. -+bug26877.js(4,23): error TS2339: Property 'D' does not exist on type '{}'. -+bug26877.js(5,19): error TS2339: Property 'D' does not exist on type '{}'. -+bug26877.js(7,5): error TS2339: Property 'D' does not exist on type '{}'. -+second.js(3,5): error TS2339: Property 'D' does not exist on type '{}'. + + -+==== bug26877.js (4 errors) ==== ++==== bug26877.js (1 errors) ==== + /** @param {Emu.D} x */ + ~~~ +!!! error TS2503: Cannot find namespace 'Emu'. + function ollKorrect(x) { + x._model + const y = new Emu.D() -+ ~ -+!!! error TS2339: Property 'D' does not exist on type '{}'. + const z = Emu.D._wrapperInstance; -+ ~ -+!!! error TS2339: Property 'D' does not exist on type '{}'. + } + Emu.D = class { -+ ~ -+!!! error TS2339: Property 'D' does not exist on type '{}'. + constructor() { + this._model = 1 + } + } + -+==== second.js (1 errors) ==== ++==== second.js (0 errors) ==== + var Emu = {} + /** @type {string} */ + Emu.D._wrapperInstance; -+ ~ -+!!! error TS2339: Property 'D' does not exist on type '{}'. + + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt index a8a549a4f..db8ede3fe 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt @@ -1,6 +1,5 @@ mod.js(1,14): error TS2304: Cannot find name 'exports'. mod.js(1,24): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -mod.js(3,10): error TS2339: Property 'existy' does not exist on type '{}'. use.js(1,22): error TS2306: File 'mod.js' is not a module. @@ -13,7 +12,7 @@ use.js(1,22): error TS2306: File 'mod.js' is not a module. } util.existy // no error -==== mod.js (3 errors) ==== +==== mod.js (2 errors) ==== const util = exports = module.exports = {} ~~~~~~~ !!! error TS2304: Cannot find name 'exports'. @@ -21,7 +20,5 @@ use.js(1,22): error TS2306: File 'mod.js' is not a module. !!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. if (!!false) { util.existy = function () { } - ~~~~~~ -!!! error TS2339: Property 'existy' does not exist on type '{}'. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt.diff index 500a5ce5d..4c08740d6 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment37.errors.txt.diff @@ -4,7 +4,6 @@ - +mod.js(1,14): error TS2304: Cannot find name 'exports'. +mod.js(1,24): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -+mod.js(3,10): error TS2339: Property 'existy' does not exist on type '{}'. +use.js(1,22): error TS2306: File 'mod.js' is not a module. + + @@ -17,7 +16,7 @@ + } + util.existy // no error + -+==== mod.js (3 errors) ==== ++==== mod.js (2 errors) ==== + const util = exports = module.exports = {} + ~~~~~~~ +!!! error TS2304: Cannot find name 'exports'. @@ -25,7 +24,5 @@ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + if (!!false) { + util.existy = function () { } -+ ~~~~~~ -+!!! error TS2339: Property 'existy' does not exist on type '{}'. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt index 1b87c0694..7e5959acc 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt @@ -1,17 +1,12 @@ -a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. a.js(8,12): error TS2503: Cannot find namespace 'Outer'. -a.js(11,23): error TS2339: Property 'Inner' does not exist on type '{}'. b.js(1,12): error TS2503: Cannot find namespace 'Outer'. -b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. ==== def.js (0 errors) ==== var Outer = {}; -==== a.js (3 errors) ==== +==== a.js (1 errors) ==== Outer.Inner = class { - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. constructor() { /** @type {number} */ this.y = 12 @@ -24,18 +19,14 @@ b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. var local local.y var inner = new Outer.Inner() - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. inner.y -==== b.js (2 errors) ==== +==== b.js (1 errors) ==== /** @type {Outer.Inner} */ ~~~~~ !!! error TS2503: Cannot find namespace 'Outer'. var x x.y var z = new Outer.Inner() - ~~~~~ -!!! error TS2339: Property 'Inner' does not exist on type '{}'. z.y \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt.diff index f71a2bea6..48e21edf3 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignment4.errors.txt.diff @@ -2,20 +2,15 @@ +++ new.typeFromPropertyAssignment4.errors.txt @@= skipped -0, +0 lines =@@ - -+a.js(1,7): error TS2339: Property 'Inner' does not exist on type '{}'. +a.js(8,12): error TS2503: Cannot find namespace 'Outer'. -+a.js(11,23): error TS2339: Property 'Inner' does not exist on type '{}'. +b.js(1,12): error TS2503: Cannot find namespace 'Outer'. -+b.js(4,19): error TS2339: Property 'Inner' does not exist on type '{}'. + + +==== def.js (0 errors) ==== + var Outer = {}; + -+==== a.js (3 errors) ==== ++==== a.js (1 errors) ==== + Outer.Inner = class { -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + constructor() { + /** @type {number} */ + this.y = 12 @@ -28,18 +23,14 @@ + var local + local.y + var inner = new Outer.Inner() -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + inner.y + -+==== b.js (2 errors) ==== ++==== b.js (1 errors) ==== + /** @type {Outer.Inner} */ + ~~~~~ +!!! error TS2503: Cannot find namespace 'Outer'. + var x + x.y + var z = new Outer.Inner() -+ ~~~~~ -+!!! error TS2339: Property 'Inner' does not exist on type '{}'. + z.y + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt index c10ea07ed..38675aa91 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt @@ -1,26 +1,11 @@ -index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. -index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. -index.js(2,37): error TS2339: Property 'Item' does not exist on type '{}'. -index.js(4,11): error TS2339: Property 'Object' does not exist on type '{}'. -index.js(4,41): error TS2339: Property 'Object' does not exist on type '{}'. index.js(6,12): error TS2503: Cannot find namespace 'Workspace'. -==== index.js (6 errors) ==== +==== index.js (1 errors) ==== First.Item = class I {} - ~~~~ -!!! error TS2339: Property 'Item' does not exist on type '{}'. Common.Object = class extends First.Item {} - ~~~~~~ -!!! error TS2339: Property 'Object' does not exist on type '{}'. - ~~~~ -!!! error TS2339: Property 'Item' does not exist on type '{}'. Workspace.Object = class extends Common.Object {} - ~~~~~~ -!!! error TS2339: Property 'Object' does not exist on type '{}'. - ~~~~~~ -!!! error TS2339: Property 'Object' does not exist on type '{}'. /** @type {Workspace.Object} */ ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff index 5dfed1d5a..0f10dc838 100644 --- a/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typeFromPropertyAssignmentOutOfOrder.errors.txt.diff @@ -2,29 +2,14 @@ +++ new.typeFromPropertyAssignmentOutOfOrder.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(1,7): error TS2339: Property 'Item' does not exist on type '{}'. -+index.js(2,8): error TS2339: Property 'Object' does not exist on type '{}'. -+index.js(2,37): error TS2339: Property 'Item' does not exist on type '{}'. -+index.js(4,11): error TS2339: Property 'Object' does not exist on type '{}'. -+index.js(4,41): error TS2339: Property 'Object' does not exist on type '{}'. +index.js(6,12): error TS2503: Cannot find namespace 'Workspace'. + + -+==== index.js (6 errors) ==== ++==== index.js (1 errors) ==== + First.Item = class I {} -+ ~~~~ -+!!! error TS2339: Property 'Item' does not exist on type '{}'. + Common.Object = class extends First.Item {} -+ ~~~~~~ -+!!! error TS2339: Property 'Object' does not exist on type '{}'. -+ ~~~~ -+!!! error TS2339: Property 'Item' does not exist on type '{}'. + + Workspace.Object = class extends Common.Object {} -+ ~~~~~~ -+!!! error TS2339: Property 'Object' does not exist on type '{}'. -+ ~~~~~~ -+!!! error TS2339: Property 'Object' does not exist on type '{}'. + + /** @type {Workspace.Object} */ + ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index ba8528abb..88c64603d 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -2,8 +2,8 @@ mod1.js(7,9): error TS2339: Property 'Bar' does not exist on type 'typeof import mod1.js(10,1): error TS2300: Duplicate identifier 'export='. mod1.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. +mod1.js(23,1): error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. mod1.js(23,1): error TS2300: Duplicate identifier 'export='. -mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. use.js(4,12): error TS2503: Cannot find namespace 'mod'. @@ -56,11 +56,12 @@ use.js(4,12): error TS2503: Cannot find namespace 'mod'. /** @typedef {number} Quack */ module.exports = { + ~~~~~~~~~~~~~~ +!!! error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. +!!! related TS2728 mod1.js:11:5: 'Baz' is declared here. ~~~~~~~~~~~~~~~~~~ Quack: 2 ~~~~~~~~~~~~ - ~~~~~ -!!! error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. } ~ !!! error TS2300: Duplicate identifier 'export='. diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff index 1fca153ea..42d0aaf0b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff @@ -12,8 +12,8 @@ +mod1.js(10,1): error TS2300: Duplicate identifier 'export='. +mod1.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. ++mod1.js(23,1): error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. +mod1.js(23,1): error TS2300: Duplicate identifier 'export='. -+mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. +use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. +use.js(4,12): error TS2503: Cannot find namespace 'mod'. + @@ -76,11 +76,12 @@ /** @typedef {number} Quack */ module.exports = { ++ ~~~~~~~~~~~~~~ ++!!! error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. ++!!! related TS2728 mod1.js:11:5: 'Baz' is declared here. + ~~~~~~~~~~~~~~~~~~ Quack: 2 + ~~~~~~~~~~~~ -+ ~~~~~ -+!!! error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. } + ~ +!!! error TS2300: Duplicate identifier 'export='. diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt new file mode 100644 index 000000000..09f1fbd26 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt @@ -0,0 +1,12 @@ +/a.ts(2,5): error TS2339: Property 'bar' does not exist on type 'typeof import("/node_modules/foo/index")'. + + +==== /a.ts (1 errors) ==== + import foo from "foo"; + foo.bar(); + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'typeof import("/node_modules/foo/index")'. + +==== /node_modules/foo/index.js (0 errors) ==== + exports.default = { bar() { return 0; } } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt.diff deleted file mode 100644 index 1d8aabb7f..000000000 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.untypedModuleImport_allowJs.errors.txt -+++ new.untypedModuleImport_allowJs.errors.txt -@@= skipped -0, +0 lines =@@ --/a.ts(2,5): error TS2339: Property 'bar' does not exist on type 'typeof import("/node_modules/foo/index")'. -- -- --==== /a.ts (1 errors) ==== -- import foo from "foo"; -- foo.bar(); -- ~~~ --!!! error TS2339: Property 'bar' does not exist on type 'typeof import("/node_modules/foo/index")'. -- --==== /node_modules/foo/index.js (0 errors) ==== -- exports.default = { bar() { return 0; } } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols index 6493017cb..99801b5b7 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols @@ -5,9 +5,7 @@ import foo from "foo"; >foo : Symbol(foo, Decl(a.ts, 0, 6)) foo.bar(); ->foo.bar : Symbol(bar, Decl(index.js, 0, 19)) >foo : Symbol(foo, Decl(a.ts, 0, 6)) ->bar : Symbol(bar, Decl(index.js, 0, 19)) === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff index 09efca276..3fa69a4d3 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.symbols.diff @@ -1,13 +1,6 @@ --- old.untypedModuleImport_allowJs.symbols +++ new.untypedModuleImport_allowJs.symbols -@@= skipped -4, +4 lines =@@ - >foo : Symbol(foo, Decl(a.ts, 0, 6)) - - foo.bar(); -+>foo.bar : Symbol(bar, Decl(index.js, 0, 19)) - >foo : Symbol(foo, Decl(a.ts, 0, 6)) -+>bar : Symbol(bar, Decl(index.js, 0, 19)) - +@@= skipped -9, +9 lines =@@ === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } >exports.default : Symbol(default, Decl(index.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types index 114f087c6..8965344e1 100644 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types +++ b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types @@ -2,13 +2,13 @@ === /a.ts === import foo from "foo"; ->foo : { bar(): number; } +>foo : typeof foo foo.bar(); ->foo.bar() : number ->foo.bar : () => number ->foo : { bar(): number; } ->bar : () => number +>foo.bar() : any +>foo.bar : any +>foo : typeof foo +>bar : any === /node_modules/foo/index.js === exports.default = { bar() { return 0; } } diff --git a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types.diff b/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types.diff deleted file mode 100644 index ede066d4f..000000000 --- a/testdata/baselines/reference/submodule/conformance/untypedModuleImport_allowJs.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.untypedModuleImport_allowJs.types -+++ new.untypedModuleImport_allowJs.types -@@= skipped -1, +1 lines =@@ - - === /a.ts === - import foo from "foo"; -->foo : typeof foo -+>foo : { bar(): number; } - - foo.bar(); -->foo.bar() : any -->foo.bar : any -->foo : typeof foo -->bar : any -+>foo.bar() : number -+>foo.bar : () => number -+>foo : { bar(): number; } -+>bar : () => number - - === /node_modules/foo/index.js === - exports.default = { bar() { return 0; } } \ No newline at end of file