@@ -1650,6 +1650,115 @@ namespace ts.projectSystem {
1650
1650
assert ( completions && completions . entries [ 0 ] . name !== "hello" , `unexpected hello entry in completion list` ) ;
1651
1651
} ) ;
1652
1652
1653
+ it ( "no tsconfig script block diagnostic errors" , ( ) => {
1654
+
1655
+ // #1. Ensure no diagnostic errors when allowJs is true
1656
+ const file1 = {
1657
+ path : "/a/b/f1.ts" ,
1658
+ content : ` `
1659
+ } ;
1660
+ const file2 = {
1661
+ path : "/a/b/f2.html" ,
1662
+ content : `var hello = "hello";`
1663
+ } ;
1664
+ const config1 = {
1665
+ path : "/a/b/tsconfig.json" ,
1666
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } } )
1667
+ } ;
1668
+
1669
+ let host = createServerHost ( [ file1 , file2 , config1 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1670
+ let session = createSession ( host ) ;
1671
+
1672
+ // Specify .html extension as mixed content in a configure host request
1673
+ const extraFileExtensions = [ { extension : ".html" , scriptKind : ScriptKind . JS , isMixedContent : true } ] ;
1674
+ const configureHostRequest = makeSessionRequest < protocol . ConfigureRequestArguments > ( CommandNames . Configure , { extraFileExtensions } ) ;
1675
+ session . executeCommand ( configureHostRequest ) . response ;
1676
+
1677
+ openFilesForSession ( [ file1 ] , session ) ;
1678
+ let projectService = session . getProjectService ( ) ;
1679
+
1680
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1681
+
1682
+ let diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1683
+ assert . deepEqual ( diagnostics , [ ] ) ;
1684
+
1685
+ // #2. Ensure no errors when allowJs is false
1686
+ const config2 = {
1687
+ path : "/a/b/tsconfig.json" ,
1688
+ content : JSON . stringify ( { compilerOptions : { allowJs : false } } )
1689
+ } ;
1690
+
1691
+ host = createServerHost ( [ file1 , file2 , config2 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1692
+ session = createSession ( host ) ;
1693
+
1694
+ session . executeCommand ( configureHostRequest ) . response ;
1695
+
1696
+ openFilesForSession ( [ file1 ] , session ) ;
1697
+ projectService = session . getProjectService ( ) ;
1698
+
1699
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1700
+
1701
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1702
+ assert . deepEqual ( diagnostics , [ ] ) ;
1703
+
1704
+ // #3. Ensure no errors when compiler options aren't specified
1705
+ const config3 = {
1706
+ path : "/a/b/tsconfig.json" ,
1707
+ content : JSON . stringify ( { } )
1708
+ } ;
1709
+
1710
+ host = createServerHost ( [ file1 , file2 , config3 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1711
+ session = createSession ( host ) ;
1712
+
1713
+ session . executeCommand ( configureHostRequest ) . response ;
1714
+
1715
+ openFilesForSession ( [ file1 ] , session ) ;
1716
+ projectService = session . getProjectService ( ) ;
1717
+
1718
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1719
+
1720
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1721
+ assert . deepEqual ( diagnostics , [ ] ) ;
1722
+
1723
+ // #4. Ensure no errors when files are explicitly specified in tsconfig
1724
+ const config4 = {
1725
+ path : "/a/b/tsconfig.json" ,
1726
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } , files : [ file1 . path , file2 . path ] } )
1727
+ } ;
1728
+
1729
+ host = createServerHost ( [ file1 , file2 , config4 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1730
+ session = createSession ( host ) ;
1731
+
1732
+ session . executeCommand ( configureHostRequest ) . response ;
1733
+
1734
+ openFilesForSession ( [ file1 ] , session ) ;
1735
+ projectService = session . getProjectService ( ) ;
1736
+
1737
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1738
+
1739
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1740
+ assert . deepEqual ( diagnostics , [ ] ) ;
1741
+
1742
+ // #4. Ensure no errors when files are explicitly excluded in tsconfig
1743
+ const config5 = {
1744
+ path : "/a/b/tsconfig.json" ,
1745
+ content : JSON . stringify ( { compilerOptions : { allowJs : true } , exclude : [ file2 . path ] } )
1746
+ } ;
1747
+
1748
+ host = createServerHost ( [ file1 , file2 , config5 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
1749
+ session = createSession ( host ) ;
1750
+
1751
+ session . executeCommand ( configureHostRequest ) . response ;
1752
+
1753
+ openFilesForSession ( [ file1 ] , session ) ;
1754
+ projectService = session . getProjectService ( ) ;
1755
+
1756
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
1757
+
1758
+ diagnostics = projectService . configuredProjects [ 0 ] . getLanguageService ( ) . getCompilerOptionsDiagnostics ( ) ;
1759
+ assert . deepEqual ( diagnostics , [ ] ) ;
1760
+ } ) ;
1761
+
1653
1762
it ( "project structure update is deferred if files are not added\removed" , ( ) => {
1654
1763
const file1 = {
1655
1764
path : "/a/b/f1.ts" ,
0 commit comments