Skip to content

Commit

Permalink
build: handle special case of empty namespace better
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Nov 28, 2024
1 parent 890af82 commit 27b8283
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function createTestFile() {
* @returns {string} `index.d.ts` contents
*/
function createDefinitionFile( ns, imports, properties, description ) {
return [
var lines = [
'/*',
'* @license Apache-2.0',
'*',
Expand All @@ -121,16 +121,23 @@ function createDefinitionFile( ns, imports, properties, description ) {
'',
'// TypeScript Version: 4.1',
'',
'/* eslint-disable max-lines */',
'',
imports.join( '\n' ),
'',
'/* eslint-disable max-lines' + ( ( properties.length === 0 ) ? ', @typescript-eslint/no-empty-interface' : '' ) + ' */',
''
];
if ( imports.length > 0 ) {
lines.push( '', imports.join( '\n' ), '' );
}
lines = lines.concat([
'/**',
'* Interface describing the `'+ns+'` namespace.',
'*/',
'interface Namespace {',
properties.join( '\n' ),
'}',
'*/'
]);
if ( properties.length > 0 ) {
lines.push( 'interface Namespace {', properties.join( '\n' ), '}' );
} else {
lines.push( 'interface Namespace {}' );
}
lines = lines.concat([
'',
'/**',
'* '+description,
Expand All @@ -142,7 +149,8 @@ function createDefinitionFile( ns, imports, properties, description ) {
'',
'export = ns;',
''
].join( '\n' );
]);
return lines.join( '\n' );
}

/**
Expand Down

0 comments on commit 27b8283

Please sign in to comment.