Merge pull request #28932 from j-oliveras/No-es2015-usages

Change es2015 usages to existing ts functions
This commit is contained in:
Daniel Rosenwasser
2018-12-10 17:11:28 -08:00
committed by GitHub
3 changed files with 3 additions and 3 deletions

View File

@@ -148,7 +148,7 @@ namespace ts {
}
export function isJsPrivate(name: string): boolean {
return name.startsWith("_");
return startsWith(name, "_");
}
function tryRequire(fileNameToRequire: string): unknown {

View File

@@ -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);

View File

@@ -45,7 +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 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;