From f41b4e088da53f73e7f2b51bef3f8feb31b59656 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:17:54 +0100 Subject: [PATCH 1/5] Change usage of Array.prototype.find to ts.find. --- src/compiler/moduleSpecifiers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 1913ee90b2b..f5bac45f6ab 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -203,7 +203,7 @@ namespace ts.moduleSpecifiers { return; // Don't want to a package to globally import from itself } - const target = targets.find(t => compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === Comparison.EqualTo); + const target = find(targets, t => compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === Comparison.EqualTo); if (target === undefined) return; const relative = getRelativePathFromDirectory(resolved, target, getCanonicalFileName); From 3d23e7a0a4fe5894f6f79fbd3e15d2956f5a1fc8 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:21:45 +0100 Subject: [PATCH 2/5] Change usage of String.prototype.startsWith to ts.startsWith. --- src/compiler/inspectValue.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/inspectValue.ts b/src/compiler/inspectValue.ts index 8433ee6e489..8d0b6993c00 100644 --- a/src/compiler/inspectValue.ts +++ b/src/compiler/inspectValue.ts @@ -148,8 +148,7 @@ namespace ts { } export function isJsPrivate(name: string): boolean { - return name.startsWith("_"); - } + return startsWith(name, "_"); } function tryRequire(fileNameToRequire: string): unknown { try { From 4e43dcdc05074d9f28efa2232e328f2bc0002d85 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:22:06 +0100 Subject: [PATCH 3/5] Change usages of String.prototype.endsWith to ts.endsWith. --- src/services/rename.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/rename.ts b/src/services/rename.ts index 7ba32c91309..1175ce847fe 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -45,8 +45,7 @@ namespace ts.Rename { const moduleSourceFile = find(moduleSymbol.declarations, isSourceFile); if (!moduleSourceFile) return undefined; - const withoutIndex = node.text.endsWith("/index") || node.text.endsWith("/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); - const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; + const withoutIndex = endsWith(node.text, "/index") || endsWith(node.text, "/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; const kind = withoutIndex === undefined ? ScriptElementKind.moduleElement : ScriptElementKind.directory; const indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. From 6a82b0a96bf7104743b7ca5cf9eb89fffa6b68f4 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:42:02 +0100 Subject: [PATCH 4/5] Add newline, bad edit --- src/compiler/inspectValue.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/inspectValue.ts b/src/compiler/inspectValue.ts index 8d0b6993c00..381f47d12e9 100644 --- a/src/compiler/inspectValue.ts +++ b/src/compiler/inspectValue.ts @@ -148,7 +148,8 @@ namespace ts { } export function isJsPrivate(name: string): boolean { - return startsWith(name, "_"); } + return startsWith(name, "_"); + } function tryRequire(fileNameToRequire: string): unknown { try { From 599a963493a8bdb12e2eef7cc37151c047df8af0 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:42:46 +0100 Subject: [PATCH 5/5] Add newline --- src/services/rename.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/rename.ts b/src/services/rename.ts index 1175ce847fe..a51d79797bf 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -45,7 +45,8 @@ namespace ts.Rename { const moduleSourceFile = find(moduleSymbol.declarations, isSourceFile); if (!moduleSourceFile) return undefined; - const withoutIndex = endsWith(node.text, "/index") || endsWith(node.text, "/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; + const withoutIndex = endsWith(node.text, "/index") || endsWith(node.text, "/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); + const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; const kind = withoutIndex === undefined ? ScriptElementKind.moduleElement : ScriptElementKind.directory; const indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character.