Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const libs = memoize(() => {
/** @type {{ libs: string[]; paths: Record<string, string | undefined>; }} */
const libraries = readJson("./src/lib/libs.json");
const libs = libraries.libs.map(lib => {
const relativeSources = ["header.d.ts", lib + ".d.ts"];
const relativeSources = [lib + ".d.ts"];
const relativeTarget = libraries.paths && libraries.paths[lib] || ("lib." + lib + ".d.ts");
const sources = relativeSources.map(s => path.posix.join("src/lib", s));
const target = `built/local/${relativeTarget}`;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function createBuilderProgramState(

if (canCopySemanticDiagnostics) {
if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) return;
if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) return;
if (newProgram.isSourceFileDefaultLibrary(sourceFile) && !copyLibFileDiagnostics) return;

// Unchanged file copy diagnostics
const diagnostics = oldState!.semanticDiagnosticsPerFile.get(sourceFilePath);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21504,15 +21504,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
let issuedElaboration = false;
if (!targetProp) {
const indexInfo = getApplicableIndexInfo(target, nameType);
if (indexInfo && indexInfo.declaration && !getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
if (indexInfo && indexInfo.declaration && !host.isSourceFileDefaultLibrary(getSourceFileOfNode(indexInfo.declaration))) {
issuedElaboration = true;
addRelatedInfo(reportedDiag, createDiagnosticForNode(indexInfo.declaration, Diagnostics.The_expected_type_comes_from_this_index_signature));
}
}

if (!issuedElaboration && (targetProp && length(targetProp.declarations) || target.symbol && length(target.symbol.declarations))) {
const targetNode = targetProp && length(targetProp.declarations) ? targetProp.declarations![0] : target.symbol.declarations![0];
if (!getSourceFileOfNode(targetNode).hasNoDefaultLib) {
if (!host.isSourceFileDefaultLibrary(getSourceFileOfNode(targetNode))) {
addRelatedInfo(
reportedDiag,
createDiagnosticForNode(
Expand Down
10 changes: 3 additions & 7 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4286,18 +4286,14 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
}

function emitSyntheticTripleSlashReferencesIfNeeded(node: Bundle) {
emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
emitTripleSlashDirectives(node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
}

function emitTripleSlashDirectivesIfNeeded(node: SourceFile) {
if (node.isDeclarationFile) emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
if (node.isDeclarationFile) emitTripleSlashDirectives(node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
}

function emitTripleSlashDirectives(hasNoDefaultLib: boolean, files: readonly FileReference[], types: readonly FileReference[], libs: readonly FileReference[]) {
if (hasNoDefaultLib) {
writeComment(`/// <reference no-default-lib="true"/>`);
writeLine();
}
function emitTripleSlashDirectives(files: readonly FileReference[], types: readonly FileReference[], libs: readonly FileReference[]) {
if (currentSourceFile && currentSourceFile.moduleName) {
writeComment(`/// <amd-module name="${currentSourceFile.moduleName}" />`);
writeLine();
Expand Down
6 changes: 2 additions & 4 deletions src/compiler/factory/nodeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6181,16 +6181,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
isDeclarationFile = node.isDeclarationFile,
referencedFiles = node.referencedFiles,
typeReferenceDirectives = node.typeReferenceDirectives,
hasNoDefaultLib = node.hasNoDefaultLib,
_hasNoDefaultLib = false,
libReferenceDirectives = node.libReferenceDirectives,
) {
return node.statements !== statements
|| node.isDeclarationFile !== isDeclarationFile
|| node.referencedFiles !== referencedFiles
|| node.typeReferenceDirectives !== typeReferenceDirectives
|| node.hasNoDefaultLib !== hasNoDefaultLib
|| node.libReferenceDirectives !== libReferenceDirectives
? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives), node)
? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, /*hasNoDefaultLib*/ false, libReferenceDirectives), node)
: node;
}

Expand All @@ -6201,7 +6200,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
node.syntheticFileReferences = undefined;
node.syntheticTypeReferences = undefined;
node.syntheticLibReferences = undefined;
node.hasNoDefaultLib = undefined;
return node;
}

Expand Down
3 changes: 1 addition & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10617,7 +10617,6 @@ export function processPragmasIntoFields(context: PragmaContext, reportDiagnosti
context.typeReferenceDirectives = [];
context.libReferenceDirectives = [];
context.amdDependencies = [];
context.hasNoDefaultLib = false;
context.pragmas!.forEach((entryOrList, key) => { // TODO: GH#18217
// TODO: The below should be strongly type-guarded and not need casts/explicit annotations, since entryOrList is related to
// key and key is constrained to a union; but it's not (see GH#21483 for at least partial fix) :(
Expand All @@ -10630,7 +10629,7 @@ export function processPragmasIntoFields(context: PragmaContext, reportDiagnosti
const { types, lib, path, ["resolution-mode"]: res, preserve: _preserve } = arg.arguments;
const preserve = _preserve === "true" ? true : undefined;
if (arg.arguments["no-default-lib"] === "true") {
context.hasNoDefaultLib = true;
// This has been removed; parse but ignore it.
}
else if (types) {
const parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
Expand Down
Loading
Loading