-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/73 default json mapper response #201
Feature/73 default json mapper response #201
Conversation
Codecov Report
@@ Coverage Diff @@
## master #201 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 55 56 +1
Lines 1087 1098 +11
Branches 154 134 -20
=========================================
+ Hits 1087 1098 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maryiabydanova
Thank you for the contribution, That's great!
I added some comments with proposals to update typings. These will enable TypeScript features:
interface IPerson {
name: string
}
const nobody:IPerson = {name:'nobody'};
const personMapper = jsonMapper.default(nobody);
const person = personMapper<IPerson>('incorrect'); // person is always IPerson
// person.name === 'nobody'
const person2 = personMapper<IPerson>('{name:"Pablo"}'); // person2 is always IPerson
// person.name === 'Pablo'
Or with type discrimination:
interface IPerson {
name:string
}
const invalidJson = new Error('The parsed json was invalid.');
const personMapper = jsonMapper.default<typeof invalidJson>(invalidJson);
const person = personMapper<IPerson>('incorrect');
if(person instanceof Error){
throw person;
}
doSomethingWithPerson(person);
Would you mind running two commands in packages/xlsx-import
?
npm run lint:fix
npm run format
They care about formatting.
Kudos, SonarCloud Quality Gate passed!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @maryiabydanova, it works great! I'm going to publish this release up to 20th Dec. |
Resolves #73