Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 220706e

Browse files
authoredJan 24, 2025··
Add new option "libReplacement" (#60829)
1 parent c5058f0 commit 220706e

File tree

49 files changed

+1230
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1230
-71
lines changed
 

‎src/compiler/commandLineParser.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,14 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
865865
affectsBuildInfo: true,
866866
affectsSemanticDiagnostics: true,
867867
},
868+
{
869+
name: "libReplacement",
870+
type: "boolean",
871+
affectsProgramStructure: true,
872+
category: Diagnostics.Language_and_Environment,
873+
description: Diagnostics.Enable_lib_replacement,
874+
defaultValueDescription: true,
875+
},
868876

869877
// Strict Type Checks
870878
{

‎src/compiler/diagnosticMessages.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6502,6 +6502,10 @@
65026502
"category": "Error",
65036503
"code": 6807
65046504
},
6505+
"Enable lib replacement.": {
6506+
"category": "Message",
6507+
"code": 6808
6508+
},
65056509

65066510
"one of:": {
65076511
"category": "Message",

‎src/compiler/program.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,6 +3937,17 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
39373937
const existing = resolvedLibProcessing?.get(libFileName);
39383938
if (existing) return existing;
39393939

3940+
if (options.libReplacement === false) {
3941+
const result: LibResolution = {
3942+
resolution: {
3943+
resolvedModule: undefined,
3944+
},
3945+
actual: combinePaths(defaultLibraryPath, libFileName),
3946+
};
3947+
(resolvedLibProcessing ??= new Map()).set(libFileName, result);
3948+
return result;
3949+
}
3950+
39403951
if (structureIsReused !== StructureIsReused.Not && oldProgram && !hasInvalidatedLibResolutions(libFileName)) {
39413952
const oldResolution = oldProgram.resolvedLibReferences?.get(libFileName);
39423953
if (oldResolution) {

‎src/compiler/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7411,6 +7411,7 @@ export interface CompilerOptions {
74117411
/** @deprecated */
74127412
keyofStringsOnly?: boolean;
74137413
lib?: string[];
7414+
libReplacement?: boolean;
74147415
/** @internal */ listEmittedFiles?: boolean;
74157416
/** @internal */ listFiles?: boolean;
74167417
/** @internal */ explainFiles?: boolean;

0 commit comments

Comments
 (0)
Please sign in to comment.