Closed
Description
Starting with TS 4.1 and also in TS 4.2, it seems that required code is frozen and cannot be reassigned.
We had some code that would require a JSON and conditionally overwrite it, however that code is no longer valid. See example below for a minimal reproduction.
I couldn't find anything in the release notes or breaking changes.
TypeScript Version: 4.1.2
Search Terms:
require json cannot assign let
Code
let a = require('./package.json');
a = {...a};
Expected behavior:
No warnings should be raised for this code. Alternatively at the least I would expect another warning about defining a
with let
.
Actual behavior:
Cannot to 'a' because it is not a variable.
Related Issues: