@@ -49,8 +49,9 @@ func (e *emitter) emit() {
49
49
e .emitBuildInfo (e .paths .BuildInfoPath ())
50
50
}
51
51
52
- func (e * emitter ) getDeclarationTransformers (emitContext * printer.EmitContext , declarationFilePath string , declarationMapPath string ) []* declarations.DeclarationTransformer {
53
- transform := declarations .NewDeclarationTransformer (e .host , emitContext , e .host .Options (), declarationFilePath , declarationMapPath )
52
+ func (e * emitter ) getDeclarationTransformers (emitContext * printer.EmitContext , sourceFile * ast.SourceFile , declarationFilePath string , declarationMapPath string ) []* declarations.DeclarationTransformer {
53
+ emitResolver := e .host .GetEmitResolver (sourceFile , false /*skipDiagnostics*/ ) // !!! conditionally skip diagnostics
54
+ transform := declarations .NewDeclarationTransformer (e .host , emitResolver , emitContext , e .host .Options (), declarationFilePath , declarationMapPath )
54
55
return []* declarations.DeclarationTransformer {transform }
55
56
}
56
57
@@ -85,7 +86,7 @@ func getScriptTransformers(emitContext *printer.EmitContext, host printer.EmitHo
85
86
var emitResolver printer.EmitResolver
86
87
var referenceResolver binder.ReferenceResolver
87
88
if importElisionEnabled || options .GetJSXTransformEnabled () {
88
- emitResolver = host .GetEmitResolver ()
89
+ emitResolver = host .GetEmitResolver (sourceFile , false /*skipDiagnostics*/ ) // !!! conditionally skip diagnostics
89
90
emitResolver .MarkLinkedReferencesRecursively (sourceFile )
90
91
referenceResolver = emitResolver
91
92
} else {
@@ -178,7 +179,7 @@ func (e *emitter) emitDeclarationFile(sourceFile *ast.SourceFile, declarationFil
178
179
var diags []* ast.Diagnostic
179
180
emitContext , putEmitContext := printer .GetEmitContext ()
180
181
defer putEmitContext ()
181
- for _ , transformer := range e .getDeclarationTransformers (emitContext , declarationFilePath , declarationMapPath ) {
182
+ for _ , transformer := range e .getDeclarationTransformers (emitContext , sourceFile , declarationFilePath , declarationMapPath ) {
182
183
sourceFile = transformer .TransformSourceFile (sourceFile )
183
184
diags = append (diags , transformer .GetDiagnostics ()... )
184
185
}
@@ -377,7 +378,6 @@ type SourceFileMayBeEmittedHost interface {
377
378
IsSourceFileFromExternalLibrary (file * ast.SourceFile ) bool
378
379
GetCurrentDirectory () string
379
380
UseCaseSensitiveFileNames () bool
380
- SourceFiles () []* ast.SourceFile
381
381
}
382
382
383
383
func sourceFileMayBeEmitted (sourceFile * ast.SourceFile , host SourceFileMayBeEmittedHost , forceDtsEmit bool ) bool {
@@ -435,7 +435,7 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit
435
435
return true
436
436
}
437
437
438
- func getSourceFilesToEmit (host SourceFileMayBeEmittedHost , targetSourceFile * ast.SourceFile , forceDtsEmit bool ) []* ast.SourceFile {
438
+ func getSourceFilesToEmit (host printer. EmitHost , targetSourceFile * ast.SourceFile , forceDtsEmit bool ) []* ast.SourceFile {
439
439
// !!! outFile not yet implemented, may be deprecated
440
440
var sourceFiles []* ast.SourceFile
441
441
if targetSourceFile != nil {
@@ -452,13 +452,13 @@ func isSourceFileNotJson(file *ast.SourceFile) bool {
452
452
return ! ast .IsJsonSourceFile (file )
453
453
}
454
454
455
- func getDeclarationDiagnostics (host EmitHost , file * ast.SourceFile ) []* ast.Diagnostic {
455
+ func getDeclarationDiagnostics (host EmitHost , resolver printer. EmitResolver , file * ast.SourceFile ) []* ast.Diagnostic {
456
456
fullFiles := core .Filter (getSourceFilesToEmit (host , file , false ), isSourceFileNotJson )
457
457
if ! core .Some (fullFiles , func (f * ast.SourceFile ) bool { return f == file }) {
458
458
return []* ast.Diagnostic {}
459
459
}
460
460
options := host .Options ()
461
- transform := declarations .NewDeclarationTransformer (host , nil , options , "" , "" )
461
+ transform := declarations .NewDeclarationTransformer (host , resolver , nil , options , "" , "" )
462
462
transform .TransformSourceFile (file )
463
463
return transform .GetDiagnostics ()
464
464
}
0 commit comments