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

[BUG] Uncaught ReferenceError: _ßr is not defined #81

Open
Hookyns opened this issue Nov 8, 2022 · 4 comments
Open

[BUG] Uncaught ReferenceError: _ßr is not defined #81

Hookyns opened this issue Nov 8, 2022 · 4 comments
Labels
bug Something isn't working Fixed@alpha

Comments

@Hookyns
Copy link
Owner

Hookyns commented Nov 8, 2022

This is a known bug

You can find this issue in projects with incremental build and/or HMR.
This is fixed in the new major version (not released yet).

Fix

You can hotfix this issue by adding this code somewhere to your project, it has to be executed as soon as possible.

import { getType, Type } from "tst-reflect";
(window as any)["_" + String.fromCharCode(223) + "r"] = { getType, Type };

Example

Lets have create-react-app project. You have to create new file eg. polyfills.ts

import { getType, Type } from "tst-reflect";
(window as any)["_" + String.fromCharCode(223) + "r"] = { getType, Type };

and import this file first in the index.ts.

import "./polyfills";
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
@Hookyns Hookyns added bug Something isn't working enhancement New feature or request labels Nov 8, 2022
@Hookyns Hookyns pinned this issue Nov 8, 2022
@Hookyns Hookyns removed the enhancement New feature or request label Nov 21, 2022
@paluchi
Copy link

paluchi commented Jan 28, 2023

@Hookyns How can I apply this fix to a node server?

@Hookyns
Copy link
Owner Author

Hookyns commented Jan 28, 2023

Hi, you can participate in Alpha version (it's fixed there) or you have to declare that variable in "index" file on your own as shown above.

Do you have some specific issue with it?

@paluchi
Copy link

paluchi commented Jan 28, 2023

Hi, you can participate in Alpha version (it's fixed there) or you have to declare that variable in "index" file on your own as shown above.

Do you have some specific issue with it?

It's the same issue you already described. Could you please provide me a link to the alpha subs.? window object does not exist for node servers as it is not running on a web provider

EDIT (Hookyns): idk how, but I edited this instead of reply; reverted

@Hookyns
Copy link
Owner Author

Hookyns commented Feb 2, 2023

@paluchi
Ahh, okay. You just have to replace window by global or globalThis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed@alpha
Projects
None yet
Development

No branches or pull requests

2 participants