Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
66f4788
Set implied node format during source file creation
frodi-karlsson Mar 16, 2025
48873eb
Merge branch 'main' into implied-node-format-setting
frodi-karlsson Mar 16, 2025
fb0f304
Move into file loader
frodi-karlsson Mar 16, 2025
3e7b92c
Merge branch 'implied-node-format-setting' of github.com:frodi-karlss…
frodi-karlsson Mar 16, 2025
8bba782
Revert back to main to start from scratch with storing on Program per…
frodi-karlsson Mar 16, 2025
d1f5959
Try a v3 with parser-set fields, keep hacking at it
frodi-karlsson Mar 17, 2025
e5645d2
Merge branch 'main' into implied-node-format-setting
frodi-karlsson Mar 17, 2025
e825898
Resolve bad history linearly
frodi-karlsson Mar 17, 2025
1f3b470
Fix languageservice <-> project dependency muck up
frodi-karlsson Mar 17, 2025
1a66c19
Pass around package json type instead of cache entry
frodi-karlsson Mar 17, 2025
0112b00
Remove left-over !!!
frodi-karlsson Mar 17, 2025
8366e88
Remove GetImpliedNodeFormat
frodi-karlsson Mar 17, 2025
d33133b
Remove harnessUtil package json garbage
frodi-karlsson Mar 17, 2025
b81a9d1
Remove unnecessary newline
frodi-karlsson Mar 17, 2025
406918a
Move off of AST into a map in program
frodi-karlsson Mar 17, 2025
44d6aff
Move creation of metadata into fileloader
frodi-karlsson Mar 17, 2025
54fc786
Change arg to fileName and remove packageType argument in caching method
frodi-karlsson Mar 17, 2025
0644fd3
Appease linter and remove unnecessary convert
frodi-karlsson Mar 17, 2025
8d1f096
Use extension constants
frodi-karlsson Mar 18, 2025
344710a
Merge branch 'main' into implied-node-format-setting (-X theirs for
frodi-karlsson Mar 18, 2025
f6fcb49
Pass single sourceFileMetaData from program into emitContext
frodi-karlsson Mar 18, 2025
a1d63f5
Merge branch 'main' into implied-node-format-setting
frodi-karlsson Mar 18, 2025
3c902b8
Accept insane new diff wins
frodi-karlsson Mar 18, 2025
08333cf
Switch back to map
frodi-karlsson Mar 18, 2025
ba527ba
Use path as map key
frodi-karlsson Mar 18, 2025
4f740f1
Revert walking originals
frodi-karlsson Mar 18, 2025
d1e2b2e
Create MetaDataProvider
frodi-karlsson Mar 18, 2025
7da5ddc
Move commonjs metadata provider adding to struct declaration
frodi-karlsson Mar 18, 2025
e2c7a77
Use program as SourceFileMetaDataProvider and share fakeProgram in te…
frodi-karlsson Mar 18, 2025
3099425
Revert moving to util and create smaller fakeSourceFileMetaDataProvider
frodi-karlsson Mar 18, 2025
1697b75
Realign naming to provider
frodi-karlsson Mar 18, 2025
d86780d
Remove unnecessary struct
frodi-karlsson Mar 18, 2025
ac71490
Fix henceforth "load"SourceFileMetaData, spacings and leftover
frodi-karlsson Mar 18, 2025
286beed
Switch to RWMutex and include map creation in w lock
frodi-karlsson Mar 19, 2025
ed015b3
Fix deadlock
frodi-karlsson Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -8695,6 +8695,8 @@ type SourceFile struct {
ReferencedFiles []*FileReference
TypeReferenceDirectives []*FileReference
LibReferenceDirectives []*FileReference
PackageJsonType string
ImpliedNodeFormat core.ModuleKind

// Fields set by binder

Expand Down Expand Up @@ -8723,7 +8725,6 @@ type SourceFile struct {

// !!!

ImpliedNodeFormat core.ModuleKind
CommonJsModuleIndicator *Node
ExternalModuleIndicator *Node
JsGlobalAugmentations SymbolTable
Expand Down
8 changes: 4 additions & 4 deletions internal/ast/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -2368,13 +2368,13 @@ func GetImpliedNodeFormatForEmitWorker(sourceFile *SourceFile, options *core.Com
return sourceFile.ImpliedNodeFormat
}
if sourceFile.ImpliedNodeFormat == core.ModuleKindCommonJS &&
( /*sourceFile.packageJsonScope.contents.packageJsonContent.type == "commonjs" ||*/ // !!!
tspath.FileExtensionIsOneOf(sourceFile.FileName(), []string{tspath.ExtensionCjs, tspath.ExtensionCts})) {
(sourceFile.PackageJsonType != "module" ||
tspath.FileExtensionIsOneOf(sourceFile.FileName(), []string{tspath.ExtensionCjs, tspath.ExtensionCts})) {
return core.ModuleKindCommonJS
}
if sourceFile.ImpliedNodeFormat == core.ModuleKindESNext &&
( /*sourceFile.packageJsonScope?.contents.packageJsonContent.type === "module" ||*/ // !!!
tspath.FileExtensionIsOneOf(sourceFile.fileName, []string{tspath.ExtensionMjs, tspath.ExtensionMts})) {
(sourceFile.PackageJsonType == "module" ||
tspath.FileExtensionIsOneOf(sourceFile.fileName, []string{tspath.ExtensionMjs, tspath.ExtensionMts})) {
return core.ModuleKindESNext
}
return core.ModuleKindNone
Expand Down
4 changes: 2 additions & 2 deletions internal/astnav/tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestGetTokenAtPosition(t *testing.T) {
return 0;
}
`
file := parser.ParseSourceFile("/file.ts", "/file.ts", fileText, core.ScriptTargetLatest, scanner.JSDocParsingModeParseAll)
file := parser.ParseSourceFile("/file.ts", "/file.ts", fileText, core.ScriptTargetLatest, scanner.JSDocParsingModeParseAll, core.ModuleResolutionKindNodeNext, "")
assert.Equal(t, astnav.GetTokenAtPosition(file, 0), astnav.GetTokenAtPosition(file, 0))
})
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func baselineTokens(t *testing.T, testName string, getTSTokens func(fileText str
positions[i] = i
}
tsTokens := getTSTokens(string(fileText), positions)
file := parser.ParseSourceFile("/file.ts", "/file.ts", string(fileText), core.ScriptTargetLatest, scanner.JSDocParsingModeParseAll)
file := parser.ParseSourceFile("/file.ts", "/file.ts", string(fileText), core.ScriptTargetLatest, scanner.JSDocParsingModeParseAll, core.ModuleResolutionKindNodeNext, "")

var output strings.Builder
currentRange := core.NewTextRange(0, 0)
Expand Down
2 changes: 1 addition & 1 deletion internal/binder/binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func BenchmarkBind(b *testing.B) {

sourceFiles := make([]*ast.SourceFile, b.N)
for i := range b.N {
sourceFiles[i] = parser.ParseSourceFile(fileName, path, sourceText, core.ScriptTargetESNext, scanner.JSDocParsingModeParseAll)
sourceFiles[i] = parser.ParseSourceFile(fileName, path, sourceText, core.ScriptTargetESNext, scanner.JSDocParsingModeParseAll, core.ModuleResolutionKindNodeNext, "")
}

compilerOptions := &core.CompilerOptions{Target: core.ScriptTargetESNext, ModuleKind: core.ModuleKindNodeNext}
Expand Down
7 changes: 6 additions & 1 deletion internal/compiler/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ func (t *parseTask) start(loader *fileLoader) {

func (p *fileLoader) parseSourceFile(fileName string) *ast.SourceFile {
path := tspath.ToPath(fileName, p.host.GetCurrentDirectory(), p.host.FS().UseCaseSensitiveFileNames())
sourceFile := p.host.GetSourceFile(fileName, path, p.compilerOptions.GetEmitScriptTarget())
packageType := ""
packageScope := p.resolver.GetPackageScopeForPath(fileName)
if packageScope != nil {
packageType = packageScope.Contents.Type.Value
}
sourceFile := p.host.GetSourceFile(fileName, path, p.compilerOptions.GetEmitScriptTarget(), packageType)
return sourceFile
}

Expand Down
12 changes: 9 additions & 3 deletions internal/compiler/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type CompilerHost interface {
GetCurrentDirectory() string
NewLine() string
Trace(msg string)
GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile
GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile
}

type FileInfo struct {
Expand Down Expand Up @@ -68,10 +68,16 @@ func (h *compilerHost) Trace(msg string) {
//!!! TODO: implement
}

func (h *compilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile {
func (h *compilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile {
text, _ := h.FS().ReadFile(fileName)
if tspath.FileExtensionIs(fileName, tspath.ExtensionJson) {
return parser.ParseJSONText(fileName, path, text)
}
return parser.ParseSourceFile(fileName, path, text, languageVersion, scanner.JSDocParsingModeParseForTypeErrors)

var moduleResolutionKind core.ModuleResolutionKind
if h.options != nil {
moduleResolutionKind = h.options.GetModuleResolutionKind()
}

return parser.ParseSourceFile(fileName, path, text, languageVersion, scanner.JSDocParsingModeParseForTypeErrors, moduleResolutionKind, packageJsonType)
}
2 changes: 1 addition & 1 deletion internal/ls/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Host interface {
GetRootFileNames() []string
// GetCompilerOptions was called GetCompilationSettings in the original code.
GetCompilerOptions() *core.CompilerOptions
GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile
GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile
// This responsibility was moved from the language service to the project,
// because they were bidirectionally interdependent.
GetProgram() *compiler.Program
Expand Down
4 changes: 2 additions & 2 deletions internal/ls/languageservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func (l *LanguageService) Trace(msg string) {
}

// GetSourceFile implements compiler.CompilerHost.
func (l *LanguageService) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile {
return l.host.GetSourceFile(fileName, path, languageVersion)
func (l *LanguageService) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile {
return l.host.GetSourceFile(fileName, path, languageVersion, packageJsonType)
}

// GetProgram updates the program if the project version has changed.
Expand Down
44 changes: 32 additions & 12 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ type Parser struct {
scanner *scanner.Scanner
factory ast.NodeFactory

fileName string
path tspath.Path
sourceText string
languageVersion core.ScriptTarget
scriptKind core.ScriptKind
languageVariant core.LanguageVariant
diagnostics []*ast.Diagnostic
jsdocDiagnostics []*ast.Diagnostic
fileName string
path tspath.Path
sourceText string
languageVersion core.ScriptTarget
scriptKind core.ScriptKind
languageVariant core.LanguageVariant
diagnostics []*ast.Diagnostic
jsdocDiagnostics []*ast.Diagnostic
impliedNodeFormat core.ResolutionMode
packageJsonType string

token ast.Kind
sourceFlags ast.NodeFlags
Expand Down Expand Up @@ -92,18 +94,18 @@ func putParser(p *Parser) {
parserPool.Put(p)
}

func ParseSourceFile(fileName string, path tspath.Path, sourceText string, languageVersion core.ScriptTarget, jsdocParsingMode scanner.JSDocParsingMode) *ast.SourceFile {
func ParseSourceFile(fileName string, path tspath.Path, sourceText string, languageVersion core.ScriptTarget, jsdocParsingMode scanner.JSDocParsingMode, moduleResolutionKind core.ModuleResolutionKind, packageJsonType string) *ast.SourceFile {
p := getParser()
defer putParser(p)
p.initializeState(fileName, path, sourceText, languageVersion, core.ScriptKindUnknown, jsdocParsingMode)
p.initializeState(fileName, path, sourceText, languageVersion, core.ScriptKindUnknown, jsdocParsingMode, moduleResolutionKind, packageJsonType)
p.nextToken()
return p.parseSourceFileWorker()
}

func ParseJSONText(fileName string, path tspath.Path, sourceText string) *ast.SourceFile {
p := getParser()
defer putParser(p)
p.initializeState(fileName, path, sourceText, core.ScriptTargetES2015, core.ScriptKindJSON, scanner.JSDocParsingModeParseAll)
p.initializeState(fileName, path, sourceText, core.ScriptTargetES2015, core.ScriptKindJSON, scanner.JSDocParsingModeParseAll, core.ModuleResolutionKindUnknown, "")
p.nextToken()
pos := p.nodePos()
var statements *ast.NodeList
Expand Down Expand Up @@ -176,7 +178,7 @@ func ParseJSONText(fileName string, path tspath.Path, sourceText string) *ast.So
return result
}

func (p *Parser) initializeState(fileName string, path tspath.Path, sourceText string, languageVersion core.ScriptTarget, scriptKind core.ScriptKind, jsdocParsingMode scanner.JSDocParsingMode) {
func (p *Parser) initializeState(fileName string, path tspath.Path, sourceText string, languageVersion core.ScriptTarget, scriptKind core.ScriptKind, jsdocParsingMode scanner.JSDocParsingMode, moduleResolutionKind core.ModuleResolutionKind, packageJsonType string) {
if p.scanner == nil {
p.scanner = scanner.NewScanner()
} else {
Expand All @@ -196,6 +198,20 @@ func (p *Parser) initializeState(fileName string, path tspath.Path, sourceText s
default:
p.contextFlags = ast.NodeFlagsNone
}

shouldLookupFromPackageJson := core.ModuleResolutionKindNode16 <= moduleResolutionKind && moduleResolutionKind <= core.ModuleResolutionKindNodeNext || strings.Contains(string(path), "/node_modules/")

impliedNodeFormat := core.ResolutionModeNone
if tspath.FileExtensionIsOneOf(string(path), []string{tspath.ExtensionDmts, tspath.ExtensionMts, tspath.ExtensionMjs}) {
impliedNodeFormat = core.ResolutionModeESM
} else if tspath.FileExtensionIsOneOf(string(path), []string{tspath.ExtensionDcts, tspath.ExtensionCts, tspath.ExtensionCjs}) {
impliedNodeFormat = core.ResolutionModeCommonJS
} else if shouldLookupFromPackageJson && tspath.FileExtensionIsOneOf(string(path), []string{tspath.ExtensionDts, tspath.ExtensionTs, tspath.ExtensionTsx, tspath.ExtensionJs, tspath.ExtensionJsx}) {
impliedNodeFormat = core.IfElse(packageJsonType == "module", core.ResolutionModeESM, core.ResolutionModeCommonJS)
}

p.impliedNodeFormat = impliedNodeFormat
p.packageJsonType = packageJsonType
p.scanner.SetText(p.sourceText)
p.scanner.SetOnError(p.scanError)
p.scanner.SetScriptTarget(p.languageVersion)
Expand Down Expand Up @@ -325,8 +341,12 @@ func (p *Parser) finishSourceFile(result *ast.SourceFile, isDeclarationFile bool
result.Flags |= p.sourceFlags
result.Identifiers = p.identifiers
result.SetJSDocCache(p.jsdocCache)
result.ImpliedNodeFormat = p.impliedNodeFormat
result.PackageJsonType = p.packageJsonType
p.jsdocCache = nil
p.identifiers = nil
p.impliedNodeFormat = core.ResolutionModeNone
p.packageJsonType = ""
}

func (p *Parser) parseToplevelStatement(i int) *ast.Node {
Expand Down
6 changes: 3 additions & 3 deletions internal/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func BenchmarkParse(b *testing.B) {
b.Run(jsdoc.name, func(b *testing.B) {
jsdocMode := jsdoc.mode
for b.Loop() {
ParseSourceFile(fileName, path, sourceText, core.ScriptTargetESNext, jsdocMode)
ParseSourceFile(fileName, path, sourceText, core.ScriptTargetESNext, jsdocMode, core.ModuleResolutionKindNodeNext, "")
}
})
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestParseTypeScriptRepo(t *testing.T) {
if strings.HasSuffix(f.name, ".json") {
sourceFile = ParseJSONText(fileName, path, string(sourceText))
} else {
sourceFile = ParseSourceFile(fileName, path, string(sourceText), core.ScriptTargetESNext, scanner.JSDocParsingModeParseAll)
sourceFile = ParseSourceFile(fileName, path, string(sourceText), core.ScriptTargetESNext, scanner.JSDocParsingModeParseAll, core.ModuleResolutionKindNodeNext, "")
}

if !test.ignoreErrors {
Expand Down Expand Up @@ -179,6 +179,6 @@ func FuzzParser(f *testing.F) {
return
}

ParseSourceFile(fileName, path, sourceText, scriptTarget, jsdocParsingMode)
ParseSourceFile(fileName, path, sourceText, scriptTarget, jsdocParsingMode, core.ModuleResolutionKindUnknown, "")
})
}
8 changes: 6 additions & 2 deletions internal/project/documentregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@ func (r *documentRegistry) getDocumentWorker(
key registryKey,
) *ast.SourceFile {
scriptTarget := core.IfElse(scriptInfo.scriptKind == core.ScriptKindJSON, core.ScriptTargetJSON, compilerOptions.GetEmitScriptTarget())
var moduleResolutionKind core.ModuleResolutionKind
if compilerOptions != nil {
moduleResolutionKind = compilerOptions.GetModuleResolutionKind()
}
if entryAny, ok := r.documents.Load(key); ok {
// We have an entry for this file. However, it may be for a different version of
// the script snapshot. If so, update it appropriately.
entry := entryAny.(*registryEntry)
if entry.sourceFile.Version != scriptInfo.version {
sourceFile := parser.ParseSourceFile(scriptInfo.fileName, scriptInfo.path, scriptInfo.text, scriptTarget, scanner.JSDocParsingModeParseAll)
sourceFile := parser.ParseSourceFile(scriptInfo.fileName, scriptInfo.path, scriptInfo.text, scriptTarget, scanner.JSDocParsingModeParseAll, moduleResolutionKind, "")
sourceFile.Version = scriptInfo.version
entry.mu.Lock()
defer entry.mu.Unlock()
Expand All @@ -102,7 +106,7 @@ func (r *documentRegistry) getDocumentWorker(
return entry.sourceFile
} else {
// Have never seen this file with these settings. Create a new source file for it.
sourceFile := parser.ParseSourceFile(scriptInfo.fileName, scriptInfo.path, scriptInfo.text, scriptTarget, scanner.JSDocParsingModeParseAll)
sourceFile := parser.ParseSourceFile(scriptInfo.fileName, scriptInfo.path, scriptInfo.text, scriptTarget, scanner.JSDocParsingModeParseAll, moduleResolutionKind, "")
sourceFile.Version = scriptInfo.version
entryAny, _ := r.documents.LoadOrStore(key, &registryEntry{
sourceFile: sourceFile,
Expand Down
2 changes: 1 addition & 1 deletion internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (p *Project) GetRootFileNames() []string {
}

// GetSourceFile implements LanguageServiceHost.
func (p *Project) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile {
func (p *Project) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile {
scriptKind := p.getScriptKind(fileName)
if scriptInfo := p.getOrCreateScriptInfoAndAttachToProject(fileName, scriptKind); scriptInfo != nil {
var (
Expand Down
11 changes: 9 additions & 2 deletions internal/testutil/harnessutil/harnessutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,15 @@ type cachedCompilerHost struct {

var sourceFileCache sync.Map

func (h *cachedCompilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget) *ast.SourceFile {
func (h *cachedCompilerHost) GetSourceFile(fileName string, path tspath.Path, languageVersion core.ScriptTarget, packageJsonType string) *ast.SourceFile {
text, _ := h.FS().ReadFile(fileName)

type sourceFileCacheKey struct {
core.SourceFileAffectingCompilerOptions
fileName string
path tspath.Path
languageVersion core.ScriptTarget
packageJsonType string
text string
}

Expand All @@ -371,6 +372,7 @@ func (h *cachedCompilerHost) GetSourceFile(fileName string, path tspath.Path, la
fileName: fileName,
path: path,
languageVersion: languageVersion,
packageJsonType: packageJsonType,
text: text,
}

Expand All @@ -384,7 +386,12 @@ func (h *cachedCompilerHost) GetSourceFile(fileName string, path tspath.Path, la
sourceFile = parser.ParseJSONText(fileName, path, text)
} else {
// !!! JSDocParsingMode
sourceFile = parser.ParseSourceFile(fileName, path, text, languageVersion, scanner.JSDocParsingModeParseAll)
var moduleResolutionKind core.ModuleResolutionKind
if h.options != nil {
moduleResolutionKind = h.options.GetModuleResolutionKind()
}

sourceFile = parser.ParseSourceFile(fileName, path, text, languageVersion, scanner.JSDocParsingModeParseAll, moduleResolutionKind, packageJsonType)
}

result, _ := sourceFileCache.LoadOrStore(key, sourceFile)
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/parsetestutil/parsetestutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// Simplifies parsing an input string into a SourceFile for testing purposes.
func ParseTypeScript(text string, jsx bool) *ast.SourceFile {
fileName := core.IfElse(jsx, "/main.tsx", "/main.ts")
file := parser.ParseSourceFile(fileName, tspath.Path(fileName), text, core.ScriptTargetESNext, scanner.JSDocParsingModeParseNone)
file := parser.ParseSourceFile(fileName, tspath.Path(fileName), text, core.ScriptTargetESNext, scanner.JSDocParsingModeParseNone, core.ModuleResolutionKindNodeNext, "")
ast.SetParentInChildren(file.AsNode())
return file
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
other.d.mts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


==== other.d.mts (1 errors) ====
declare function example(): 5;
export = example;
~~~~~~~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.

==== main.mts (0 errors) ====
import example from "./other.mjs";
example();
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
--- old.esmModeDeclarationFileWithExportAssignment.errors.txt
+++ new.esmModeDeclarationFileWithExportAssignment.errors.txt
@@= skipped -0, +-1 lines =@@
@@= skipped -0, +0 lines =@@
-main.mts(1,8): error TS1192: Module '"other"' has no default export.
-other.d.mts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
-
-
-==== other.d.mts (1 errors) ====
- declare function example(): 5;
- export = example;
- ~~~~~~~~~~~~~~~~~
-!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
-
other.d.mts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


@@= skipped -7, +6 lines =@@
~~~~~~~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.

-==== main.mts (1 errors) ====
- import example from "./other.mjs";
+==== main.mts (0 errors) ====
import example from "./other.mjs";
- ~~~~~~~
-!!! error TS1192: Module '"other"' has no default export.
- example();
@@= skipped --1, +1 lines =@@
+<no content>
example();
Loading