File tree 2 files changed +8
-13
lines changed
2 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -5540,11 +5540,13 @@ module ts {
5540
5540
var declarations = symbol . getDeclarations ( ) ;
5541
5541
if ( declarations && declarations . length > 0 ) {
5542
5542
// Disallow rename for elements that are defined in the standard TypeScript library.
5543
- var defaultLibFile = getDefaultLibFileName ( host . getCompilationSettings ( ) ) ;
5544
- for ( var i = 0 ; i < declarations . length ; i ++ ) {
5545
- var sourceFile = declarations [ i ] . getSourceFile ( ) ;
5546
- if ( sourceFile && endsWith ( sourceFile . fileName , defaultLibFile ) ) {
5547
- return getRenameInfoError ( getLocaleSpecificMessage ( Diagnostics . You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library . key ) ) ;
5543
+ var defaultLibFileName = host . getDefaultLibFileName ( host . getCompilationSettings ( ) ) ;
5544
+ if ( defaultLibFileName ) {
5545
+ for ( var i = 0 ; i < declarations . length ; i ++ ) {
5546
+ var sourceFile = declarations [ i ] . getSourceFile ( ) ;
5547
+ if ( sourceFile && getCanonicalFileName ( ts . normalizePath ( sourceFile . fileName ) ) === getCanonicalFileName ( ts . normalizePath ( defaultLibFileName ) ) ) {
5548
+ return getRenameInfoError ( getLocaleSpecificMessage ( Diagnostics . You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library . key ) ) ;
5549
+ }
5548
5550
}
5549
5551
}
5550
5552
@@ -5566,10 +5568,6 @@ module ts {
5566
5568
5567
5569
return getRenameInfoError ( getLocaleSpecificMessage ( Diagnostics . You_cannot_rename_this_element . key ) ) ;
5568
5570
5569
- function endsWith ( string : string , value : string ) : boolean {
5570
- return string . lastIndexOf ( value ) + value . length === string . length ;
5571
- }
5572
-
5573
5571
function getRenameInfoError ( localizedErrorMessage : string ) : RenameInfo {
5574
5572
return {
5575
5573
canRename : false ,
Original file line number Diff line number Diff line change @@ -274,10 +274,7 @@ module ts {
274
274
}
275
275
276
276
public getDefaultLibFileName ( options : CompilerOptions ) : string {
277
- // Shim the API changes for 1.5 release. This should be removed once
278
- // TypeScript 1.5 has shipped.
279
- return "" ;
280
- //return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
277
+ return this . shimHost . getDefaultLibFileName ( JSON . stringify ( options ) ) ;
281
278
}
282
279
}
283
280
You can’t perform that action at this time.
0 commit comments