Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
},
"homepage": "https://github.com/TypeScript-Heroes/node-typescript-parser#readme",
"devDependencies": {
"@types/jest": "^21.1.0",
"@types/jest": "^21.1.8",
"@types/mock-fs": "^3.6.30",
"@types/node": "^8.0.31",
"@types/node": "^8.0.57",
"del-cli": "^1.1.0",
"jest": "^21.2.0",
"mock-fs": "^4.4.1",
"jest": "^21.2.1",
"mock-fs": "^4.4.2",
"semantic-release": "^9.0.0",
"ts-jest": "^21.0.0",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"tsutils": "^2.9.0",
"typedoc": "^0.8.0"
"ts-jest": "^21.2.4",
"tslint": "^5.8.0",
"tslint-config-airbnb": "^5.4.2",
"tsutils": "^2.13.0",
"typedoc": "^0.9.0"
},
"dependencies": {
"lodash": "^4.17.4",
"tslib": "^1.7.1",
"typescript": "^2.5.3"
"tslib": "^1.8.1",
"typescript": "^2.6.2"
}
}
3 changes: 2 additions & 1 deletion src/code-generators/typescript-generators/namedImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function specifierSort(i1: SymbolSpecifier, i2: SymbolSpecifier): number {

if (strA < strB) {
return -1;
} else if (strA > strB) {
}
if (strA > strB) {
return 1;
}
return 0;
Expand Down
9 changes: 4 additions & 5 deletions src/resources/Module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Resource } from './Resource';

/**
* TypeScript resource. Declaration of a typescript module (i.e. declare module "foobar").
*
*
* @export
* @class Module
* @implements {Resource}
Expand Down Expand Up @@ -39,19 +39,18 @@ export class Module implements Resource, Node {
/**
* Function that calculates the alias name of a namespace.
* Removes all underlines and dashes and camelcases the name.
*
*
* @returns {string}
*
*
* @memberof Module
*/
public getNamespaceAlias(): string {
return this.name.split(/[-_]/).reduce(
(all, cur, idx) => {
if (idx === 0) {
return all + cur.toLowerCase();
} else {
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
}
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
},
'',
);
Expand Down
9 changes: 4 additions & 5 deletions src/resources/Namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Resource } from './Resource';

/**
* TypeScript resource. Declaration of a typescript namespace (i.e. declare foobar).
*
*
* @export
* @class Namespace
* @implements {Resource}
Expand Down Expand Up @@ -39,19 +39,18 @@ export class Namespace implements Resource, Node {
/**
* Function that calculates the alias name of a namespace.
* Removes all underlines and dashes and camelcases the name.
*
*
* @returns {string}
*
*
* @memberof Namespace
*/
public getNamespaceAlias(): string {
return this.name.split(/[-_]/).reduce(
(all, cur, idx) => {
if (idx === 0) {
return all + cur.toLowerCase();
} else {
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
}
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
},
'',
);
Expand Down
23 changes: 23 additions & 0 deletions test/SpecificUsageCases.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TypescriptParser } from '../src';
import { getWorkspaceFile, rootPath } from './testUtilities';

describe('Specific usage cases', () => {
const parser = new TypescriptParser();

describe('i18next with and without destructure', () => {

it('should contain i18next reference in not destructured way', async () => {
const file = getWorkspaceFile('specific-usage-cases/i18next-destructure/import-my-component.tsx');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.usages).toMatchSnapshot();
});

it('should contain t reference in destructured way', async () => {
const file = getWorkspaceFile('specific-usage-cases/i18next-destructure/destructure-my-component.tsx');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.usages).toMatchSnapshot();
});

});

});
17 changes: 17 additions & 0 deletions test/__snapshots__/SpecificUsageCases.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Specific usage cases i18next with and without destructure should contain i18next reference in not destructured way 1`] = `
Array [
"MyComponent",
"p",
"i18next",
]
`;

exports[`Specific usage cases i18next with and without destructure should contain t reference in destructured way 1`] = `
Array [
"MyComponent",
"p",
"t",
]
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as React from 'react';
import { t } from 'i18next';

export const MyComponent = () => (
<p>{t('foo')}</p>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as i18next from 'i18next';
import * as React from 'react';

export const MyComponent = () => <p>{i18next.t('foo')}</p>;