Skip to content

Commit a6562e9

Browse files
2 parents db8c071 + b3e43e0 commit a6562e9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/services/models.ts

Lines changed: 3 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
}
@@ -170,8 +170,9 @@ export function getModels(arg: Array<typeof Model|string>): Array<typeof Model>
170170
const _models = fs
171171
.readdirSync(dir as string)
172172
.filter(file => {
173+
// TODO extension is not necessarily only the lasst three characters
173174
const extension = file.slice(-3);
174-
return extension === '.js' || extension === '.ts';
175+
return extension === '.js' || (extension === '.ts' && file.slice(-5) !== '.d.ts');
175176
})
176177
.map(file => path.parse(file).name)
177178
.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)