@@ -100,7 +100,6 @@ import {
100
100
sort ,
101
101
SourceFile ,
102
102
startsWith ,
103
- stringContains ,
104
103
supportedDeclarationExtensions ,
105
104
supportedJSExtensionsFlat ,
106
105
supportedTSImplementationExtensions ,
@@ -1808,7 +1807,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
1808
1807
&& features & NodeResolutionFeatures . Exports
1809
1808
&& ! isExternalModuleNameRelative ( moduleName )
1810
1809
&& ! extensionIsOk ( Extensions . TypeScript | Extensions . Declaration , result . value . resolved . extension )
1811
- && conditions . indexOf ( "import" ) > - 1
1810
+ && conditions . includes ( "import" )
1812
1811
) {
1813
1812
traceIfEnabled ( state , Diagnostics . Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update ) ;
1814
1813
const diagnosticState = {
@@ -1849,7 +1848,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
1849
1848
resolved = loadModuleFromSelfNameReference ( extensions , moduleName , containingDirectory , state , cache , redirectedReference ) ;
1850
1849
}
1851
1850
if ( ! resolved ) {
1852
- if ( moduleName . indexOf ( ":" ) > - 1 ) {
1851
+ if ( moduleName . includes ( ":" ) ) {
1853
1852
if ( traceEnabled ) {
1854
1853
trace ( host , Diagnostics . Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1 , moduleName , formatExtensions ( extensions ) ) ;
1855
1854
}
@@ -1944,7 +1943,7 @@ function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string,
1944
1943
export const nodeModulesPathPart = "/node_modules/" ;
1945
1944
/** @internal */
1946
1945
export function pathContainsNodeModules ( path : string ) : boolean {
1947
- return stringContains ( path , nodeModulesPathPart ) ;
1946
+ return path . includes ( nodeModulesPathPart ) ;
1948
1947
}
1949
1948
1950
1949
/**
@@ -2006,7 +2005,7 @@ function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecor
2006
2005
2007
2006
function loadModuleFromFileNoImplicitExtensions ( extensions : Extensions , candidate : string , onlyRecordFailures : boolean , state : ModuleResolutionState ) : PathAndExtension | undefined {
2008
2007
const filename = getBaseFileName ( candidate ) ;
2009
- if ( filename . indexOf ( "." ) === - 1 ) {
2008
+ if ( ! filename . includes ( "." ) ) {
2010
2009
return undefined ; // extensionless import, no lookups performed, since we don't support extensionless files
2011
2010
}
2012
2011
let extensionless = removeFileExtension ( candidate ) ;
@@ -2223,7 +2222,7 @@ function loadEntrypointsFromExportMap(
2223
2222
2224
2223
function loadEntrypointsFromTargetExports ( target : unknown ) : boolean | undefined {
2225
2224
if ( typeof target === "string" && startsWith ( target , "./" ) ) {
2226
- if ( target . indexOf ( "*" ) >= 0 && state . host . readDirectory ) {
2225
+ if ( target . includes ( "*" ) && state . host . readDirectory ) {
2227
2226
if ( target . indexOf ( "*" ) !== target . lastIndexOf ( "*" ) ) {
2228
2227
return false ;
2229
2228
}
@@ -2243,7 +2242,7 @@ function loadEntrypointsFromExportMap(
2243
2242
}
2244
2243
else {
2245
2244
const partsAfterFirst = getPathComponents ( target ) . slice ( 2 ) ;
2246
- if ( partsAfterFirst . indexOf ( ".." ) >= 0 || partsAfterFirst . indexOf ( "." ) >= 0 || partsAfterFirst . indexOf ( "node_modules" ) >= 0 ) {
2245
+ if ( partsAfterFirst . includes ( ".." ) || partsAfterFirst . includes ( "." ) || partsAfterFirst . includes ( "node_modules" ) ) {
2247
2246
return false ;
2248
2247
}
2249
2248
const resolvedTarget = combinePaths ( scope . packageDirectory , target ) ;
@@ -2609,11 +2608,11 @@ export function comparePatternKeys(a: string, b: string) {
2609
2608
function loadModuleFromImportsOrExports ( extensions : Extensions , state : ModuleResolutionState , cache : ModuleResolutionCache | undefined , redirectedReference : ResolvedProjectReference | undefined , moduleName : string , lookupTable : object , scope : PackageJsonInfo , isImports : boolean ) : SearchResult < Resolved > | undefined {
2610
2609
const loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport ( extensions , state , cache , redirectedReference , moduleName , scope , isImports ) ;
2611
2610
2612
- if ( ! endsWith ( moduleName , directorySeparator ) && moduleName . indexOf ( "*" ) === - 1 && hasProperty ( lookupTable , moduleName ) ) {
2611
+ if ( ! endsWith ( moduleName , directorySeparator ) && ! moduleName . includes ( "*" ) && hasProperty ( lookupTable , moduleName ) ) {
2613
2612
const target = ( lookupTable as { [ idx : string ] : unknown ; } ) [ moduleName ] ;
2614
2613
return loadModuleFromTargetImportOrExport ( target , /*subpath*/ "" , /*pattern*/ false , moduleName ) ;
2615
2614
}
2616
- const expandingKeys = sort ( filter ( getOwnKeys ( lookupTable as MapLike < unknown > ) , k => k . indexOf ( "*" ) !== - 1 || endsWith ( k , "/" ) ) , comparePatternKeys ) ;
2615
+ const expandingKeys = sort ( filter ( getOwnKeys ( lookupTable as MapLike < unknown > ) , k => k . includes ( "*" ) || endsWith ( k , "/" ) ) , comparePatternKeys ) ;
2617
2616
for ( const potentialTarget of expandingKeys ) {
2618
2617
if ( state . features & NodeResolutionFeatures . ExportsPatternTrailers && matchesPatternWithTrailer ( potentialTarget , moduleName ) ) {
2619
2618
const target = ( lookupTable as { [ idx : string ] : unknown ; } ) [ potentialTarget ] ;
@@ -2677,7 +2676,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
2677
2676
}
2678
2677
const parts = pathIsRelative ( target ) ? getPathComponents ( target ) . slice ( 1 ) : getPathComponents ( target ) ;
2679
2678
const partsAfterFirst = parts . slice ( 1 ) ;
2680
- if ( partsAfterFirst . indexOf ( ".." ) >= 0 || partsAfterFirst . indexOf ( "." ) >= 0 || partsAfterFirst . indexOf ( "node_modules" ) >= 0 ) {
2679
+ if ( partsAfterFirst . includes ( ".." ) || partsAfterFirst . includes ( "." ) || partsAfterFirst . includes ( "node_modules" ) ) {
2681
2680
if ( state . traceEnabled ) {
2682
2681
trace ( state . host , Diagnostics . package_json_scope_0_has_invalid_type_for_target_of_specifier_1 , scope . packageDirectory , moduleName ) ;
2683
2682
}
@@ -2687,7 +2686,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
2687
2686
// TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
2688
2687
// to be in the business of validating everyone's import and export map correctness.
2689
2688
const subpathParts = getPathComponents ( subpath ) ;
2690
- if ( subpathParts . indexOf ( ".." ) >= 0 || subpathParts . indexOf ( "." ) >= 0 || subpathParts . indexOf ( "node_modules" ) >= 0 ) {
2689
+ if ( subpathParts . includes ( ".." ) || subpathParts . includes ( "." ) || subpathParts . includes ( "node_modules" ) ) {
2691
2690
if ( state . traceEnabled ) {
2692
2691
trace ( state . host , Diagnostics . package_json_scope_0_has_invalid_type_for_target_of_specifier_1 , scope . packageDirectory , moduleName ) ;
2693
2692
}
@@ -2706,7 +2705,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
2706
2705
if ( ! Array . isArray ( target ) ) {
2707
2706
traceIfEnabled ( state , Diagnostics . Entering_conditional_exports ) ;
2708
2707
for ( const condition of getOwnKeys ( target as MapLike < unknown > ) ) {
2709
- if ( condition === "default" || state . conditions . indexOf ( condition ) >= 0 || isApplicableVersionedTypesKey ( state . conditions , condition ) ) {
2708
+ if ( condition === "default" || state . conditions . includes ( condition ) || isApplicableVersionedTypesKey ( state . conditions , condition ) ) {
2710
2709
traceIfEnabled ( state , Diagnostics . Matched_0_condition_1 , isImports ? "imports" : "exports" , condition ) ;
2711
2710
const subTarget = ( target as MapLike < unknown > ) [ condition ] ;
2712
2711
const result = loadModuleFromTargetImportOrExport ( subTarget , subpath , pattern , key ) ;
@@ -2772,7 +2771,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
2772
2771
if (
2773
2772
! state . isConfigLookup
2774
2773
&& ( state . compilerOptions . declarationDir || state . compilerOptions . outDir )
2775
- && finalPath . indexOf ( "/node_modules/" ) === - 1
2774
+ && ! finalPath . includes ( "/node_modules/" )
2776
2775
&& ( state . compilerOptions . configFile ? containsPath ( scope . packageDirectory , toAbsolutePath ( state . compilerOptions . configFile . fileName ) , ! useCaseSensitiveFileNames ( state ) ) : true )
2777
2776
) {
2778
2777
// So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
@@ -2876,7 +2875,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
2876
2875
2877
2876
/** @internal */
2878
2877
export function isApplicableVersionedTypesKey ( conditions : readonly string [ ] , key : string ) {
2879
- if ( conditions . indexOf ( "types" ) === - 1 ) return false ; // only apply versioned types conditions if the types condition is applied
2878
+ if ( ! conditions . includes ( "types" ) ) return false ; // only apply versioned types conditions if the types condition is applied
2880
2879
if ( ! startsWith ( key , "types@" ) ) return false ;
2881
2880
const range = VersionRange . tryParse ( key . substring ( "types@" . length ) ) ;
2882
2881
if ( ! range ) return false ;
@@ -3099,7 +3098,7 @@ export function getPackageNameFromTypesPackageName(mangledName: string): string
3099
3098
3100
3099
/** @internal */
3101
3100
export function unmangleScopedPackageName ( typesPackageName : string ) : string {
3102
- return stringContains ( typesPackageName , mangledScopedPackageSeparator ) ?
3101
+ return typesPackageName . includes ( mangledScopedPackageSeparator ) ?
3103
3102
"@" + typesPackageName . replace ( mangledScopedPackageSeparator , directorySeparator ) :
3104
3103
typesPackageName ;
3105
3104
}
0 commit comments