Skip to content

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

Description

@Hookyns

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>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions