Replace endsWith() check with isDefaultLibFile() in getRenameInfo()#1990
Conversation
There are a couple of issues with using the current endsWith() function to determine if we should allow a rename for default lib files: 1. XXXX-lib.d.ts would not allow renames even though it should as the preceding characters are not being verified for directory separators 2. There is the potential for false matches as there is currently no check to verify indexOf was successful (index >= 0)
|
Hi @jramsay, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
|
I do not think you have this information on the script side. we do not know if lib.d.ts is really a user file, or has been injected into the context by VS. the only one who has this information is VS, and in the genral case, the language service Host. ts.getBaseFileName(ts.normalizePath(fileName)) === getDefaultLibFileName(options); |
88fbdf2 to
93ca5ae
Compare
|
Thanks for the comments. |
|
👍 |
There was a problem hiding this comment.
you will need to use getCanonicalFileName here to ensure that case insensitive systems will not have a problem.
Replace endsWith() check with canonical normalized path comparison in getRenameInfo()
There are a couple of issues with using the current endsWith() function used to determine if we should allow a rename for default lib files: