@@ -42,42 +42,51 @@ const base = getConverter2Base();
4242const app = getConverter2App ( ) ;
4343const program = getConverter2Program ( ) ;
4444
45- function doConvert ( entry : string ) {
46- const entryPoint = [
47- join ( base , `issues/${ entry } .ts` ) ,
48- join ( base , `issues/${ entry } .d.ts` ) ,
49- join ( base , `issues/${ entry } .tsx` ) ,
50- join ( base , `issues/${ entry } .js` ) ,
51- join ( base , "issues" , entry , "index.ts" ) ,
52- join ( base , "issues" , entry , "index.js" ) ,
53- ] . find ( existsSync ) ;
54-
55- ok ( entryPoint , `No entry point found for ${ entry } ` ) ;
56- const sourceFile = program . getSourceFile ( entryPoint ) ;
57- ok ( sourceFile , `No source file found for ${ entryPoint } ` ) ;
58-
59- app . options . setValue ( "entryPoints" , [ entryPoint ] ) ;
45+ function doConvert ( entries : string [ ] ) {
46+ const entryPoints = entries
47+ . map ( ( entry ) =>
48+ [
49+ join ( base , `issues/${ entry } .ts` ) ,
50+ join ( base , `issues/${ entry } .d.ts` ) ,
51+ join ( base , `issues/${ entry } .tsx` ) ,
52+ join ( base , `issues/${ entry } .js` ) ,
53+ join ( base , "issues" , entry , "index.ts" ) ,
54+ join ( base , "issues" , entry , "index.js" ) ,
55+ join ( base , "issues" , entry ) ,
56+ ] . find ( existsSync ) ,
57+ )
58+ . filter ( ( x ) => x !== undefined ) ;
59+
60+ const files = entryPoints . map ( ( e ) => program . getSourceFile ( e ) ) ;
61+ for ( const [ index , file ] of files . entries ( ) ) {
62+ ok ( file , `No source file found for ${ entryPoints [ index ] } ` ) ;
63+ }
64+
65+ app . options . setValue ( "entryPoints" , entryPoints ) ;
6066 clearCommentCache ( ) ;
61- return app . converter . convert ( [
62- {
63- displayName : entry ,
64- program,
65- sourceFile,
66- } ,
67- ] ) ;
67+ return app . converter . convert (
68+ files . map ( ( file , index ) => {
69+ return {
70+ displayName : entries [ index ] . replace ( / \. [ t j ] s x ? $ / , "" ) ,
71+ program,
72+ sourceFile : file ! ,
73+ } ;
74+ } ) ,
75+ ) ;
6876}
6977
7078describe ( "Issue Tests" , ( ) => {
7179 let logger : TestLogger ;
72- let convert : ( name ? : string ) => ProjectReflection ;
80+ let convert : ( ... entries : string [ ] ) => ProjectReflection ;
7381 let optionsSnap : { __optionSnapshot : never } ;
7482
7583 beforeEach ( function ( ) {
7684 app . logger = logger = new TestLogger ( ) ;
7785 optionsSnap = app . options . snapshot ( ) ;
7886 const issueNumber = this . currentTest ?. title . match ( / # ( \d + ) / ) ?. [ 1 ] ;
7987 ok ( issueNumber , "Test name must contain an issue number." ) ;
80- convert = ( name = `gh${ issueNumber } ` ) => doConvert ( name ) ;
88+ convert = ( ...entries ) =>
89+ doConvert ( entries . length ? entries : [ `gh${ issueNumber } ` ] ) ;
8190 } ) ;
8291
8392 afterEach ( ( ) => {
@@ -1885,4 +1894,18 @@ describe("Issue Tests", () => {
18851894 equal ( getSigComment ( project , "Callable" , 0 ) , "A" ) ;
18861895 equal ( getSigComment ( project , "Callable" , 1 ) , "B" ) ;
18871896 } ) ;
1897+
1898+ it ( "#2774 gets global symbols in a consistent manner" , ( ) => {
1899+ const project = convert (
1900+ "gh2774/gh2774.ts" ,
1901+ "gh2774/globalAugment.ts" ,
1902+ "gh2774/moduleAugment.ts" ,
1903+ ) ;
1904+
1905+ const decl = query ( project , "gh2774/gh2774.GH2774" ) ;
1906+ equal (
1907+ decl . children ?. map ( ( c ) => c . name ) ,
1908+ [ "Extensions" ] ,
1909+ ) ;
1910+ } ) ;
18881911} ) ;
0 commit comments