Skip to content

Commit

Permalink
fix: Fixed runtime bug "TypeError: __kipper.index is not a function" …
Browse files Browse the repository at this point in the history
…in compile worker
  • Loading branch information
Luna-Klatzer committed Sep 17, 2024
1 parent 2b19523 commit 3202bdf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/js/playground/compile/__kipper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Define global '__kipper' on the window (d.ts file)
export {};

declare global {
var __kipper: { [key: string]: any };

Check warning on line 5 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'__kipper' is defined but never used

Check warning on line 5 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'__kipper' is defined but never used

Check warning on line 5 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'__kipper' is defined but never used

interface Window {

Check warning on line 7 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used

Check warning on line 7 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used

Check warning on line 7 in src/js/playground/compile/__kipper.d.ts

View workflow job for this annotation

GitHub Actions / build (20.10.0)

'Window' is defined but never used
__kipper: { [key: string]: any };
}
}
4 changes: 4 additions & 0 deletions src/js/playground/compile/compile-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ let compiler: never | any;
* @param code The translated code to evaluate. (Must be in JavaScript)
*/
async function evalKipperCode(code: string) {
// Clean up any global scope entries
// eslint-disable-next-line no-undef
window.__kipper = __kipper = undefined;

// Overwrite 'console.log'
const prevLog = console.log;
console.log = (msg: string) => {
Expand Down

0 comments on commit 3202bdf

Please sign in to comment.