Skip to content

Commit 15c2b1d

Browse files
authored
Merge pull request #21 from TypeScript-Heroes/develop
2 parents 52974b6 + b61e1b5 commit 15c2b1d

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"@types/mock-fs": "^3.6.30",
3636
"@types/node": "^8.0.13",
3737
"del-cli": "^1.1.0",
38-
"jest": "^20.0.4",
38+
"jest": "^21.0.0",
3939
"mock-fs": "^4.4.1",
40-
"semantic-release": "^6.3.6",
41-
"ts-jest": "^20.0.7",
40+
"semantic-release": "^8.0.0",
41+
"ts-jest": "^21.0.0",
4242
"tslint": "^5.5.0",
4343
"tslint-config-airbnb": "^5.2.1",
4444
"tsutils": "^2.7.1",

src/DeclarationIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export class DeclarationIndex {
383383
if (!index[declaration.name]) {
384384
index[declaration.name] = [];
385385
}
386-
const from = key.replace(/[/]?index$/, '') || '/';
386+
const from = key.replace(/\/index$/, '') || '/';
387387
if (!index[declaration.name].some(
388388
o => o.declaration.constructor === declaration.constructor && o.from === from,
389389
)) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export let _index;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export let barrelExport;

test/declaration-index/DeclarationIndex.spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ describe('DeclarationIndex', () => {
4040
join(rootPath, 'helper-functions.ts'),
4141
join(rootPath, 'myReactTemplate.tsx'),
4242
join(rootPath, 'prototype-funcs.ts'),
43+
join(rootPath, 'index.ts'),
44+
join(rootPath, '_index.ts'),
4345
];
4446

4547
beforeEach(async () => {
@@ -84,6 +86,14 @@ describe('DeclarationIndex', () => {
8486
expect(resource).toMatchSnapshot();
8587
});
8688

89+
it('should properly index non-barrel files ending in `index`', () => {
90+
const barrelExport = declarationIndex.index!['barrelExport'];
91+
expect(barrelExport).toMatchSnapshot();
92+
93+
const _index = declarationIndex.index!['_index'];
94+
expect(_index).toMatchSnapshot();
95+
});
96+
8797
});
8898

8999
describe('reindexForChanges()', () => {
@@ -183,7 +193,7 @@ describe('DeclarationIndex', () => {
183193
export class FancierLibraryClass {
184194
public doSomethingAwesome(): void { }
185195
}
186-
196+
187197
export * from './foobar'`,
188198
});
189199

@@ -265,7 +275,7 @@ describe('DeclarationIndex', () => {
265275
export class FancierLibraryClass {
266276
public doSomethingAwesome(): void { }
267277
}
268-
278+
269279
export * from './foobar'`,
270280
});
271281

@@ -290,7 +300,7 @@ describe('DeclarationIndex', () => {
290300
export class FancierLibraryClass {
291301
public doSomethingAwesome(): void { }
292302
}
293-
303+
294304
export * from './foobar'`,
295305
});
296306

test/declaration-index/__snapshots__/DeclarationIndex.spec.ts.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Array [
6666
"/helper-functions",
6767
"/myReactTemplate",
6868
"/prototype-funcs",
69+
"/index",
70+
"/_index",
6971
]
7072
`;
7173

@@ -127,6 +129,38 @@ Array [
127129
]
128130
`;
129131

132+
exports[`DeclarationIndex buildIndex() should properly index non-barrel files ending in \`index\` 1`] = `
133+
Array [
134+
DeclarationInfo {
135+
"declaration": VariableDeclaration {
136+
"end": 24,
137+
"isConst": false,
138+
"isExported": true,
139+
"name": "barrelExport",
140+
"start": 0,
141+
"type": undefined,
142+
},
143+
"from": "/",
144+
},
145+
]
146+
`;
147+
148+
exports[`DeclarationIndex buildIndex() should properly index non-barrel files ending in \`index\` 2`] = `
149+
Array [
150+
DeclarationInfo {
151+
"declaration": VariableDeclaration {
152+
"end": 18,
153+
"isConst": false,
154+
"isExported": true,
155+
"name": "_index",
156+
"start": 0,
157+
"type": undefined,
158+
},
159+
"from": "/_index",
160+
},
161+
]
162+
`;
163+
130164
exports[`DeclarationIndex calculateIndexDelta() should calculate a newly added declaration 1`] = `
131165
Object {
132166
"added": Object {

0 commit comments

Comments
 (0)