@@ -239,6 +239,57 @@ pnpm-lock.yaml
239239 } ) ;
240240} ) ;
241241
242+ Deno . test ( "should warn when using separate declarations with a script output" , async ( ) => {
243+ const warnings = await captureWarnings ( ( ) =>
244+ runTest ( "test_project" , {
245+ entryPoints : [ "mod.ts" ] ,
246+ outDir : "./npm" ,
247+ declaration : "separate" ,
248+ shims : {
249+ deno : "dev" ,
250+ } ,
251+ test : false ,
252+ typeCheck : false ,
253+ skipNpmInstall : true ,
254+ package : {
255+ name : "add" ,
256+ version : "1.0.0" ,
257+ } ,
258+ } )
259+ ) ;
260+
261+ assertStringIncludes (
262+ warnings . join ( "\n" ) ,
263+ "The 'separate' declaration build option" ,
264+ ) ;
265+ } ) ;
266+
267+ Deno . test ( "should not warn about separate declarations without a script output" , async ( ) => {
268+ const warnings = await captureWarnings ( ( ) =>
269+ runTest ( "test_project" , {
270+ entryPoints : [ "mod.ts" ] ,
271+ outDir : "./npm" ,
272+ declaration : "separate" ,
273+ scriptModule : false ,
274+ shims : {
275+ deno : "dev" ,
276+ } ,
277+ test : false ,
278+ typeCheck : false ,
279+ skipNpmInstall : true ,
280+ package : {
281+ name : "add" ,
282+ version : "1.0.0" ,
283+ } ,
284+ } )
285+ ) ;
286+
287+ assertEquals (
288+ warnings . some ( ( w ) => w . includes ( "declaration build option" ) ) ,
289+ false ,
290+ ) ;
291+ } ) ;
292+
242293Deno . test ( "should build umd module" , async ( ) => {
243294 await runTest ( "test_project" , {
244295 entryPoints : [ "mod.ts" ] ,
@@ -1840,6 +1891,20 @@ function assertPreloadModuleOutput(output: Output) {
18401891 assertEquals ( filePaths . includes ( "test_preload" ) , false ) ;
18411892}
18421893
1894+ async function captureWarnings ( action : ( ) => Promise < void > ) {
1895+ const warnings : string [ ] = [ ] ;
1896+ const originalWarn = console . warn ;
1897+ console . warn = ( ...args : unknown [ ] ) => {
1898+ warnings . push ( args . join ( " " ) ) ;
1899+ } ;
1900+ try {
1901+ await action ( ) ;
1902+ } finally {
1903+ console . warn = originalWarn ;
1904+ }
1905+ return warnings ;
1906+ }
1907+
18431908async function captureLogs ( action : ( ) => Promise < void > ) {
18441909 const logs : string [ ] = [ ] ;
18451910 const originalLog = console . log ;
0 commit comments