-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
WIP: YASNCB (Yet Another Strict Null Checks Branch) #1703
base: dev
Are you sure you want to change the base?
Conversation
This is an odd one. The types were very different for useRowCol = true and useRowCol = false and so I needed to use generics to clean it up.
@@ -185,7 +185,7 @@ export class LineInputModel implements EditableModel { | |||
} | |||
return [a, b]; | |||
}) | |||
.filter((x) => x !== null) | |||
.filter((x) => x !== null) as [number, number][] |
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.
Same same.
@@ -224,7 +224,7 @@ export class LineInputModel implements EditableModel { | |||
const seen = new Set<number>(); | |||
this.dirtyLines.sort(); | |||
while (this.dirtyLines.length) { | |||
let nextIdx = this.dirtyLines.shift(); | |||
let nextIdx = this.dirtyLines.shift() as number; |
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.
Again, TypeScript isn't smart enough to figure out that the length check on the previous line means this will never be undefined and will always be a number.
cursorStartField: StartFieldKey, | ||
cursorEndField: EndFieldKey | ||
): [LispTokenCursor[StartFieldKey], LispTokenCursor[EndFieldKey]][] => { | ||
const ranges: [LispTokenCursor[StartFieldKey], LispTokenCursor[EndFieldKey]][] = []; |
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.
The explanation for this function is that we needed a generic version of _rangesForSexpsInList
that didn't need really long types and weird type contortions in order to use it.
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's probably an improvement. But with my limited command over the typing system, right now this turned from ”this is messy” to ”I don't understand what I'm reading at all”. Not sure what to do about that...
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 might also be that I am having a hard time trying to puzzle together the code in my head from the diffs.
if (step) { | ||
step.undo(c); | ||
this.redos.push(step); | ||
} |
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.
More TypeScript silliness. The length check means pop will always work but TypeScript can't figure that out.
|
||
const options = {}; | ||
|
||
if (pick !== undefined) { | ||
options['evaluationSendCodeToOutputWindow'] = | ||
snippetsDict[pick].evaluationSendCodeToOutputWindow; | ||
options['evaluationSendCodeToOutputWindow'] = replSnippet?.evaluationSendCodeToOutputWindow; |
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.
strange note: evaluationSendCodeToOutputWindow
was missing from customREPLCommandSnippet
and I had to add it.
src/debugger/calva-debug.ts
Outdated
@@ -271,6 +271,7 @@ class CalvaDebugSession extends LoggingDebugSession { | |||
// Pass scheme in path argument to Source contructor so that if it's a jar file it's handled correctly | |||
const source = new Source(basename(debugResponse.file), debugResponse.file); | |||
const name = tokenCursor.getFunctionName(); | |||
util.assertIsDefined(name, 'Expected to find a function name!'); |
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.
StackFrame doesn't allow for an undefined name.
@@ -169,18 +169,21 @@ export class MirroredDocument implements EditableDocument { | |||
} | |||
|
|||
public delete(): Thenable<boolean> { | |||
return vscode.commands.executeCommand('deleteRight'); | |||
return vscode.commands.executeCommand('deleteRight').then((v) => !!v); |
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.
The actual return type here was Thenable<true | undefined>
and so this fixes the type so it's Thenable<boolean>
again.
@@ -381,6 +382,7 @@ export class NReplSession { | |||
if (evaluation.onMessage(msg, pprintOptions)) { | |||
return true; | |||
} | |||
return false; |
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 unsure of this behavior but we must return a boolean from this function and it clearly shouldn't return true.
} | ||
} | ||
|
||
export { isNonEmptyString, isNullOrUndefined, isDefined, assertIsDefined }; |
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 needed to split this out into its own file so it could be imported in files where vscode isn't available. Importing utilities was breaking unit tests because of this.
I found this in the noise where the integration test broke:
Before that I also find:
Which I am not sure if we usually see or not, but if not maybe it could be the cause of the timeout. Anyway, those I would see if I could run these tests locally. If you haven't before, it's surprisingly easy:
|
I ran it locally and profiled the code to find where it's stuck. I just need to figure out why it's stuck. I have the last known working commit sha for integration tests but it's not clear why it's broken by the following commit |
Which commits does the bisect give you? Maybe we can see what could be the cause with more eyes on it. |
Is it here? If so, that is still a bit opaque to me. 😄 I don't know what the implications are for enabling strict null checks. |
if (menuSelections && menuSelections.cljsDefaultBuild && useDefaultBuild) { | ||
build = menuSelections.cljsDefaultBuild; | ||
useDefaultBuild = false; | ||
} else { | ||
if (typeof initCode === 'object' || initCode.includes('%BUILD%')) { | ||
const buildsForSelection = startedBuilds |
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 stopped and wondered if we somehow consider the current selection here. Maybe name it builds
? Or buildCandidates
?.
const previous = cursor.clone().previous(); | ||
assertIsDefined(previous, 'Expected a token to be before the cursor!'); | ||
const offset = previous.offsetStart; |
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 sure I am reading this correctly. But generally in Paredit and token cursor code we need to gracefully handle when the structure does not match some expectation. We most often leave things unchanged in those cases. Does this change mean that we croak? I realize that that would be happening before the change as well, I'm more wondering about what we should be doing here...
What has Changed?
This turns on
strictNullChecks
in TypeScript and fixes all the remaining issues in the codebase that were preventing us from turning this setting on.My Calva PR Checklist
I have:
dev
branch. (Or have specific reasons to target some other branch.)published
. (Sorry for the nagging.)[Unreleased]
entry inCHANGELOG.md
, linking the issue(s) that the PR is addressing.ci/circleci: build
test.npm run prettier-format
)npm run eslint
before creating your PR, or runnpm run eslint-watch
to eslint as you go).Ping @PEZ, @bpringe, @corasaurus-hex, @Cyrik