Skip to content

Commit

Permalink
Merge branch 'develop' into fix/recognize-tsx-function-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
buehler authored Aug 9, 2017
2 parents a595f95 + f3ea09d commit 47ee901
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"tsutils": "^2.7.1",
"typedoc": "^0.7.1"
"typedoc": "^0.8.0"
},
"dependencies": {
"lodash": "^4.17.4",
Expand Down
7 changes: 6 additions & 1 deletion src/code-generators/typescript-generators/namedImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ export function generateNamedImport(
const space = spaceBraces ? ' ' : '';
const specifiers = imp.specifiers.sort(specifierSort).map(o => generateSymbolSpecifier(o)).join(', ');
const lib = imp.libraryName;

let importSpecifiers = `${space}${specifiers}${space}`;
if (importSpecifiers.trim().length === 0) {
importSpecifiers = ' ';
}

const importString = `import {${space}${specifiers}${space}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
const importString = `import {${importSpecifiers}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
if (importString.length > multiLineWrapThreshold) {
const spacings = Array(tabSize + 1).join(' ');
return multiLineImport(
Expand Down
1 change: 1 addition & 0 deletions test/code-generators/TypescriptCodeGenerator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('TypescriptCodeGenerator', () => {
new NamespaceImport('namespaceLib', 'namespaceAlias'),
namedImport,
multiLineNamedImport,
new NamedImport('emptyImport'),
];

for (const generatable of generatables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ exports[`TypescriptCodeGenerator should generate the correct code for NamedImpor
} from 'multiLineNamedLib';"
`;

exports[`TypescriptCodeGenerator should generate the correct code for NamedImport 3`] = `"import { } from 'emptyImport';"`;

exports[`TypescriptCodeGenerator should generate the correct code for NamespaceImport 1`] = `"import * as namespaceAlias from 'namespaceLib';"`;

exports[`TypescriptCodeGenerator should generate the correct code for ParameterDeclaration 1`] = `"param"`;
Expand Down

0 comments on commit 47ee901

Please sign in to comment.