Skip to content

Commit 4073ab4

Browse files
authored
Improve model create function types (#150)
* Remove Partial<> usage from model create functions * Properly reflect create function input & return types * Remove optional input support from create functions * Fix type inference for abstract model classes * Fully support typescript strict mode * Update dependencies * Reduce npm package contents
1 parent c864be9 commit 4073ab4

File tree

33 files changed

+3379
-2327
lines changed

33 files changed

+3379
-2327
lines changed

.eslintignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
tests/data/*
2-
*.d.ts
1+
*.cjs
2+
*.d.ts
3+
*.js
4+
*.mjs
5+
/tests/data

.eslintrc.cjs

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
const path = require("path");
22

33
module.exports = {
4-
root: true,
5-
env: {
6-
'node': true,
7-
},
8-
parser: '@typescript-eslint/parser',
9-
plugins: [
10-
'@typescript-eslint',
11-
'import',
12-
'jsdoc'
13-
],
14-
parserOptions: {
15-
project: path.resolve("./tsconfig.json"),
16-
},
17-
extends: [
18-
'eslint:recommended',
19-
'plugin:@typescript-eslint/eslint-recommended',
20-
'plugin:@typescript-eslint/recommended',
21-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
22-
],
23-
rules: {
4+
root: true,
5+
env: {
6+
'node': true,
7+
},
8+
parser: '@typescript-eslint/parser',
9+
plugins: [
10+
'@typescript-eslint',
11+
'import',
12+
'jsdoc'
13+
],
14+
parserOptions: {
15+
project: path.resolve("./tsconfig.json"),
16+
},
17+
extends: [
18+
'eslint:recommended',
19+
'plugin:@typescript-eslint/eslint-recommended',
20+
'plugin:@typescript-eslint/recommended',
21+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
22+
'plugin:mocha/recommended',
23+
],
24+
rules: {
2425
'semi': 'off',
2526
'no-shadow': 'off',
2627
'quotes': ['warn', 'single'],
@@ -61,6 +62,8 @@ module.exports = {
6162
}
6263
],
6364
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
64-
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true, allowBoolean: true }]
65+
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true, allowBoolean: true }],
66+
'@typescript-eslint/no-non-null-assertion': 'off',
67+
'mocha/no-setup-in-describe': 'off',
6568
}
6669
};

.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
node_modules
2-
dist
3-
.eslintcache
41
*.tgz
5-
.ignored
2+
/.eslintcache
3+
/dist
4+
/node_modules
5+
/tests_out

.npmignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
.tsbuildinfo
1+
/.eslint*
2+
/.github*
3+
/.husky
4+
/.vscode*
5+
/tests
6+
/tests_out
7+
/tsconfig*

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [3.0.0](https://github.com/Netatwork-de/odata-edm-generator/compare/v2.0.1...v3.0.0) (2025-01-23)
6+
7+
8+
### Bug Fixes
9+
10+
* Fix create fn behavior ([8c66b9a](https://github.com/Netatwork-de/odata-edm-generator/commit/8c66b9a0ac3f01c2175c94e87880d22e19cef46a))
11+
* properly reflect create input & return types ([4cc637d](https://github.com/Netatwork-de/odata-edm-generator/commit/4cc637de1d285d31a0310e0d025225e24d688860))
12+
513
### [2.0.2](https://github.com/Netatwork-de/odata-edm-generator/compare/v2.0.1...v2.0.2) (2024-08-28)
614

715
### [2.0.1](https://github.com/Netatwork-de/odata-edm-generator/compare/v2.0.0...v2.0.1) (2024-07-31)

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ import {
339339
odataEndpoint,
340340
odataType,
341341
odataTypeKey,
342+
createModel,
342343
} from '@netatwork/odata-edm-generator';
343344
import {
344345
Endpoints,
@@ -372,7 +373,7 @@ export class Bazz {
372373
return new this(
373374
raw.Id,
374375
raw.BazzProp2,
375-
Bar.create(raw.Bar),
376+
createModel(Bar, raw),
376377
raw.BarId,
377378
raw.BazzProp1,
378379
raw.Cp,
@@ -449,7 +450,7 @@ export class ChildOne extends Base {
449450
raw.BaseProp11,
450451
raw.BaseProp14,
451452
raw.ChildProp11,
452-
StandardCondition.create(raw.Condition),
453+
createModel(StandardCondition, raw),
453454
);
454455
}
455456

@@ -526,7 +527,7 @@ export class GrandChild extends ChildOne {
526527
raw.BaseProp11,
527528
raw.BaseProp14,
528529
raw.ChildProp11,
529-
StandardCondition.create(raw.Condition),
530+
createModel(StandardCondition, raw),
530531
raw.GrandChildProp11,
531532
);
532533
}
@@ -789,7 +790,7 @@ export class FizzCondition extends StandardCondition {
789790
super.initialize(raw);
790791
this.FC1P1 = raw.FC1P1;
791792
this.FC1P2 = raw.FC1P2;
792-
this.FC1P3 = BaseConfiguration.create(raw.FC1P3);
793+
this.FC1P3 = createModel(BaseConfiguration, raw);
793794
}
794795
}
795796

0 commit comments

Comments
 (0)