Skip to content
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

refactor(jsonc): prepare for noUncheckedIndexedAccess #4149

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jsonc/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class JSONCParser {
*#tokenize(): Generator<Token, void> {
for (let i = 0; i < this.#length; i++) {
// skip whitespace
if (this.#whitespace.has(this.#text[i])) {
if (this.#whitespace.has(this.#text[i]!)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: i is a number between 0 and this.#length. this.#length equals this.#text.length, as seen in the constructor. Therefore, this.#text[i] is always defined, and the non-null assertion is justified.

Ditto for the other change.

continue;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ class JSONCParser {
default: { // parse null, true, false or number token
const startIndex = i;
for (; i < this.#length; i++) { // read until find numberEndToken
if (this.#numberEndToken.has(this.#text[i])) {
if (this.#numberEndToken.has(this.#text[i]!)) {
break;
}
}
Expand Down