-
Notifications
You must be signed in to change notification settings - Fork 128
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
Refactoring: Strict TypeScript Fix #1208 #1209
Conversation
I'm quite familiar with the help and plot viewer related code, so I could do those files. Should I just push the corresponding changes directly to this branch? |
Yes, go for it. I am done for today and will continue tomorrow. I have just finished all code files in the src/ root but |
For reference: There was/is a pretty large number of unchecked null-ish values. (for example when the R-path is not set) I try to return early or abort gracefully where possible but this PR will need extensive testing of all vscode-r functionality after it is finished. On the plus side this will hopefully fix a lot of hard to track down bugs presently and in the future. |
We should probably refactor all occurrences of
to
|
It's done! We should definitely test this well before merge, but I will open the PR for review now. |
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
From https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration, it seems Take vscode-python for example, none of the calls to Do you think if it makes sense to follow the pattern that we don't specify the default value if the entry is defined by the extension so that it should automatically follow the definition in |
Interesting, it seems like they opted to do comparisons to avoid
I was under the impression adding a default value to the call just adds another fallback after there was no default found on any other level. I.e.: |
It feels quite redundant and burdensome to maintain the default values of each setting not only at where it is defined in
Thought about this case too. And specifying a default when there is a typo seems to hide the problem rather than make it easier to spot. |
So what is your opinion on how to proceed? We could also opt for a helper function that either ignores the undefined or checks and errors: function config_get<T>(section: string): T {
return config().get<T>(section) as T;
}
function config_get<T>(section: string): T {
const x = config().get<T>(section);
if (x === undefined) {
throw 'No config entry for ' + section;
return undefined as T; // a bit scary
}
return x;
} Edit: Only using default values when needed is also fine by me, I am just wondering what the most developer friendy way ist. |
Me too. Please feel free to use whatever you think makes good sense or common practice. |
Yes it's probably the best to leave this for now revisit it if it actually presents itself as a problem. From my side we are good to go with this PR. |
Thanks! |
What problem did you solve?
WIP PR to refactor the entire TypeScript codebase to use stricter type checks. See #1208
We should work bottom-up and fix files with many dependents earlier as null-checks may propagate.
TODO
Rough checklist to track progress: