@@ -128,7 +128,7 @@ func (p *Program) GetParseFileRedirect(fileName string) string {
128
128
}
129
129
130
130
func (p * Program ) ForEachResolvedProjectReference (
131
- fn func (path tspath.Path , config * tsoptions.ParsedCommandLine ),
131
+ fn func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions. ParsedCommandLine , index int ),
132
132
) {
133
133
p .projectReferenceFileMapper .forEachResolvedProjectReference (fn )
134
134
}
@@ -544,9 +544,7 @@ func (p *Program) verifyCompilerOptions() {
544
544
}
545
545
}
546
546
547
- // !!! Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified
548
-
549
- // !!! verifyProjectReferences
547
+ p .verifyProjectReferences ()
550
548
551
549
if options .Composite .IsTrue () {
552
550
var rootPaths collections.Set [tspath.Path ]
@@ -810,12 +808,13 @@ func (p *Program) verifyCompilerOptions() {
810
808
}
811
809
812
810
outputpaths .ForEachEmittedFile (p , options , func (emitFileNames * outputpaths.OutputPaths , sourceFile * ast.SourceFile ) bool {
813
- if ! options .EmitDeclarationOnly .IsTrue () {
814
- verifyEmitFilePath (emitFileNames .JsFilePath ())
815
- }
811
+ verifyEmitFilePath (emitFileNames .JsFilePath ())
812
+ verifyEmitFilePath (emitFileNames .SourceMapFilePath ())
816
813
verifyEmitFilePath (emitFileNames .DeclarationFilePath ())
814
+ verifyEmitFilePath (emitFileNames .DeclarationMapPath ())
817
815
return false
818
816
}, p .getSourceFilesToEmit (nil , false ), false )
817
+ verifyEmitFilePath (p .opts .Config .GetBuildInfoFileName ())
819
818
}
820
819
}
821
820
@@ -824,6 +823,58 @@ func (p *Program) blockEmittingOfFile(emitFileName string, diag *ast.Diagnostic)
824
823
p .programDiagnostics = append (p .programDiagnostics , diag )
825
824
}
826
825
826
+ func (p * Program ) IsEmitBlocked (emitFileName string ) bool {
827
+ return p .hasEmitBlockingDiagnostics .Has (p .toPath (emitFileName ))
828
+ }
829
+
830
+ func (p * Program ) verifyProjectReferences () {
831
+ buildInfoFileName := core .IfElse (! p .Options ().SuppressOutputPathCheck .IsTrue (), p .opts .Config .GetBuildInfoFileName (), "" )
832
+ createDiagnosticForReference := func (config * tsoptions.ParsedCommandLine , index int , message * diagnostics.Message , args ... any ) {
833
+ var sourceFile * ast.SourceFile
834
+ if config .ConfigFile != nil {
835
+ sourceFile = config .ConfigFile .SourceFile
836
+ }
837
+ diag := tsoptions .ForEachTsConfigPropArray (sourceFile , "references" , func (property * ast.PropertyAssignment ) * ast.Diagnostic {
838
+ if ast .IsArrayLiteralExpression (property .Initializer ) {
839
+ value := property .Initializer .AsArrayLiteralExpression ().Elements .Nodes
840
+ if len (value ) > index {
841
+ return tsoptions .CreateDiagnosticForNodeInSourceFileOrCompilerDiagnostic (sourceFile , value [index ], message , args ... )
842
+ }
843
+ }
844
+ return nil
845
+ })
846
+ if diag == nil {
847
+ diag = ast .NewCompilerDiagnostic (message , args ... )
848
+ }
849
+ p .programDiagnostics = append (p .programDiagnostics , diag )
850
+ }
851
+
852
+ p .ForEachResolvedProjectReference (func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions.ParsedCommandLine , index int ) {
853
+ ref := parent .ProjectReferences ()[index ]
854
+ // !!! Deprecated in 5.0 and removed since 5.5
855
+ // verifyRemovedProjectReference(ref, parent, index);
856
+ if config == nil {
857
+ createDiagnosticForReference (parent , index , diagnostics .File_0_not_found , ref .Path )
858
+ return
859
+ }
860
+ refOptions := config .CompilerOptions ()
861
+ if ! refOptions .Composite .IsTrue () || refOptions .NoEmit .IsTrue () {
862
+ if len (config .FileNames ()) > 0 {
863
+ if ! refOptions .Composite .IsTrue () {
864
+ createDiagnosticForReference (parent , index , diagnostics .Referenced_project_0_must_have_setting_composite_Colon_true , ref .Path )
865
+ }
866
+ if refOptions .NoEmit .IsTrue () {
867
+ createDiagnosticForReference (parent , index , diagnostics .Referenced_project_0_may_not_disable_emit , ref .Path )
868
+ }
869
+ }
870
+ }
871
+ if buildInfoFileName != "" && buildInfoFileName == config .GetBuildInfoFileName () {
872
+ createDiagnosticForReference (parent , index , diagnostics .Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1 , buildInfoFileName , ref .Path )
873
+ p .hasEmitBlockingDiagnostics .Add (p .toPath (buildInfoFileName ))
874
+ }
875
+ })
876
+ }
877
+
827
878
func hasZeroOrOneAsteriskCharacter (str string ) bool {
828
879
seenAsterisk := false
829
880
for _ , ch := range str {
0 commit comments