Skip to content

Commit

Permalink
fix: Fix TypeScript errors when compiling with `noUncheckedIndexedAcc…
Browse files Browse the repository at this point in the history
…ess` (#297)

Co-authored-by: aikoven <dan.lytkin@gmail.com>
  • Loading branch information
aikoven and aikoven authored Jun 13, 2021
1 parent 86751fc commit f865e43
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions integration/bytes-as-base64/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/bytes-node/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/oneof-properties/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/oneof-unions/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long-string/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-optionals/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-snake/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions integration/simple/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,8 @@ const btoa: (bin: string) => string =
globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ function makeByteUtils() {
const btoa : (bin: string) => string = ${globalThis}.btoa || ((bin) => ${globalThis}.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr: Uint8Array): string {
const bin: string[] = [];
for (let i = 0; i < arr.byteLength; ++i) {
bin.push(String.fromCharCode(arr[i]));
for (const byte of arr) {
bin.push(String.fromCharCode(byte));
}
return btoa(bin.join(''));
}
Expand Down

0 comments on commit f865e43

Please sign in to comment.