diff --git a/src/services/services.ts b/src/services/services.ts index 73d6b555c30..b4d53984307 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5540,11 +5540,13 @@ module ts { var declarations = symbol.getDeclarations(); if (declarations && declarations.length > 0) { // Disallow rename for elements that are defined in the standard TypeScript library. - var defaultLibFile = getDefaultLibFileName(host.getCompilationSettings()); - for (var i = 0; i < declarations.length; i++) { - var sourceFile = declarations[i].getSourceFile(); - if (sourceFile && endsWith(sourceFile.fileName, defaultLibFile)) { - return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); + var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + if (defaultLibFileName) { + for (var i = 0; i < declarations.length; i++) { + var sourceFile = declarations[i].getSourceFile(); + if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { + return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); + } } } @@ -5566,10 +5568,6 @@ module ts { return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key)); - function endsWith(string: string, value: string): boolean { - return string.lastIndexOf(value) + value.length === string.length; - } - function getRenameInfoError(localizedErrorMessage: string): RenameInfo { return { canRename: false, diff --git a/src/services/shims.ts b/src/services/shims.ts index a0eb1cb1ac4..7b5b6d08cf4 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -274,10 +274,7 @@ module ts { } public getDefaultLibFileName(options: CompilerOptions): string { - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - return ""; - //return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); } }