Skip to content

Commit

Permalink
Merge pull request #21 from TypeScript-Heroes/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
buehler authored Sep 18, 2017
2 parents 52974b6 + b61e1b5 commit 15c2b1d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@types/mock-fs": "^3.6.30",
"@types/node": "^8.0.13",
"del-cli": "^1.1.0",
"jest": "^20.0.4",
"jest": "^21.0.0",
"mock-fs": "^4.4.1",
"semantic-release": "^6.3.6",
"ts-jest": "^20.0.7",
"semantic-release": "^8.0.0",
"ts-jest": "^21.0.0",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"tsutils": "^2.7.1",
Expand Down
2 changes: 1 addition & 1 deletion src/DeclarationIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export class DeclarationIndex {
if (!index[declaration.name]) {
index[declaration.name] = [];
}
const from = key.replace(/[/]?index$/, '') || '/';
const from = key.replace(/\/index$/, '') || '/';
if (!index[declaration.name].some(
o => o.declaration.constructor === declaration.constructor && o.from === from,
)) {
Expand Down
1 change: 1 addition & 0 deletions test/_workspace/declaration-index/_index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export let _index;
1 change: 1 addition & 0 deletions test/_workspace/declaration-index/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export let barrelExport;
16 changes: 13 additions & 3 deletions test/declaration-index/DeclarationIndex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('DeclarationIndex', () => {
join(rootPath, 'helper-functions.ts'),
join(rootPath, 'myReactTemplate.tsx'),
join(rootPath, 'prototype-funcs.ts'),
join(rootPath, 'index.ts'),
join(rootPath, '_index.ts'),
];

beforeEach(async () => {
Expand Down Expand Up @@ -84,6 +86,14 @@ describe('DeclarationIndex', () => {
expect(resource).toMatchSnapshot();
});

it('should properly index non-barrel files ending in `index`', () => {
const barrelExport = declarationIndex.index!['barrelExport'];
expect(barrelExport).toMatchSnapshot();

const _index = declarationIndex.index!['_index'];
expect(_index).toMatchSnapshot();
});

});

describe('reindexForChanges()', () => {
Expand Down Expand Up @@ -183,7 +193,7 @@ describe('DeclarationIndex', () => {
export class FancierLibraryClass {
public doSomethingAwesome(): void { }
}
export * from './foobar'`,
});

Expand Down Expand Up @@ -265,7 +275,7 @@ describe('DeclarationIndex', () => {
export class FancierLibraryClass {
public doSomethingAwesome(): void { }
}
export * from './foobar'`,
});

Expand All @@ -290,7 +300,7 @@ describe('DeclarationIndex', () => {
export class FancierLibraryClass {
public doSomethingAwesome(): void { }
}
export * from './foobar'`,
});

Expand Down
34 changes: 34 additions & 0 deletions test/declaration-index/__snapshots__/DeclarationIndex.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Array [
"/helper-functions",
"/myReactTemplate",
"/prototype-funcs",
"/index",
"/_index",
]
`;

Expand Down Expand Up @@ -127,6 +129,38 @@ Array [
]
`;

exports[`DeclarationIndex buildIndex() should properly index non-barrel files ending in \`index\` 1`] = `
Array [
DeclarationInfo {
"declaration": VariableDeclaration {
"end": 24,
"isConst": false,
"isExported": true,
"name": "barrelExport",
"start": 0,
"type": undefined,
},
"from": "/",
},
]
`;

exports[`DeclarationIndex buildIndex() should properly index non-barrel files ending in \`index\` 2`] = `
Array [
DeclarationInfo {
"declaration": VariableDeclaration {
"end": 18,
"isConst": false,
"isExported": true,
"name": "_index",
"start": 0,
"type": undefined,
},
"from": "/_index",
},
]
`;

exports[`DeclarationIndex calculateIndexDelta() should calculate a newly added declaration 1`] = `
Object {
"added": Object {
Expand Down

0 comments on commit 15c2b1d

Please sign in to comment.