-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
polish raven.d.ts #827
polish raven.d.ts #827
Conversation
- added missing public functions from raven.js - moved complex data types into helper interfaces - corrected wrong definitions - reordered things a bit
cc @connor4312 – mind chiming in on this? |
* | ||
* @param user The definition of the currently active user's unique identity | ||
*/ | ||
setUserContext(user: RavenUserContext): RavenStatic; |
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.
You can remove the overload and just have user?: RavenUserContext
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.
But if the overload is removed, the difference in the documentation is lost.
As the function behaves (a bit) differently, if you pass it nothing or a RavenUserContext
, I wanted to also reflect that in the inline-/tooltip -documentation
typescript/raven.d.ts
Outdated
* Specify a callback function that determines if the given message should be sent to Sentry. | ||
* @param callback The function which determines if the given blob should be sent | ||
*/ | ||
setShouldSendCallback(callback: (data: any, orig?: string) => boolean): RavenStatic; |
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.
That's a lot of any
s! Can we get some more specific typings on them?
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.
It sure is...
I will look into it again if it is (reasonably) possible to be more specific about the data passed to these various callbacks
Looks mostly fine as far as the typings themselves go, I've not verified that all data types are correct against the Js implementation. |
Okay, CI isn't running
So, this is the problem I have every time I try to touch our module definition: I cannot come up with a consistent export that works wherever. Can someone here help me? Am I invoking |
Also, why rename to |
If I remember it correctly, a
|
@LucaVazz – again, really appreciate your continued effort on this. I've re-enabled the |
…in before-previous commit)
I took me a little longer then I expected to get around to doing this... Now tsc works without errors and I made |
# Conflicts: # typescript/raven.d.ts
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.
See comments: really just questions.
typescript/raven-tests.ts
Outdated
Raven.setEnvironment('production'); | ||
|
||
Raven.setDataCallback(function (data: any) {}); | ||
Raven.setDataCallback(function (data: any, original: any) {}); |
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.
Why remove these from tests?
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.
That was not intentional.
As to why it did happen... Good question.
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.
fixed in 1f55f01
typescript/raven.d.ts
Outdated
|
||
|
||
// --- Helper Interfaces for Options -------------- | ||
export interface RavenBreadcrumOptions { |
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.
Typo: Breadcrum
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.
fixed in 3e51fc6
colno: string; | ||
function:string; | ||
in_app: boolean; | ||
} |
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.
At 387 lines, this definition file is almost as complicated as Raven.js itself. Is it normal for libraries to expose something so rigid? I'm terrified this file will become really painful to maintain.
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.
Well, I agree with what @connor4312 previously said: More specific type definitions are always better.
Unfortunately I don't see a way to compress the type definitions for Raven more...
One way to ensure a bit easier maintainability would be to switch the main Raven-JS to TypeScript. It wouldn't be a change that drastically, especially considering that TypeScript transpiles down to vanilla JS in the end.
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.
One way to ensure a bit easier maintainability would be to switch the main Raven-JS to TypeScript. It wouldn't be a change that drastically, especially considering that TypeScript transpiles down to vanilla JS in the end.
This will not happen :)
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.
okay then ;)
But still, I don't think that it would be that hard to maintain this file onwards. In my opinion it is "just" another documentation of the Raven Module, like a more specific version of JSDoc which you already use.
Maybe @connor4312 has some additional opinion...?
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.
Yea, so. I would mention that although the length may be comparable to raven.js itself, the complexity is significantly lower; it's static definitions, not procedural code.
That said, it is a maintenance burden, and it's definitely your prerogative whether that's something you want to take up. Someone will have to take it up, if nothing else maintaining definitions in DefinitelyTyped. It could be reduced by making pull request templates and having an issue checkmark for "[x] I updated typings/raven.d.ts if I added to or changed the API". I'd be happy to assist with reviews for those if you'd like.
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 think that is a really good idea @connor4312!
I have added a Proposal for a PR-Template which includes that. What do you think of it @benvinegar?
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.
If we're to add such a template, I'd rather it not be part of this PR.
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 see, then I will try that in a separate Request.
typescript/raven.d.ts
Outdated
|
||
export interface RavenBreadcrumb { | ||
message: string; | ||
data: { [id: string]: string }; |
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.
Will this allow for free-form objects?
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.
Regarding the RavenUserContext
or RavenBreadcrumb
?
@@ -0,0 +1,23 @@ | |||
{ | |||
"compilerOptions": { | |||
"module": "commonjs", |
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.
What can we do to guarantee that users, no matter what environment, will be able to import this project fine? Do we have to document, "please see our tsconfig settings"?
Would you expect the export/module TypeScript definition change to result in a new major rev (4.x.x)?
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.
No, this tsconfig settings only define the structure and compilerOptions for this module. Users should be able to import the module fine as long as our type definitions are correct, regardless if their project's tsconfig settings match these or not.
In my opinion this is still a non-breaking change, as long as users used the interface correctly. I didn't change anything major at the tests (as I said, the Deletion was unintentional) and they still pass.
Okay, so the blocker for me right now has little to do with this PR (sort of). It's that if you try to do this in a SystemJS project:
SystemJS will look for That's why, up until now, we've advocated doing:
Which does not look for a |
.github/PULL_REQUEST_TEMPLATE.md
Outdated
***Release Type:*** | ||
- [ ] Major | ||
- [ ] Minor | ||
- [X] Patch |
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.
👍
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.
Please remove this.
.github/PULL_REQUEST_TEMPLATE.md
Outdated
***Checklist:*** | ||
- [ ] I have included appropriate Tests and have run `npm test` without errors | ||
- [ ] I have updated the Documentation accordingly | ||
- [ ] I updated typings/raven.d.ts if I added to or changed the API and have run `tsc --noEmit --noImplicitAny typescript/raven-tests.ts` without errors |
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.
We can probably make this a script like npm run test:ts
, or make it called by npm test
directly
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 just noticed that in fact it already is called directly by npm test
😁
Regarding SystemJS: On the one hand I don't see a reason why the way you outlined wouldn't work anymore. |
the last two commits integrated changes suggested by @evilj0e in DefinitelyTyped/DefinitelyTyped#14674 |
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.
Please remove PULL_REQUEST_TEMPLATE
(see other comment) and I'll go ahead and merge.
colno: string; | ||
function:string; | ||
in_app: boolean; | ||
} |
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.
If we're to add such a template, I'd rather it not be part of this PR.
Haven't forgotten about this. I'll merge it for the next minor release (3.13.0). |
This reverts commit 4e12341.
as discussed in #820
Please double-check that everything has the correct data types, according to the JS-Side.