Skip to content

fix(apps): resolve strict-mode TypeScript errors in packages/apps/src#40187

Closed
d-gubert wants to merge 19 commits intofeat/apps-engine-split--pr2c-flip-the-switchfrom
feat/apps-engine-split--pr3-strict-mode
Closed

fix(apps): resolve strict-mode TypeScript errors in packages/apps/src#40187
d-gubert wants to merge 19 commits intofeat/apps-engine-split--pr2c-flip-the-switchfrom
feat/apps-engine-split--pr3-strict-mode

Conversation

@d-gubert
Copy link
Copy Markdown
Member

@d-gubert d-gubert commented Apr 16, 2026

Proposed changes (including videos or screenshots)

Fix all TypeScript strict-mode errors introduced when the packages/apps package was configured with strict: true, noImplicitReturns, and noUnusedParameters. Errors included:

  • Map.get() used without non-null assertion after has()/set() guards
  • Catch clause variables typed as unknown (now cast explicitly)
  • Missing return statements in all code paths (TS7030)
  • Unused parameters renamed with _ prefix
  • Optional chaining / nullish coalescing for possibly-undefined values
  • Bridge do* methods returning undefined as unknown as T for denied perms

Issue(s)

Steps to test or reproduce

Further comments

Related to the "Apps-Engine split" stack:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 16, 2026

⚠️ No Changeset found

Latest commit: 83f9262

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 934518e9-33c0-4c63-b5b3-ad5ae1ec961c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 16, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Adds `src/definition/version.ts` which reads the package version via
`resolveJsonModule` and exports it as `ENGINE_VERSION`.

Replaces `AppPackageParser.getEngineVersion()` — which resolved the
version by traversing the filesystem relative to `__dirname` — with a
direct import of `ENGINE_VERSION`. This removes the assumption that
`package.json` lives at a predictable relative path, which will break
when `AppPackageParser` moves to a different package during the
apps-engine split.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

fix(apps-engine): fix ENGINE_VERSION runtime path in compiled output

Static `import { version } from '../../package.json'` resolves correctly
during TypeScript compilation (source lives at src/definition/) but the
emitted require('../../package.json') exits the package root at runtime
once compiled to definition/version.js (outDir='.', rootDir='./src').

Switching to require('../package.json') — which is the correct path
relative to the compiled output — and bypassing TypeScript's compile-time
module resolution avoids the path mismatch entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d-gubert and others added 17 commits April 22, 2026 15:45
Copies src/server/ from @rocket.chat/apps-engine verbatim, then
rewrites all relative definition/ imports to package imports
(`@rocket.chat/apps-engine/definition/...`).

apps-engine still contains its server code at this point — this is an
additive copy only. The deletion happens in a later PR once @packages/apps
is confirmed working independently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copies src/client/ (AppClientManager, AppsEngineUIHost, AppsEngineUIClient)
from @rocket.chat/apps-engine, rewriting relative definition/ imports to
package imports.

This code is a known rough edge: browser-side UI host logic does not
semantically belong in a server orchestration package. It is consolidated
here for pragmatic simplicity during the apps-engine split. A future
@rocket.chat/apps-client package is tracked in the TODO comment added to
src/client/index.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copies deno-runtime/ verbatim from @rocket.chat/apps-engine.

The import map in deno.jsonc still points to ./../src/ which is only
valid in the current location (apps-engine). Making the import map
location-independent (using a runtime-generated map) is handled in a
dedicated follow-up PR to keep the diff focused.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… directly

The old src/bridges/IListenerBridge.ts used module augmentation
(`declare module '@rocket.chat/apps-engine/server/bridges'`) to extend
IListenerBridge with core-typings-specific overloads. Now that
IListenerBridge lives in this package, the augmentation workaround is no
longer needed. The extra overload signatures are merged directly into
src/server/bridges/IListenerBridge.ts and the augmentation file is deleted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- package.json: add all runtime deps from apps-engine (msgpack, adm-zip,
  esbuild, jose, semver, etc.), deno-related devDeps (npm-run-all,
  rimraf, ts-node), build/test scripts, and include deno-runtime/ and
  scripts/ in published files
- tsconfig.json: enable experimentalDecorators and emitDecoratorMetadata
  required by the incoming server code
- turbo.json: declare build outputs (dist/, deno-runtime/, .deno-cache/)
- scripts/deno-cache.js: copied from apps-engine; validates Deno version
  and pre-caches deno-runtime dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Installs runtime and dev dependencies added to @rocket.chat/apps in the
previous commit (adm-zip, debug, esbuild, jose, jsonrpc-lite,
lodash.clonedeep, msgpack, semver, stack-trace, uuid, npm-run-all,
rimraf, ts-node).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…lass

