Skip to content

Commit 8e3537d

Browse files
author
Sean Newell
committed
Added filter for .d.ts Closes #23
1 parent 511e90d commit 8e3537d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/services/models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function getSequelizeTypeByDesignType(target: any, propertyName: string):
153153
return dataType;
154154
}
155155

156-
throw new Error(`Specified type of property '${propertyName}'
156+
throw new Error(`Specified type of property '${propertyName}'
157157
cannot be automatically resolved to a sequelize data type. Please
158158
define the data type manually`);
159159
}
@@ -171,7 +171,7 @@ export function getModels(arg: Array<typeof Model|string>): Array<typeof Model>
171171
.readdirSync(dir as string)
172172
.filter(file => {
173173
const extension = file.slice(-3);
174-
return extension === '.js' || extension === '.ts';
174+
return extension === '.js' || (extension === '.ts' && file.slice(-4) !== '.d.ts');
175175
})
176176
.map(file => path.parse(file).name)
177177
.filter(uniqueFilter)

test/specs/models/sequelize.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ describe('sequelize', () => {
5858

5959
});
6060

61+
describe('definition files', () => {
62+
it('should not load in definition files', () => {
63+
sequelize.addModels([__dirname + '/../../models/exports/']);
64+
65+
expect(() => Game.build({})).not.to.throw;
66+
67+
expect(Object.keys(sequelize.models).length).to.equal(2);
68+
});
69+
});
70+
6171
});
6272

6373
describe('model', () => {

0 commit comments

Comments
 (0)