@@ -100,7 +100,6 @@ import {
100100 sort ,
101101 SourceFile ,
102102 startsWith ,
103- stringContains ,
104103 supportedDeclarationExtensions ,
105104 supportedJSExtensionsFlat ,
106105 supportedTSImplementationExtensions ,
@@ -1808,7 +1807,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
18081807 && features & NodeResolutionFeatures . Exports
18091808 && ! isExternalModuleNameRelative ( moduleName )
18101809 && ! extensionIsOk ( Extensions . TypeScript | Extensions . Declaration , result . value . resolved . extension )
1811- && conditions . indexOf ( "import" ) > - 1
1810+ && conditions . includes ( "import" )
18121811 ) {
18131812 traceIfEnabled ( state , Diagnostics . Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update ) ;
18141813 const diagnosticState = {
@@ -1849,7 +1848,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
18491848 resolved = loadModuleFromSelfNameReference ( extensions , moduleName , containingDirectory , state , cache , redirectedReference ) ;
18501849 }
18511850 if ( ! resolved ) {
1852- if ( moduleName . indexOf ( ":" ) > - 1 ) {
1851+ if ( moduleName . includes ( ":" ) ) {
18531852 if ( traceEnabled ) {
18541853 trace ( host , Diagnostics . Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1 , moduleName , formatExtensions ( extensions ) ) ;
18551854 }
@@ -1944,7 +1943,7 @@ function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string,
19441943export const nodeModulesPathPart = "/node_modules/" ;
19451944/** @internal */
19461945export function pathContainsNodeModules ( path : string ) : boolean {
1947- return stringContains ( path , nodeModulesPathPart ) ;
1946+ return path . includes ( nodeModulesPathPart ) ;
19481947}
19491948
19501949/**
@@ -2006,7 +2005,7 @@ function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecor
20062005
20072006function loadModuleFromFileNoImplicitExtensions ( extensions : Extensions , candidate : string , onlyRecordFailures : boolean , state : ModuleResolutionState ) : PathAndExtension | undefined {
20082007 const filename = getBaseFileName ( candidate ) ;
2009- if ( filename . indexOf ( "." ) === - 1 ) {
2008+ if ( ! filename . includes ( "." ) ) {
20102009 return undefined ; // extensionless import, no lookups performed, since we don't support extensionless files
20112010 }
20122011 let extensionless = removeFileExtension ( candidate ) ;
@@ -2223,7 +2222,7 @@ function loadEntrypointsFromExportMap(
22232222
22242223 function loadEntrypointsFromTargetExports ( target : unknown ) : boolean | undefined {
22252224 if ( typeof target === "string" && startsWith ( target , "./" ) ) {
2226- if ( target . indexOf ( "*" ) >= 0 && state . host . readDirectory ) {
2225+ if ( target . includes ( "*" ) && state . host . readDirectory ) {
22272226 if ( target . indexOf ( "*" ) !== target . lastIndexOf ( "*" ) ) {
22282227 return false ;
22292228 }
@@ -2243,7 +2242,7 @@ function loadEntrypointsFromExportMap(
22432242 }
22442243 else {
22452244 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" ) ) {
22472246 return false ;
22482247 }
22492248 const resolvedTarget = combinePaths ( scope . packageDirectory , target ) ;
@@ -2609,11 +2608,11 @@ export function comparePatternKeys(a: string, b: string) {
26092608function loadModuleFromImportsOrExports ( extensions : Extensions , state : ModuleResolutionState , cache : ModuleResolutionCache | undefined , redirectedReference : ResolvedProjectReference | undefined , moduleName : string , lookupTable : object , scope : PackageJsonInfo , isImports : boolean ) : SearchResult < Resolved > | undefined {
26102609 const loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport ( extensions , state , cache , redirectedReference , moduleName , scope , isImports ) ;
26112610
2612- if ( ! endsWith ( moduleName , directorySeparator ) && moduleName . indexOf ( "*" ) === - 1 && hasProperty ( lookupTable , moduleName ) ) {
2611+ if ( ! endsWith ( moduleName , directorySeparator ) && ! moduleName . includes ( "*" ) && hasProperty ( lookupTable , moduleName ) ) {
26132612 const target = ( lookupTable as { [ idx : string ] : unknown ; } ) [ moduleName ] ;
26142613 return loadModuleFromTargetImportOrExport ( target , /*subpath*/ "" , /*pattern*/ false , moduleName ) ;
26152614 }
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 ) ;
26172616 for ( const potentialTarget of expandingKeys ) {
26182617 if ( state . features & NodeResolutionFeatures . ExportsPatternTrailers && matchesPatternWithTrailer ( potentialTarget , moduleName ) ) {
26192618 const target = ( lookupTable as { [ idx : string ] : unknown ; } ) [ potentialTarget ] ;
@@ -2677,7 +2676,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
26772676 }
26782677 const parts = pathIsRelative ( target ) ? getPathComponents ( target ) . slice ( 1 ) : getPathComponents ( target ) ;
26792678 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" ) ) {
26812680 if ( state . traceEnabled ) {
26822681 trace ( state . host , Diagnostics . package_json_scope_0_has_invalid_type_for_target_of_specifier_1 , scope . packageDirectory , moduleName ) ;
26832682 }
@@ -2687,7 +2686,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
26872686 // TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
26882687 // to be in the business of validating everyone's import and export map correctness.
26892688 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" ) ) {
26912690 if ( state . traceEnabled ) {
26922691 trace ( state . host , Diagnostics . package_json_scope_0_has_invalid_type_for_target_of_specifier_1 , scope . packageDirectory , moduleName ) ;
26932692 }
@@ -2706,7 +2705,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
27062705 if ( ! Array . isArray ( target ) ) {
27072706 traceIfEnabled ( state , Diagnostics . Entering_conditional_exports ) ;
27082707 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 ) ) {
27102709 traceIfEnabled ( state , Diagnostics . Matched_0_condition_1 , isImports ? "imports" : "exports" , condition ) ;
27112710 const subTarget = ( target as MapLike < unknown > ) [ condition ] ;
27122711 const result = loadModuleFromTargetImportOrExport ( subTarget , subpath , pattern , key ) ;
@@ -2772,7 +2771,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
27722771 if (
27732772 ! state . isConfigLookup
27742773 && ( state . compilerOptions . declarationDir || state . compilerOptions . outDir )
2775- && finalPath . indexOf ( "/node_modules/" ) === - 1
2774+ && ! finalPath . includes ( "/node_modules/" )
27762775 && ( state . compilerOptions . configFile ? containsPath ( scope . packageDirectory , toAbsolutePath ( state . compilerOptions . configFile . fileName ) , ! useCaseSensitiveFileNames ( state ) ) : true )
27772776 ) {
27782777 // 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
28762875
28772876/** @internal */
28782877export 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
28802879 if ( ! startsWith ( key , "types@" ) ) return false ;
28812880 const range = VersionRange . tryParse ( key . substring ( "types@" . length ) ) ;
28822881 if ( ! range ) return false ;
@@ -3099,7 +3098,7 @@ export function getPackageNameFromTypesPackageName(mangledName: string): string
30993098
31003099/** @internal */
31013100export function unmangleScopedPackageName ( typesPackageName : string ) : string {
3102- return stringContains ( typesPackageName , mangledScopedPackageSeparator ) ?
3101+ return typesPackageName . includes ( mangledScopedPackageSeparator ) ?
31033102 "@" + typesPackageName . replace ( mangledScopedPackageSeparator , directorySeparator ) :
31043103 typesPackageName ;
31053104}
0 commit comments