Skip to content

Commit 96acaa5

Browse files
authored
Remove no-default-lib (#62435)
1 parent 904e7dd commit 96acaa5

File tree

2,178 files changed

+15942
-25733
lines changed

Some content is hidden

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

2,178 files changed

+15942
-25733
lines changed

Herebyfile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const libs = memoize(() => {
5252
/** @type {{ libs: string[]; paths: Record<string, string | undefined>; }} */
5353
const libraries = readJson("./src/lib/libs.json");
5454
const libs = libraries.libs.map(lib => {
55-
const relativeSources = ["header.d.ts", lib + ".d.ts"];
55+
const relativeSources = [lib + ".d.ts"];
5656
const relativeTarget = libraries.paths && libraries.paths[lib] || ("lib." + lib + ".d.ts");
5757
const sources = relativeSources.map(s => path.posix.join("src/lib", s));
5858
const target = `built/local/${relativeTarget}`;

src/compiler/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function createBuilderProgramState(
412412

413413
if (canCopySemanticDiagnostics) {
414414
if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) return;
415-
if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) return;
415+
if (newProgram.isSourceFileDefaultLibrary(sourceFile) && !copyLibFileDiagnostics) return;
416416

417417
// Unchanged file copy diagnostics
418418
const diagnostics = oldState!.semanticDiagnosticsPerFile.get(sourceFilePath);

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21504,15 +21504,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2150421504
let issuedElaboration = false;
2150521505
if (!targetProp) {
2150621506
const indexInfo = getApplicableIndexInfo(target, nameType);
21507-
if (indexInfo && indexInfo.declaration && !getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
21507+
if (indexInfo && indexInfo.declaration && !host.isSourceFileDefaultLibrary(getSourceFileOfNode(indexInfo.declaration))) {
2150821508
issuedElaboration = true;
2150921509
addRelatedInfo(reportedDiag, createDiagnosticForNode(indexInfo.declaration, Diagnostics.The_expected_type_comes_from_this_index_signature));
2151021510
}
2151121511
}
2151221512

2151321513
if (!issuedElaboration && (targetProp && length(targetProp.declarations) || target.symbol && length(target.symbol.declarations))) {
2151421514
const targetNode = targetProp && length(targetProp.declarations) ? targetProp.declarations![0] : target.symbol.declarations![0];
21515-
if (!getSourceFileOfNode(targetNode).hasNoDefaultLib) {
21515+
if (!host.isSourceFileDefaultLibrary(getSourceFileOfNode(targetNode))) {
2151621516
addRelatedInfo(
2151721517
reportedDiag,
2151821518
createDiagnosticForNode(

src/compiler/emitter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,18 +4286,14 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
42864286
}
42874287

42884288
function emitSyntheticTripleSlashReferencesIfNeeded(node: Bundle) {
4289-
emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
4289+
emitTripleSlashDirectives(node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
42904290
}
42914291

42924292
function emitTripleSlashDirectivesIfNeeded(node: SourceFile) {
4293-
if (node.isDeclarationFile) emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
4293+
if (node.isDeclarationFile) emitTripleSlashDirectives(node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
42944294
}
42954295

4296-
function emitTripleSlashDirectives(hasNoDefaultLib: boolean, files: readonly FileReference[], types: readonly FileReference[], libs: readonly FileReference[]) {
4297-
if (hasNoDefaultLib) {
4298-
writeComment(`/// <reference no-default-lib="true"/>`);
4299-
writeLine();
4300-
}
4296+
function emitTripleSlashDirectives(files: readonly FileReference[], types: readonly FileReference[], libs: readonly FileReference[]) {
43014297
if (currentSourceFile && currentSourceFile.moduleName) {
43024298
writeComment(`/// <amd-module name="${currentSourceFile.moduleName}" />`);
43034299
writeLine();

src/compiler/factory/nodeFactory.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6181,16 +6181,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
61816181
isDeclarationFile = node.isDeclarationFile,
61826182
referencedFiles = node.referencedFiles,
61836183
typeReferenceDirectives = node.typeReferenceDirectives,
6184-
hasNoDefaultLib = node.hasNoDefaultLib,
6184+
_hasNoDefaultLib = false,
61856185
libReferenceDirectives = node.libReferenceDirectives,
61866186
) {
61876187
return node.statements !== statements
61886188
|| node.isDeclarationFile !== isDeclarationFile
61896189
|| node.referencedFiles !== referencedFiles
61906190
|| node.typeReferenceDirectives !== typeReferenceDirectives
6191-
|| node.hasNoDefaultLib !== hasNoDefaultLib
61926191
|| node.libReferenceDirectives !== libReferenceDirectives
6193-
? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives), node)
6192+
? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, /*hasNoDefaultLib*/ false, libReferenceDirectives), node)
61946193
: node;
61956194
}
61966195

@@ -6201,7 +6200,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
62016200
node.syntheticFileReferences = undefined;
62026201
node.syntheticTypeReferences = undefined;
62036202
node.syntheticLibReferences = undefined;
6204-
node.hasNoDefaultLib = undefined;
62056203
return node;
62066204
}
62076205

src/compiler/parser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10617,7 +10617,6 @@ export function processPragmasIntoFields(context: PragmaContext, reportDiagnosti
1061710617
context.typeReferenceDirectives = [];
1061810618
context.libReferenceDirectives = [];
1061910619
context.amdDependencies = [];
10620-
context.hasNoDefaultLib = false;
1062110620
context.pragmas!.forEach((entryOrList, key) => { // TODO: GH#18217
1062210621
// TODO: The below should be strongly type-guarded and not need casts/explicit annotations, since entryOrList is related to
1062310622
// key and key is constrained to a union; but it's not (see GH#21483 for at least partial fix) :(
@@ -10630,7 +10629,7 @@ export function processPragmasIntoFields(context: PragmaContext, reportDiagnosti
1063010629
const { types, lib, path, ["resolution-mode"]: res, preserve: _preserve } = arg.arguments;
1063110630
const preserve = _preserve === "true" ? true : undefined;
1063210631
if (arg.arguments["no-default-lib"] === "true") {
10633-
context.hasNoDefaultLib = true;
10632+
// This has been removed; parse but ignore it.
1063410633
}
1063510634
else if (types) {
1063610635
const parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);

0 commit comments

Comments
 (0)