-
Notifications
You must be signed in to change notification settings - Fork 138
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
Fix remaining typescript issues #712
Conversation
Pull Request Test Coverage Report for Build 9546551429Details
💛 - Coveralls |
Managed to fix all the remaining typescript errors, even the PS: I have updated the tests, so everything passes, although I'm not too familiar with them, please check, if I did that correctly. Also I could open a separate PR for the breaking change if you want, however then one typescript issue will remain unfixed after merging this PR. |
Pull Request Test Coverage Report for Build 9565191609Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
lib/ical/timezone_service.js
Outdated
*/ | ||
register: function(name, timezone) { | ||
register: function(namedTimezoneOrComponent) { |
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.
I'm not a big fan of objects for arguments unless it is very many, as in many cases consumers need to create an object solely for the purpose of passing arguments and then it is destroyed again.
I think we should make it as follows:
- First argument is
Component|Timezone
and required. - Second argument is String (name) and optional
- If no name is specified, then name is assumed to be timezone.tzid, regardless of if a timezone is passed or a component that is turned into a timezone.
- Runtime error thrown if neither timezone.tzid is set nor name is passed.
- To avoid a breaking change over argument order, a runtime check to see if arg1 is string and arg2 is Timezone, then just swap them correctly. Add a note to the v3 issue to remove the hack when we are ready for v3. Technically it already breaks typescript consumers, but we didn't have types a few weeks ago and the type checks would catch it.
I tried the newest types. My code so far used I guess the parameter of In While the types enforce that Component.getFirstPropertyValue() returns string, in my existing code I assume that getFirstPropertyValue('dtend' / 'duration' / 'rrule' ) return Time / Duration / Recur object. Please check, if the return type can indeed be non-string? Isn’t |
Hi. I just updated the register function with your suggestion. Should I add a test for the new runtime error aswell? |
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.
Fixing the build warning and these two minor comments and we're good, thank you!
Tests are always well received and maintain coverage, so this would be great! |
Co-authored-by: Philipp Kewisch <[email protected]>
Co-authored-by: Philipp Kewisch <[email protected]>
Actually I think this test case already covers it, so I didn't add another one: test('with only invalid component', function() {
assert.throws(function() {
let comp = new ICAL.Component('vtoaster');
subject.register(comp);
}, "neither a timezone nor a name was passed");
}); Accepted your changes and fixed the warning with an unused import, so now we should be good |
Pull Request Test Coverage Report for Build 9711732846Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Thank you so much, I've merged the changes and will make a note in the v3 issue. |
Hi,
according to #707 there are some remaining issues with the generated typescript types. This PR aims to fix everything except those regarding
ICAL.design.designSet
since that is currently broken. Some commits need an explanation:@readonly
tags because it causes this error in typescript:readonly' modifier can only appear on a property declaration or index signature.
. When the getters get converted to typescript, typescript changes@readonly
to the typescript keywordreadonly
which is only allowed in index signatures or properties. However you use the@readonly
tag on getter functions which is not valid in typescript. I couldn't find a way to omit specific valid jsdoc comments from being parsed by typescript (@ts-ignore
doesnt work and@ignore
removed the function from the docs).A required parameter cannot follow an optional parameter.
. Also I took a look at the code and believe thatoptions
itself and their properties should be optional anyways sinceoptions.strictExceptions
is set in the property declaration to false andoptions.exceptions
states that "If not specified exceptions will automatically be set in relation of compoent's parent"