@@ -7,7 +7,7 @@ const importModule = (module, level) => `require('${ level ? '../'.repeat(level)
77
88const importModules = ( { modules, level } ) => modules . map ( module => importModule ( module , level ) ) . join ( '\n' ) ;
99
10- const buildTypeName = ( namespace , name ) => `CoreJS.${ namespace } ${ String ( name ) . charAt ( 0 ) . toUpperCase ( ) + String ( name ) . slice ( 1 ) } ` ;
10+ const buildCoreJSTypeName = ( namespace , name ) => `CoreJS.${ namespace } ${ name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) } ` ;
1111
1212function isAllowedFunctionName ( name ) {
1313 try {
@@ -36,13 +36,9 @@ const namespacesWithOneGeneric = [
3636 'AsyncIterator' ,
3737] ;
3838
39- function existsInES6 ( namespace ) {
40- const missingNamespacesInES6 = [
41- 'AsyncIterator' ,
42- ] ;
43-
44- return ! missingNamespacesInES6 . includes ( namespace ) ;
45- }
39+ const missingNamespacesInES6 = [
40+ 'AsyncIterator' ,
41+ ] ;
4642
4743function getGenericsForNamespace ( namespace ) {
4844 if ( namespace === 'WeakMap' ) {
@@ -72,13 +68,13 @@ function getCustomGenerics(count) {
7268 return `<${ names . slice ( 0 , count ) . join ( ', ' ) } >` ;
7369}
7470
75- export const wrapEntry = template => `'use strict';\n${ template } \n` ;
71+ export const wrapEntryInStrict = template => `'use strict';\n${ template } \n` ;
7672
7773export const $justImport = p => ( {
7874 entry : dedent `
7975 ${ importModules ( p ) }
8076 ` ,
81- dts : '' ,
77+ types : '' ,
8278} ) ;
8379
8480export const $prototype = p => ( {
@@ -89,7 +85,7 @@ export const $prototype = p => ({
8985
9086 module.exports = getBuiltInPrototypeMethod('${ p . namespace } ', '${ p . name } ');
9187 ` ,
92- dts : dedent `
88+ types : dedent `
9389 declare module '${ p . packageName } ${ p . entry } ' {
9490 type method${ getGenericsForNamespace ( p . namespace ) } = ${ p . prefix ?? '' } ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } ['${ p . name } '];
9591 export = method;
@@ -105,7 +101,7 @@ export const $prototypeIterator = p => ({
105101
106102 module.exports = getIteratorMethod(${ p . source } );
107103 ` ,
108- dts : dedent `
104+ types : dedent `
109105 declare module '${ p . packageName } ${ p . entry } ' {
110106 const method: typeof ${ p . prefix ?? '' } ${ p . namespace } .prototype[typeof Symbol.iterator];
111107 export = method;
@@ -121,10 +117,10 @@ export const $uncurried = p => ({
121117
122118 module.exports = entryUnbind('${ p . namespace } ', '${ p . name } ');
123119 ` ,
124- dts : dedent `
120+ types : dedent `
125121 declare module '${ p . packageName } ${ p . entry } ' {
126122 type method${ getGenericsForNamespace ( p . namespace ) } = ${ p . prefix ?? '' } ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } ['${ p . name } '];
127- const resultMethod: ${ getGenericsForNamespace ( p . namespace ) } (self: ${ p . prefix && ! existsInES6 ( p . namespace ) ? p . prefix : '' } ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } , ...args: Parameters<method${ getCommonGenericsForNamespace ( p . namespace ) } >) => ReturnType<method${ getCommonGenericsForNamespace ( p . namespace ) } >;
123+ const resultMethod: ${ getGenericsForNamespace ( p . namespace ) } (self: ${ p . prefix && ! missingNamespacesInES6 . includes ( p . namespace ) ? p . prefix : '' } ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } , ...args: Parameters<method${ getCommonGenericsForNamespace ( p . namespace ) } >) => ReturnType<method${ getCommonGenericsForNamespace ( p . namespace ) } >;
128124 export = resultMethod;
129125 }
130126 ` ,
@@ -138,9 +134,9 @@ export const $uncurriedWithCustomType = p => ({
138134
139135 module.exports = entryUnbind('${ p . namespace } ', '${ p . name } ');
140136 ` ,
141- dts : dedent `
137+ types : dedent `
142138 declare module '${ p . packageName } ${ p . entry } ' {
143- const resultMethod: ${ getCustomGenerics ( p . genericsCount ) } (self: ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } , ...args: Parameters<${ buildTypeName ( p . namespace , p . name ) } ${ getCustomGenerics ( p . genericsCount ) } >) => ReturnType<${ buildTypeName ( p . namespace , p . name ) } ${ getCustomGenerics ( p . genericsCount ) } >;
139+ const resultMethod: ${ getCustomGenerics ( p . genericsCount ) } (self: ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } , ...args: Parameters<${ buildCoreJSTypeName ( p . namespace , p . name ) } ${ getCustomGenerics ( p . genericsCount ) } >) => ReturnType<${ buildCoreJSTypeName ( p . namespace , p . name ) } ${ getCustomGenerics ( p . genericsCount ) } >;
144140 export = resultMethod;
145141 }
146142 ` ,
@@ -155,7 +151,7 @@ export const $uncurriedIterator = p => ({
155151
156152 module.exports = uncurryThis(getIteratorMethod(${ p . source } ));
157153 ` ,
158- dts : dedent `
154+ types : dedent `
159155 declare module '${ p . packageName } ${ p . entry } ' {
160156 type method${ getGenericsForNamespace ( p . namespace ) } = ${ p . namespace } ${ getGenericsForNamespace ( p . namespace ) } [typeof Symbol.iterator];
161157 const resultMethod: ${ getGenericsForNamespace ( p . namespace ) } (self: ${ p . namespace } ${ getCommonGenericsForNamespace ( p . namespace ) } , ...args: Parameters<method${ getCommonGenericsForNamespace ( p . namespace ) } >) => ReturnType<method${ getCommonGenericsForNamespace ( p . namespace ) } >;
@@ -172,7 +168,7 @@ export const $static = p => ({
172168
173169 module.exports = getBuiltInStaticMethod('${ p . namespace } ', '${ p . name } ');
174170 ` ,
175- dts : dedent `
171+ types : dedent `
176172 declare module '${ p . packageName } ${ p . entry } ' {
177173 const method: typeof ${ p . prefix ?? '' } ${ p . namespace } .${ p . name } ;
178174 export = method;
@@ -195,7 +191,7 @@ export const $staticWithContext = p => ({
195191 return apply(method, isCallable(this) ? this : getBuiltIn('${ p . namespace } '), arguments);
196192 };
197193 ` ,
198- dts : dedent `
194+ types : dedent `
199195 declare module '${ p . packageName } ${ p . entry } ' {
200196 const method: typeof ${ p . prefix ?? '' } ${ p . namespace } .${ p . name } ;
201197 export = method;
@@ -214,7 +210,7 @@ export const $patchableStatic = p => ({
214210 return apply(getBuiltInStaticMethod('${ p . namespace } ', '${ p . name } '), this, arguments);
215211 };
216212 ` ,
217- dts : dedent `
213+ types : dedent `
218214 declare module '${ p . packageName } ${ p . entry } ' {
219215 const method: typeof ${ p . prefix ?? '' } ${ p . namespace } .${ p . name } ;
220216 export = method;
@@ -230,7 +226,7 @@ export const $namespace = p => ({
230226
231227 module.exports = path.${ p . name } ;
232228 ` ,
233- dts : dedent `
229+ types : dedent `
234230 declare module '${ p . packageName } ${ p . entry } ' {
235231 const namespace: typeof ${ p . prefix ?? '' } ${ p . name } ;
236232 export = namespace;
@@ -246,7 +242,7 @@ export const $helper = p => ({
246242
247243 module.exports = $export;
248244 ` ,
249- dts : dedent `
245+ types : dedent `
250246 declare module '${ p . packageName } ${ p . entry } ' {
251247 const helper: (arg: NonNullable<any>) => any;
252248 export = helper;
@@ -262,7 +258,7 @@ export const $path = p => ({
262258
263259 module.exports = path;
264260 ` ,
265- dts : dedent `
261+ types : dedent `
266262 declare module '${ p . packageName } ${ p . entry } ' {
267263 const path: typeof globalThis;
268264 export = path;
@@ -283,7 +279,7 @@ export const $instanceArray = p => ({
283279 return ownProperty;
284280 };
285281 ` ,
286- dts : dedent `
282+ types : dedent `
287283 declare module '${ p . packageName } ${ p . entry } ' {
288284 const method: (arg: NonNullable<any>) => any;
289285 export = method;
@@ -305,7 +301,7 @@ export const $instanceNumber = p => ({
305301 return ownProperty;
306302 };
307303 ` ,
308- dts : dedent `
304+ types : dedent `
309305 declare module '${ p . packageName } ${ p . entry } ' {
310306 const method: (arg: NonNullable<any>) => any;
311307 export = method;
@@ -327,7 +323,7 @@ export const $instanceString = p => ({
327323 return ownProperty;
328324 };
329325 ` ,
330- dts : dedent `
326+ types : dedent `
331327 declare module '${ p . packageName } ${ p . entry } ' {
332328 const method: (arg: NonNullable<any>) => any;
333329 export = method;
@@ -349,7 +345,7 @@ export const $instanceFunction = p => ({
349345 } return ownProperty;
350346 };
351347 ` ,
352- dts : dedent `
348+ types : dedent `
353349 declare module '${ p . packageName } ${ p . entry } ' {
354350 const method: (arg: NonNullable<any>) => any;
355351 export = method;
@@ -377,7 +373,7 @@ export const $instanceDOMIterables = p => ({
377373 return ownProperty;
378374 };
379375 ` ,
380- dts : dedent `
376+ types : dedent `
381377 declare module '${ p . packageName } ${ p . entry } ' {
382378 const method: (arg: NonNullable<any>) => any;
383379 export = method;
@@ -402,7 +398,7 @@ export const $instanceArrayString = p => ({
402398 return ownProperty;
403399 };
404400 ` ,
405- dts : dedent `
401+ types : dedent `
406402 declare module '${ p . packageName } ${ p . entry } ' {
407403 const method: (arg: NonNullable<any>) => any;
408404 export = method;
@@ -433,7 +429,7 @@ export const $instanceArrayDOMIterables = p => ({
433429 return ownProperty;
434430 };
435431 ` ,
436- dts : dedent `
432+ types : dedent `
437433 declare module '${ p . packageName } ${ p . entry } ' {
438434 const method: (arg: NonNullable<any>) => any;
439435 export = method;
@@ -454,7 +450,7 @@ export const $instanceRegExpFlags = p => ({
454450 return (it === RegExpPrototype || isPrototypeOf(RegExpPrototype, it)) ? flags(it) : it.flags;
455451 };
456452 ` ,
457- dts : dedent `
453+ types : dedent `
458454 declare module '${ p . packageName } ${ p . entry } ' {
459455 const method: (arg: NonNullable<any>) => any;
460456 export = method;
@@ -468,5 +464,5 @@ export const $proposal = p => ({
468464 // ${ p . link }
469465 ${ importModules ( p ) }
470466 ` ,
471- dts : '' ,
467+ types : '' ,
472468} ) ;
0 commit comments