Skip to content

TS Test Conversion - #222

Open
Michiel-VandeVelde wants to merge 25 commits into
LinkedDataFragments:masterfrom
Michiel-VandeVelde:TS-test-conversion
Open

Michiel-VandeVelde wants to merge 25 commits into
LinkedDataFragments:masterfrom
Michiel-VandeVelde:TS-test-conversion

Conversation

@Michiel-VandeVelde

Copy link
Copy Markdown
Contributor

No description provided.

@Michiel-VandeVelde Michiel-VandeVelde changed the title Ts Test Conversion TS Test Conversion Sep 1, 2026

@jitsedesmet jitsedesmet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

First round of comments/ opinions :)

Comment thread package.json Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread .github/workflows/ci.yml Outdated
Comment thread packages/core/test/controllers/AssetsController-test.ts Outdated
Comment thread packages/core/test/controllers/AssetsController-test.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread packages/core/test/controllers/AssetsController-test.ts Outdated
…op InstanceType

- Fold typecheck into postinstall, drop separate CI step (per review)
- Migrate controller tests off real ports to light-my-request injection,
  keep listen() for LinkedDataFragmentsServer-test.ts (relies on response
  'error' events as a recoverable signal, incompatible with light-my-request)
- Make DummyServer a class exposing next/error directly, drop
  SpiedController/Partial workaround
- Replace InstanceType<typeof X> & Partial<SpiedController> patterns with
  direct class imports across controller test files
- Remove unused supertest/@types/supertest dependency
…ping, narrow HttpResponse

- Add Router interface to core/lib/types.ts, have DatasourceRouter, PageRouter
  and QuadPatternRouter implement it explicitly instead of each router-consuming
  file declaring its own local duck-typed interface
- Widen RouterRequest.url.pathname to string | null, matching Node's own
  url.parse()/UrlObject convention, removing the need for callers to coerce
  null to undefined
- Apply reviewer's suggested { url: parsed } simplification in test-helpers.ts,
  now unblocked by the pathname widening above
- Make test-helpers.ts's HttpResponse extend IncomingMessage instead of
  Readable, mirroring the existing StreamCapture/ServerResponse pattern
jitsedesmet and others added 4 commits September 24, 2026 08:39
Adopts the TypeScript layout used in Comunica: a single tsconfig.json that
builds the shipped code (yarn build is bare tsc, run from postinstall), plus
tsconfig.eslint.json, which exists only so typescript-eslint's type-aware
rules have a program containing the test files and the Vitest config. The
build/typecheck split (tsconfig.build.json, tsconfig.typecheck.json) and the
typecheck script are gone. "module" stays "commonjs", as this monorepo is
CommonJS throughout: no package.json in it declares "type": "module".

skipLibCheck stays off, which is what forced most of the dependency work:

- Under TypeScript 5, "module": "commonjs" implied node10 resolution, which
  cannot follow package.json "exports", so Vitest's own type definitions
  failed to resolve their subpath imports; that is what the deleted
  tsconfig.typecheck.json worked around. TypeScript 6 resolves "commonjs"
  through the "exports" map, so a single module setting now serves both the
  build and the test tooling. TypeScript 6 also deprecates
  esModuleInterop=false, so interop is now on; the emitted requires gain the
  usual __importStar helpers.
- The Vitest config no longer computes a root directory from import.meta.url,
  which a CommonJS program cannot type-check. It resolves compiled output back
  to its sources through a Vite plugin instead, as Comunica does. It keeps its
  .mts extension so that Vite still loads it as a module, rather than as the
  CommonJS its ESM syntax would warn about.
- immutable@3.8.2, reached through componentsjs 4 -> rdf-parse 1 ->
  @comunica/core 1, declares its namespaces with the old `declare module Foo`
  syntax that TypeScript 6 rejects. Pinned to ^5 through resolutions.
- The RDF typing layer moves off the deprecated, undeclared @types/rdf-js:
  @rdfjs/types ^2 is now an explicit dependency of every package that uses
  it, and the rdf-js imports point there. rdf-string, sparqljson-parse,
  jsonld-streaming-parser/serializer, rdfa-streaming-parser and rdf-object
  are realigned on that same major. rdf-string stays on 1.x on purpose: 2.x
  builds language literals through the RDF 1.2 `{ language, direction }` form,
  which n3 1.x's data factory does not accept.
- n3 has never shipped type declarations; the types came from a stale lock
  entry. @types/n3 is now an explicit devDependency and the n3 ranges are
  unified, with n3, rdf-string and asynciterator declared in the packages
  that were using them without saying so.

componentsjs stays on ^4. Version 6 type-checks cleanly but rejects our
componentsjs-4-era component definitions at startup (optional parameters
without a default need a ParameterRangeUndefined range), and componentsjs 4
in turn cannot use rdf-parse >= 2. ESLint likewise stays on 7 with
typescript-eslint 5, which still lints cleanly against TypeScript 6;
upgrading to Comunica's versions surfaces ~96 findings that need rule
decisions first.

Verified: zero type errors in both programs, no output emitted next to the
test sources, lint clean, 597 tests passing, and the server still answers a
Turtle-datasource config with byte-identical TriG.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@jitsedesmet jitsedesmet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good stuff @Michiel-VandeVelde ! :D

Comment thread tsconfig.json Outdated
Comment thread tsconfig.eslint.json Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread test/test-helpers.ts Outdated
Comment thread packages/core/test/views/View-test.ts Outdated
Comment thread packages/core/test/routers/DatasourceRouter-test.ts Outdated
Comment thread packages/core/test/controllers/NotFoundController-test.ts
Comment thread packages/core/test/controllers/NotFoundController-test.ts Outdated
Comment thread packages/core/test/controllers/DereferenceController-test.ts
…rtedFeatures option, dedupe SPARQL URL assertion

- createRequest() takes an optional headers argument instead of requiring
  callers to mutate request.headers after construction
- QuadPatternFragmentsController-test.ts uses Datasource's real
  supportedFeatureList constructor parameter instead of assigning
  datasource.supportedFeatures post-construction, which silently bypassed
  the class's own Object.freeze()
- Extract the repeated SPARQL request-URL parse-and-assert pattern in
  SparqlDatasource-test.ts into a single expectRequestedQuery() helper
Comment thread test/test-helpers.ts
Comment on lines +56 to +59
// Query has no index signature; this lets the test tables below use an
// arbitrary 'a' field as a stand-in for "pre-existing data that should survive".
export type TestQuery = Query & { a?: number };
export type QueryParamsTestCase = [string, string, string, TestQuery, TestQuery];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are no tests here. Maybe we can clean up the tests this came from some more?

Neither these types seem to make any sense here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants