mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add new option "libReplacement" (#60829)
This commit is contained in:
@@ -865,6 +865,14 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
affectsBuildInfo: true,
|
||||
affectsSemanticDiagnostics: true,
|
||||
},
|
||||
{
|
||||
name: "libReplacement",
|
||||
type: "boolean",
|
||||
affectsProgramStructure: true,
|
||||
category: Diagnostics.Language_and_Environment,
|
||||
description: Diagnostics.Enable_lib_replacement,
|
||||
defaultValueDescription: true,
|
||||
},
|
||||
|
||||
// Strict Type Checks
|
||||
{
|
||||
|
||||
@@ -6502,6 +6502,10 @@
|
||||
"category": "Error",
|
||||
"code": 6807
|
||||
},
|
||||
"Enable lib replacement.": {
|
||||
"category": "Message",
|
||||
"code": 6808
|
||||
},
|
||||
|
||||
"one of:": {
|
||||
"category": "Message",
|
||||
|
||||
@@ -3937,6 +3937,17 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
|
||||
const existing = resolvedLibProcessing?.get(libFileName);
|
||||
if (existing) return existing;
|
||||
|
||||
if (options.libReplacement === false) {
|
||||
const result: LibResolution = {
|
||||
resolution: {
|
||||
resolvedModule: undefined,
|
||||
},
|
||||
actual: combinePaths(defaultLibraryPath, libFileName),
|
||||
};
|
||||
(resolvedLibProcessing ??= new Map()).set(libFileName, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (structureIsReused !== StructureIsReused.Not && oldProgram && !hasInvalidatedLibResolutions(libFileName)) {
|
||||
const oldResolution = oldProgram.resolvedLibReferences?.get(libFileName);
|
||||
if (oldResolution) {
|
||||
|
||||
@@ -7411,6 +7411,7 @@ export interface CompilerOptions {
|
||||
/** @deprecated */
|
||||
keyofStringsOnly?: boolean;
|
||||
lib?: string[];
|
||||
libReplacement?: boolean;
|
||||
/** @internal */ listEmittedFiles?: boolean;
|
||||
/** @internal */ listFiles?: boolean;
|
||||
/** @internal */ explainFiles?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user