@@ -1713,6 +1713,115 @@ namespace ts.projectSystem {
1713
1713
assert ( completions && completions . entries [ 0 ] . name !== "hello" , `unexpected hello entry in completion list` ) ;
1714
1714
} ) ;
1715
1715
1716
+ it ( "no tsconfig script block diagnostic errors" , ( ) => {
1717
+
1718
+ // #1. Ensure no diagnostic errors when allowJs is true
1719
+ const file1 = {
1720
+ path : "/a/b/f1.ts" ,
1721
+ content : ` `
1722
+ } ;
1723
+ const file2 = {
1724
+ path : "/a/b/f2.html" ,
1725
+ content : `var hello = "hello";`
1726
+ } ;
1727
+ const config1 = {
1728
+ path : "/a/b/tsconfig.json" ,
1729
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } } )
1730
+ } ;
1731
+
1732
+ let host = createServerHost ( [ file1 , file2 , config1 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1733
+ let session = createSession ( host ) ;
1734
+
1735
+ // Specify .html extension as mixed content in a configure host request
1736
+ const extraFileExtensions = [ { extension : ".html" , scriptKind : ScriptKind . JS , isMixedContent : true } ] ;
1737
+ const configureHostRequest = makeSessionRequest < protocol . ConfigureRequestArguments > ( CommandNames . Configure , { extraFileExtensions } ) ;
1738
+ session . executeCommand ( configureHostRequest ) . response ;
1739
+
1740
+ openFilesForSession ( [ file1 ] , session ) ;
1741
+ let projectService = session . getProjectService ( ) ;
1742
+
1743
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1744
+
1745
+ let diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1746
+ assert . deepEqual ( diagnostics , [ ] ) ;
1747
+
1748
+ // #2. Ensure no errors when allowJs is false
1749
+ const config2 = {
1750
+ path : "/a/b/tsconfig.json" ,
1751
+ content : JSON . stringify ( { compilerOptions : { allowJs : false } } )
1752
+ } ;
1753
+
1754
+ host = createServerHost ( [ file1 , file2 , config2 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1755
+ session = createSession ( host ) ;
1756
+
1757
+ session . executeCommand ( configureHostRequest ) . response ;
1758
+
1759
+ openFilesForSession ( [ file1 ] , session ) ;
1760
+ projectService = session . getProjectService ( ) ;
1761
+
1762
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1763
+
1764
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1765
+ assert . deepEqual ( diagnostics , [ ] ) ;
1766
+
1767
+ // #3. Ensure no errors when compiler options aren't specified
1768
+ const config3 = {
1769
+ path : "/a/b/tsconfig.json" ,
1770
+ content : JSON . stringify ( { } )
1771
+ } ;
1772
+
1773
+ host = createServerHost ( [ file1 , file2 , config3 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1774
+ session = createSession ( host ) ;
1775
+
1776
+ session . executeCommand ( configureHostRequest ) . response ;
1777
+
1778
+ openFilesForSession ( [ file1 ] , session ) ;
1779
+ projectService = session . getProjectService ( ) ;
1780
+
1781
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1782
+
1783
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1784
+ assert . deepEqual ( diagnostics , [ ] ) ;
1785
+
1786
+ // #4. Ensure no errors when files are explicitly specified in tsconfig
1787
+ const config4 = {
1788
+ path : "/a/b/tsconfig.json" ,
1789
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } , files : [ file1 . path , file2 . path ] } )
1790
+ } ;
1791
+
1792
+ host = createServerHost ( [ file1 , file2 , config4 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1793
+ session = createSession ( host ) ;
1794
+
1795
+ session . executeCommand ( configureHostRequest ) . response ;
1796
+
1797
+ openFilesForSession ( [ file1 ] , session ) ;
1798
+ projectService = session . getProjectService ( ) ;
1799
+
1800
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1801
+
1802
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1803
+ assert . deepEqual ( diagnostics , [ ] ) ;
1804
+
1805
+ // #4. Ensure no errors when files are explicitly excluded in tsconfig
1806
+ const config5 = {
1807
+ path : "/a/b/tsconfig.json" ,
1808
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } , exclude : [ file2 . path ] } )
1809
+ } ;
1810
+
1811
+ host = createServerHost ( [ file1 , file2 , config5 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1812
+ session = createSession ( host ) ;
1813
+
1814
+ session . executeCommand ( configureHostRequest ) . response ;
1815
+
1816
+ openFilesForSession ( [ file1 ] , session ) ;
1817
+ projectService = session . getProjectService ( ) ;
1818
+
1819
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1820
+
1821
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1822
+ assert . deepEqual ( diagnostics , [ ] ) ;
1823
+ } ) ;
1824
+
1716
1825
it ( "project structure update is deferred if files are not added\removed" , ( ) => {
1717
1826
const file1 = {
1718
1827
path : "/a/b/f1.ts" ,
0 commit comments