room.ts previously imported `AppManager` from the server layer
(`@rocket.chat/apps-engine/server/AppManager.ts`) solely to type the
private [PrivateManager] symbol field that backs the deprecated
`usernames` getter. This created a cross-boundary import from the
Deno subprocess into the Node.js host.

Replace with a minimal inline `IRoomManager` interface that exposes only
the one method actually called:
  getBridges().getInternalBridge().doGetUsernamesOfRoomById()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…th at spawn time

The static deno.jsonc used `"@rocket.chat/apps-engine/": "./../src/"` — a
relative path that only works when deno-runtime/ and apps-engine/src/ are
siblings in the same package. Now that deno-runtime lives in @rocket.chat/apps
and the definition source lives in @rocket.chat/apps-engine, the relative path
would resolve to the wrong location.

Solution: generate a `deno_runtime.jsonc` into the temp directory before each
Deno subprocess spawn. The generated config copies all settings from the static
deno.jsonc and injects `@rocket.chat/apps-engine/` as an absolute `file:` URL
resolved via `require.resolve('@rocket.chat/apps-engine/package.json')`. This
works correctly in any environment (monorepo dev, Meteor bundle, CI) without
assumptions about directory layout.

Changes:
- `getAppsEngineSourceDir()`: resolves apps-engine src/ via require.resolve
- `generateRuntimeDenoConfig()`: reads static config, injects resolved path,
  writes to tempDir/deno_runtime.jsonc, returns the path
- `spawnProcess()`: calls generateRuntimeDenoConfig, uses the generated config,
  adds appsEngineSrcDir to --allow-read
- deno.jsonc: remove the now-redundant static @rocket.chat/apps-engine/ entry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… local server/ paths

These files previously re-exported AppManager, AppBridges, and
AppMetadataStorage from @rocket.chat/apps-engine/server/. Now that
server/ lives in this package, the imports are updated to local paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…/apps/server/

Hard-cut all import paths from `@rocket.chat/apps-engine/server/*` to
`@rocket.chat/apps/server/*` across apps/meteor. Covers bridges, storage,
managers, marketplace, and service files (50 files, purely mechanical rename).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…/apps/client/

Hard-cut all import paths from `@rocket.chat/apps-engine/client/*` to
`@rocket.chat/apps/client/*` across apps/meteor (5 files).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…et.chat/apps

IAppsEngineService imported IGetAppsFilter and IAppStorageItem from
@rocket.chat/apps-engine/server/ — server internals that now live in
@rocket.chat/apps. Update imports and swap the devDependency accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
OAuth2Client, IExternalComponentRoomInfo/UserInfo, and the room query
option types (GetMessagesOptions, GetRoomsFilters, GetRoomsOptions) were
defined in server/ or client/ but were imported by definition/ files.
Move them into the definition layer so the public API is self-contained.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Strip @rocket.chat/apps-engine down to the definition layer only.
All runtime code (AppManager, bridges, compiler, deno-runtime, etc.)
has already been moved to @rocket.chat/apps in previous commits.

Updates package.json, tsconfig.json, and turbo.json to reflect the
narrower scope (definition/**  and lib/** outputs only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… definition

GetMessagesOptions, GetRoomsFilters, GetRoomsOptions, and
GetMessagesSortableFields are now canonical in
@rocket.chat/apps-engine/definition/rooms/IGetMessagesOptions —
import them from there and re-export for downstream consumers.

OAuth2Client is now canonical in
@rocket.chat/apps-engine/definition/oauth2/OAuth2Client — replace the
duplicate copy with a re-export.

Also add typesVersions to @rocket.chat/apps/package.json so that
consumers using moduleResolution: "node" can resolve ./server/* and
./client/* subpath imports without needing node16/bundler resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@d-gubert d-gubert force-pushed the feat/apps-engine-split--pr2c-flip-the-switch branch from 1cc12df to c9af208 Compare April 22, 2026 20:22
Fix all TypeScript strict-mode errors introduced when the packages/apps
package was configured with strict: true, noImplicitReturns, and
noUnusedParameters. Errors included:
- Map.get() used without non-null assertion after has()/set() guards
- Catch clause variables typed as unknown (now cast explicitly)
- Missing return statements in all code paths (TS7030)
- Unused parameters renamed with _ prefix
- Optional chaining / nullish coalescing for possibly-undefined values
- Bridge do* methods returning undefined as unknown as T for denied perms

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@d-gubert d-gubert force-pushed the feat/apps-engine-split--pr3-strict-mode branch from 2a94144 to 83f9262 Compare April 22, 2026 20:24
@d-gubert d-gubert force-pushed the feat/apps-engine-split--pr2c-flip-the-switch branch from c9af208 to ac06baf Compare April 27, 2026 22:44
@d-gubert
Copy link
Copy Markdown
Member Author

Closing due to conflicts. We'll relax the tsconfig on packages/apps for now to speed up this transition.

@d-gubert d-gubert closed this Apr 27, 2026
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.

1 participant