Skip to content

Commit 27b8283

Browse files
committed
build: handle special case of empty namespace better
1 parent 890af82 commit 27b8283

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function createTestFile() {
100100
* @returns {string} `index.d.ts` contents
101101
*/
102102
function createDefinitionFile( ns, imports, properties, description ) {
103-
return [
103+
var lines = [
104104
'/*',
105105
'* @license Apache-2.0',
106106
'*',
@@ -121,16 +121,23 @@ function createDefinitionFile( ns, imports, properties, description ) {
121121
'',
122122
'// TypeScript Version: 4.1',
123123
'',
124-
'/* eslint-disable max-lines */',
125-
'',
126-
imports.join( '\n' ),
127-
'',
124+
'/* eslint-disable max-lines' + ( ( properties.length === 0 ) ? ', @typescript-eslint/no-empty-interface' : '' ) + ' */',
125+
''
126+
];
127+
if ( imports.length > 0 ) {
128+
lines.push( '', imports.join( '\n' ), '' );
129+
}
130+
lines = lines.concat([
128131
'/**',
129132
'* Interface describing the `'+ns+'` namespace.',
130-
'*/',
131-
'interface Namespace {',
132-
properties.join( '\n' ),
133-
'}',
133+
'*/'
134+
]);
135+
if ( properties.length > 0 ) {
136+
lines.push( 'interface Namespace {', properties.join( '\n' ), '}' );
137+
} else {
138+
lines.push( 'interface Namespace {}' );
139+
}
140+
lines = lines.concat([
134141
'',
135142
'/**',
136143
'* '+description,
@@ -142,7 +149,8 @@ function createDefinitionFile( ns, imports, properties, description ) {
142149
'',
143150
'export = ns;',
144151
''
145-
].join( '\n' );
152+
]);
153+
return lines.join( '\n' );
146154
}
147155

148156
/**

0 commit comments

Comments
 (0)