diff --git a/.gitignore b/.gitignore index 0973f04542e0..7fad8b15206e 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ jspm_packages/ .idea dist _ts3.4 +_ts4.2 *.tsbuildinfo .watchmanconfig .rollup.cache diff --git a/packages/typescript-estree/src/clear-caches.ts b/packages/typescript-estree/src/clear-caches.ts new file mode 100644 index 000000000000..c223fe852750 --- /dev/null +++ b/packages/typescript-estree/src/clear-caches.ts @@ -0,0 +1,21 @@ +import { clearWatchCaches } from './create-program/getWatchProgramsForProjects'; +import { clearProgramCache as clearProgramCacheOriginal } from './parser'; +import { clearTSConfigMatchCache } from './parseSettings/createParseSettings'; +import { clearGlobCache } from './parseSettings/resolveProjectList'; + +/** + * Clears all of the internal caches. + * Generally you shouldn't need or want to use this. + * Examples of intended uses: + * - In tests to reset parser state to keep tests isolated. + * - In custom lint tooling that iteratively lints one project at a time to prevent OOMs. + */ +export function clearCaches(): void { + clearProgramCacheOriginal(); + clearWatchCaches(); + clearTSConfigMatchCache(); + clearGlobCache(); +} + +// TODO - delete this in next major +export const clearProgramCache = clearCaches(); diff --git a/packages/typescript-estree/src/index.ts b/packages/typescript-estree/src/index.ts index bc7ed6024f3b..511ba6c769c5 100644 --- a/packages/typescript-estree/src/index.ts +++ b/packages/typescript-estree/src/index.ts @@ -5,16 +5,15 @@ export { parseWithNodeMaps, ParseAndGenerateServicesResult, ParseWithNodeMapsResult, - clearProgramCache, } from './parser'; export { ParserServices, TSESTreeOptions } from './parser-options'; export { simpleTraverse } from './simple-traverse'; export * from './ts-estree'; -export { clearWatchCaches as clearCaches } from './create-program/getWatchProgramsForProjects'; export { createProgramFromConfigFile as createProgram } from './create-program/useProvidedPrograms'; export * from './create-program/getScriptKind'; export { typescriptVersionIsAtLeast } from './version-check'; export * from './getModifiers'; +export * from './clear-caches'; // re-export for backwards-compat export { visitorKeys } from '@typescript-eslint/visitor-keys'; diff --git a/packages/typescript-estree/src/parseSettings/createParseSettings.ts b/packages/typescript-estree/src/parseSettings/createParseSettings.ts index 028088765a28..7518b0b686c7 100644 --- a/packages/typescript-estree/src/parseSettings/createParseSettings.ts +++ b/packages/typescript-estree/src/parseSettings/createParseSettings.ts @@ -121,6 +121,10 @@ export function createParseSettings( return parseSettings; } +export function clearTSConfigMatchCache(): void { + TSCONFIG_MATCH_CACHE?.clear(); +} + /** * Ensures source code is a string. */ diff --git a/packages/typescript-estree/src/parseSettings/resolveProjectList.ts b/packages/typescript-estree/src/parseSettings/resolveProjectList.ts index 72e9539d2b9b..f9d935b88cd4 100644 --- a/packages/typescript-estree/src/parseSettings/resolveProjectList.ts +++ b/packages/typescript-estree/src/parseSettings/resolveProjectList.ts @@ -21,6 +21,10 @@ const log = debug( let RESOLUTION_CACHE: ExpiringCache | null = null; +export function clearGlobCache(): void { + RESOLUTION_CACHE?.clear(); +} + /** * Normalizes, sanitizes, resolves and filters the provided project paths */ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy