You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Renaming an import alias for a module coming from a .d.ts file, renames all instances. this is obviously wrong.
Options, 1. error (obviously not helpful), 2. only rename local symbol (better, but leaves the code in an invalid state), 3. rename local import and add as oldname clause to the import declaration as needed (looks like the best solution).
This is similar to the issue related to #7458, except that this issue adds renaming the import alias.
Approved. The fix here is just to block rename invocations in certain syntactic locations (we can start with this particular one and add more as we find them).
I believe the behavior I'm encountering is relevant to this bug. In a freshly initialized project, renaming things like Object and Number is prevented. Here is the tsconfig.json:
{"seq":0,"type":"response","command":"rename","request_seq":8914211752108017,"success":true,"body":{"info":{"canRename":false,"localizedErrorMessage":"You cannot rename elements that are defined in the standard TypeScript library."},"locs":[]}}
This is expected. However, as soon as you add a lib entry to the tsconfig.json, renaming Object is permitted. Here is the tsconfig.json:
This also occurs in things included via TypeScript's @types system. At the very least, I would expect that rename requests would be denied ("canRename": false) if changes would occur in files included via "lib", "@types/*", "typeRoots", or "types".
Perhaps this could be expanded to not rename things from node_modules (or at least give a warning) folder?
VSCode decided to rename everything that was of type string and I had to reinstall node_modules. It really shouldn't be reaching into the dependencies folder.
Activity
RyanCavanaugh commentedon Jun 9, 2016
Approved. The fix here is just to block rename invocations in certain syntactic locations (we can start with this particular one and add more as we find them).
mhegazy commentedon Jun 13, 2016
This also should cover all symbols declared in .d.ts files, as long as the operation is not initiated from this .d.ts file.
bryanforbes commentedon Jan 6, 2017
I believe the behavior I'm encountering is relevant to this bug. In a freshly initialized project, renaming things like
ObjectandNumberis prevented. Here is thetsconfig.json:The file I'm attempting the rename in:
The request for the rename of
Object:And the response:
This is expected. However, as soon as you add a
libentry to thetsconfig.json, renamingObjectis permitted. Here is thetsconfig.json:Using the same file as before, here is the request for the rename:
And the response:
This also occurs in things included via TypeScript's
@typessystem. At the very least, I would expect that rename requests would be denied ("canRename": false) if changes would occur in files included via"lib","@types/*","typeRoots", or"types".zpdDG4gta8XKpMCd commentedon Jan 6, 2017
related #11863
brandonkal commentedon Aug 23, 2019
Perhaps this could be expanded to not rename things from node_modules (or at least give a warning) folder?
VSCode decided to rename everything that was of type string and I had to reinstall node_modules. It really shouldn't be reaching into the dependencies folder.