Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
befdda6
add modified tsconfig.json
Michiel-VandeVelde Jul 28, 2026
e4d49b0
Add TypeScript devDependencies, scripts, and eslint override
Michiel-VandeVelde Jul 28, 2026
0ce69b1
Convert @ldf/core to TypeScript
Michiel-VandeVelde Jul 28, 2026
20b1199
Convert datasource-* packages to TypeScript
Michiel-VandeVelde Jul 28, 2026
7e7f87c
Replace any with real types in Controller.ts where possible
Michiel-VandeVelde Jul 28, 2026
4d311e3
Type LdfRequest.parsedUrl as UrlObject instead of Record<string, any>
Michiel-VandeVelde Jul 28, 2026
b360004
Narrow select()'s early-return casts from any to unknown-as-AsyncIter…
Michiel-VandeVelde Jul 28, 2026
c07d7c7
Add an index signature to QueryFeatures, dropping a cast in Datasourc…
Michiel-VandeVelde Jul 28, 2026
64e1276
Restore original whitespace alignment lost during JS->TS retyping
Michiel-VandeVelde Jul 28, 2026
9a8d074
Drop unnecessary any casts in RdfView.ts, guard the one real duck-type
Michiel-VandeVelde Jul 28, 2026
a0c7033
Audit every remaining any across core and datasource-* packages
Michiel-VandeVelde Jul 28, 2026
3761b82
Type _request as the real request package's RequestAPI
Michiel-VandeVelde Jul 28, 2026
8f84682
Further any tightening pass across core
Michiel-VandeVelde Jul 28, 2026
303aefc
Fix LinkedDataFragmentsServer's exported constructor type, add _first…
Michiel-VandeVelde Jul 28, 2026
5808520
Convert feature-webid, feature-summary, feature-memento to TypeScript
Michiel-VandeVelde Jul 29, 2026
90cdfba
Convert feature-qpf to TypeScript
Michiel-VandeVelde Jul 29, 2026
dde4dcd
Adopt type-aware ESLint rules, tighten any-hiding casts to real types
Michiel-VandeVelde Jul 29, 2026
7de1b4d
Audit non-null assertions: replace dishonest ! with casts or real types
Michiel-VandeVelde Jul 29, 2026
1b72641
Add fallback guards for the two crash-risk assertions from the ! audit
Michiel-VandeVelde Jul 29, 2026
cfb6623
Deduplicate the pageSize cast in PageRouter into a local variable
Michiel-VandeVelde Jul 29, 2026
dba473d
Add a lint guardrail against new as-unknown-as-X casts, eliminate wha…
Michiel-VandeVelde Jul 29, 2026
171cdf9
Fix CI: build TypeScript before running tests
Michiel-VandeVelde Jul 29, 2026
97b2507
Add tests for the three previously-untested packages/files
Michiel-VandeVelde Jul 29, 2026
b06fdae
Deduplicate repeated inline cast shapes into shared local types
Michiel-VandeVelde Jul 30, 2026
8a230b0
Eliminate as-unknown-as-X casts in favor of real types and fixes
Michiel-VandeVelde Jul 30, 2026
40d5d5d
Deduplicate Pushable into a shared generic, eliminate remaining as-an…
Michiel-VandeVelde Jul 30, 2026
7edb2d8
Remove IndexDatasource-test.js from this branch
Michiel-VandeVelde Jul 31, 2026
3210fae
Drop the remaining as-any cast in WebIDControllerExtension
Michiel-VandeVelde Jul 31, 2026
4299d2c
Streamline gitignore and eslintignore
Michiel-VandeVelde Jul 31, 2026
f116ff2
add postinstall
Michiel-VandeVelde Jul 31, 2026
af29b86
Stop skipping lib check, add comments to shims to explain further, Fi…
Michiel-VandeVelde Jul 31, 2026
0cfc18f
Refactor N3Parser integration
Michiel-VandeVelde Jul 31, 2026
bbd53a2
narrow casts and try Util Error handling
Michiel-VandeVelde Aug 3, 2026
928c9a4
fix narrowing in QPF controller and router
Michiel-VandeVelde Aug 3, 2026
0e2b2d8
Add lru-cache v5 type shim
Michiel-VandeVelde Aug 3, 2026
56460e9
Apply suggestion from @jitsedesmet
Michiel-VandeVelde Aug 3, 2026
9c6141e
remove shim. Lock in Lru-cache
Michiel-VandeVelde Aug 3, 2026
2ae213f
Tighten types and align Util with commonjs exports
Michiel-VandeVelde Aug 4, 2026
19f0580
Address review comments on feature-summary
Michiel-VandeVelde Aug 4, 2026
a73d281
remove unnecessary excluded files in tsconfig
Michiel-VandeVelde Aug 4, 2026
bce6ec3
revert module export to export
Michiel-VandeVelde Aug 4, 2026
cb510bf
revert export to module-export v2
Michiel-VandeVelde Aug 4, 2026
c2f92e6
WebId update
Michiel-VandeVelde Aug 4, 2026
faa5eb6
Replace require()/export= with named exports and imports throughout
Michiel-VandeVelde Aug 5, 2026
694e67b
some final small code comment improvements etc
Michiel-VandeVelde Aug 6, 2026
9b60c04
fix
Michiel-VandeVelde Aug 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
coverage
.nyc_output

