-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDesign LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallycheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript
Milestone
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:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDesign LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixedDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallycheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript