From 90af411e37fe4c773d7c11058afe13bf14954b05 Mon Sep 17 00:00:00 2001 From: ikatyang Date: Wed, 28 Jun 2017 15:43:19 +0800 Subject: [PATCH] fix(template): remove unnecessary importing placeholder --- gulpfile.ts | 19 +++++-------------- templates/$curried-functions.ts | 18 ++++++++---------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/gulpfile.ts b/gulpfile.ts index d628303..88e7c27 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -179,20 +179,11 @@ function get_top_level_members(filename: string): dts.ITopLevelMember[] { throw new Error(`Exported functions in ${filename} should be prefixed with $`); } - const placeholder_imports = - (functions[0].type!.parameters!.length <= 1) - ? [] - : [ - dts.create_import_named({ - from: './$placeholder', - members: [ - dts.create_import_member({ - name: placeholder_name_abbr, - property: placeholder_name, - }), - ], - }), - ]; + const placeholder_imports = (!placeholder || functions[0].type!.parameters!.length <= 1) + ? [] + : dts.parse(` + import {${placeholder_name} as ${placeholder_name_abbr}} from './$placeholder'; + `).members; const curried_declarations = create_curried_declarations( filename, diff --git a/templates/$curried-functions.ts b/templates/$curried-functions.ts index 21696f5..7ab7842 100644 --- a/templates/$curried-functions.ts +++ b/templates/$curried-functions.ts @@ -5,16 +5,14 @@ import {create_curried_interfaces} from './utils/create-curried-interfaces'; export const max_curry_level = 6; export default (selectable: boolean, placeholder: boolean) => [ - dts.create_import_named({ - members: [ - dts.create_import_member({ - name: placeholder_name_abbr, - property: placeholder_name, - }), - ], - from: './$placeholder', - }), - ...dts.parse(`export type CurriedFunction0 = () => R;`).members, + ...dts.parse(` + ${ + placeholder + ? `import {${placeholder_name} as ${placeholder_name_abbr}} from './$placeholder';` + : '' + } + export type CurriedFunction0 = () => R; + `).members, ...create_curried_interfaces(max_curry_level, selectable, placeholder).map( the_interface => ({ ...the_interface,