# Compiled output for packages already converted to TypeScript
packages/*/**/*.js
packages/*/**/*.d.ts
!packages/*/test/**
!packages/preset-qpf/**/*.js
!packages/server/**/*.js
77 changes: 77 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,83 @@
rules: {
"import/no-extraneous-dependencies": "off"
}
},
{
// TypeScript source files
files: [ "packages/**/*.ts" ],
parser: "@typescript-eslint/parser",
extends: [ "plugin:@typescript-eslint/recommended-requiring-type-checking" ],
parserOptions: {
ecmaVersion: 9,
sourceType: "module",
project: "./tsconfig.json"
},
plugins: [ "@typescript-eslint" ],
Comment thread
Michiel-VandeVelde marked this conversation as resolved.
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [ 2, { args: "none" } ],
// The TS compiler already catches undefined references, and this rule
// otherwise misfires on TS-only constructs (interfaces, type imports).
"no-undef": "off",
// Misfires on TS function-overload signatures (multiple declarations
// for one implementation) — the TS compiler already validates those.
"no-redeclare": "off",
// Third-party type names (e.g. rdf-js's Quad_Graph) aren't ours to rename.
"camelcase": "off",
// Comunica's own eslint config disables these same three as "TODO: check
// if these can be enabled" — any flowing through further calls/assignments
// is too common a real pattern here to enforce yet.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
// This codebase uses `let` pervasively as a long-standing style choice;
// enforcing const-where-possible would touch nearly every converted file.
"prefer-const": "off",
// 'text ' + someNumber is safe and pervasive in this codebase's string-building
// style; keep the rule's real catches (undefined, objects, Terms) active.
"@typescript-eslint/restrict-plus-operands": [ 2, { allowNumberAndString: true } ],
// Every hit is a destructured DataFactory method (quad/namedNode/literal) or
// lodash's _.noop — none use `this`, but the rule can't see that from the
// third-party type declarations alone.
"@typescript-eslint/unbound-method": "off",
// no-floating-promises' own suggested fix for an intentionally-unawaited
// promise chain is prefixing it with `void`.
"no-void": [ 2, { allowAsStatement: true } ],
// `x as unknown as Y` opts out of type checking entirely for x. Files with
// an existing, individually-reviewed need for it are exempted below;
// this catches it showing up anywhere else. Prefer a real type, or
// String(x)/Number(x) if this is really just coercion.
"no-restricted-syntax": [ 2, {
selector: "TSAsExpression > TSAsExpression[typeAnnotation.type='TSUnknownKeyword']",
message: "as unknown as X bypasses type checking. Prefer a real type; if unavoidable, add this file to the no-restricted-syntax exemption list in .eslintrc."
} ]
}
},
{
// HdtDatasource's constructor swaps in an ExternalHdtDatasource instance in place
// of `this`; the two are sibling classes (not a subtype relationship), and each
// independently overrides several of Datasource's protected methods, which brands
// them as structurally incompatible for TS's purposes even though they're
// interchangeable at runtime. Resolving this for real means either widening those
// protected overrides to public across both classes, or replacing the pattern with
// a factory function — both bigger changes than a type-only cleanup; see the
// commit history for the investigation.
files: [
"packages/datasource-hdt/lib/datasources/HdtDatasource.ts"
],
rules: {
"no-restricted-syntax": "off"
}
},
{
// Needs `as unknown as X` to reach n3.Parser's internals,
// since @types/n3 has no typing for them.
files: [
"packages/core/lib/N3ParserExtended.ts"
],
rules: {
"no-restricted-syntax": "off"
}
}
]
}
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
key: ${{ runner.os }}-test-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install
- name: Build TypeScript
run: yarn run build
- name: Run tests
run: yarn run test-ci
- name: Submit coverage results
Expand Down
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ config/*.json

# Ignore dev environment files
.idea
.devcontainer
.devcontainer

# Compiled output for packages already converted to TypeScript
packages/*/**/*.js
packages/*/**/*.js.map
packages/*/**/*.d.ts
!packages/*/test/**
!packages/preset-qpf/**/*.js
!packages/preset-qpf/**/*.js.map
!packages/server/**/*.js
!packages/server/**/*.js.map
21 changes: 17 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
"packages/*"
],
"engines": {
"node": ">=10.0"
"node": ">=20.0"
Comment thread
jitsedesmet marked this conversation as resolved.
},
"devDependencies": {
"@types/lodash": "^4.17.24",
"@types/lru-cache": "^5.1.1",
"@types/mime": "^2.0.3",
"@types/node": "^22.20.1",
"@types/parse-cache-control": "^1.0.4",
"@types/q": "^1.5.8",
"@types/request": "^2.48.13",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"chai": "^4.0.0",
"coveralls": "^3.0.9",
"eslint": "^7.0.0",
Expand All @@ -17,9 +26,11 @@
"mocha": "^8.0.0",
"nyc": "^15.0.0",
"pre-commit": "^1.1.3",
"rdf-object": "^1.14.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an additional dependency?

"sinon": "^1.17.4",
"sinon-chai": "^2.14.0",
"supertest": "^6.0.0"
"supertest": "^6.0.0",
"typescript": "^5.9.3"
},
"pre-commit": [
"lint",
Expand All @@ -31,12 +42,14 @@
"mocha": "mocha \"packages/*/test/**/*-test.js\" --recursive --require ./test/test-setup --timeout 500",
"test": "nyc npm run mocha",
"test-ci": "nyc --reporter=lcov npm run mocha",
"lint": "eslint packages/*/bin/* packages/*/lib packages/*/test",
"typecheck": "tsc -p tsconfig.json --noEmit",
Comment thread
Michiel-VandeVelde marked this conversation as resolved.
"build": "tsc -p tsconfig.json",
"lint": "eslint packages/*/bin/* packages/*/lib packages/*/test --ext .js,.ts",
"clean": "rm -rf ./node_modules && rm -rf ./packages/*/node_modules",
"dedupe": "npx yarn-deduplicate yarn.lock --scopes",
"publish": "lerna publish",
"publish-bare": "lerna exec -- npm publish --silent",
"postinstall": "lerna run prepare",
"postinstall": "lerna run prepare && yarn run build",
"version": "manual-git-changelog onversion"
}
}
45 changes: 0 additions & 45 deletions packages/core/index.js

This file was deleted.

96 changes: 96 additions & 0 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*! @license MIT ©2015-2016 Ruben Verborgh, Ghent University - imec */
/* Exports of the components of this package */

import type * as Types from './lib/types';

import { AssetsController } from './lib/controllers/AssetsController';
import { Controller } from './lib/controllers/Controller';
import { DeferenceController as DereferenceController } from './lib/controllers/DereferenceController';
import { ErrorController } from './lib/controllers/ErrorController';
import { NotFoundController } from './lib/controllers/NotFoundController';
Comment on lines +4 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also look into TS-ifying these exports?

A typical structure is e.g.: https://github.com/comunica/traqula/blob/main/packages/algebra-transformations-1-1/lib/index.ts


import { Datasource } from './lib/datasources/Datasource';
import { EmptyDatasource } from './lib/datasources/EmptyDatasource';
import { IndexDatasource } from './lib/datasources/IndexDatasource';
import { MemoryDatasource } from './lib/datasources/MemoryDatasource';

import { DatasourceRouter } from './lib/routers/DatasourceRouter';
import { PageRouter } from './lib/routers/PageRouter';

import { ErrorHtmlView } from './lib/views/error/ErrorHtmlView';
import { ErrorRdfView } from './lib/views/error/ErrorRdfView';
import { ForbiddenHtmlView } from './lib/views/forbidden/ForbiddenHtmlView';
import { NotFoundHtmlView } from './lib/views/notfound/NotFoundHtmlView';
import { NotFoundRdfView } from './lib/views/notfound/NotFoundRdfView';
import { HtmlView } from './lib/views/HtmlView';
import { RdfView } from './lib/views/RdfView';
import { View } from './lib/views/View';
import { ViewCollection } from './lib/views/ViewCollection';

import { runCli, runCustom } from './lib/CliRunner';
import { LinkedDataFragmentsServer } from './lib/LinkedDataFragmentsServer';
import { LinkedDataFragmentsServerWorker } from './lib/LinkedDataFragmentsServerWorker';
import { UrlData } from './lib/UrlData';
import * as Util from './lib/Util';

const Core = {
controllers: {
AssetsController,
Controller,
DereferenceController,
ErrorController,
NotFoundController,
},
datasources: {
Datasource,
EmptyDatasource,
IndexDatasource,
MemoryDatasource,
},
routers: {
DatasourceRouter,
PageRouter,
},
views: {
error: {
ErrorHtmlView,
ErrorRdfView,
},
forbidden: {
ForbiddenHtmlView,
},
notfound: {
NotFoundHtmlView,
NotFoundRdfView,
},
HtmlView,
RdfView,
View,
ViewCollection,
},
runCli,
runCustom,
LinkedDataFragmentsServer,
LinkedDataFragmentsServerWorker,
UrlData,
Util,
};

// Re-exports this package's shared type definitions, so consumers can pull
// them from the package root instead of reaching into `@ldf/core/lib/types`
namespace Core {
export type QueryFeatures = Types.QueryFeatures;
export type Query = Types.Query;
export type DatasourceRegistry = Types.DatasourceRegistry;
export type Pushable<T> = Types.Pushable<T>;
export type DatasourceOptions = Types.DatasourceOptions;
export type RenderDone = Types.RenderDone;
export type LdfRequest = Types.LdfRequest;
export type LdfResponse = Types.LdfResponse;
export type RouterRequest = Types.RouterRequest;
export type ControllerOptions = Types.ControllerOptions;
export type ViewSettings = Types.ViewSettings;
export type WorkerConfig = Types.WorkerConfig;
}

export = Core;
Loading