Skip to content

[BUG] TS2339: Property 'on' does not exist on type. / Symlink to sap__types is missing #318

@sebastien-savalle

Description

@sebastien-savalle

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

We observed a weird behavior when migrating to cds 8 and cds-types 0.7.0.

Custom handler cannot be registered properly. A typescript error is thrown.

error TS2339: Property 'on' does not exist on type 'AdminService'.

import { ApplicationService } from '@sap/cds';

export default class AdminService extends ApplicationService {
  init() {
    this.on('health', () => {
      return { status: 'UP' };
    });
  }
}

But it works when this is cast to ApplicationService.

import { ApplicationService } from '@sap/cds';

export default class AdminService extends ApplicationService {
  init() {
    (this as ApplicationService).on('health', () => {
      return { status: 'UP' };
    });
  }
}

Expected Behavior

No response

References

https://pages.github.tools.sap/cap/docs/tools/cds-typer#typer-top-level-imports

Versions

backend https://github.com/<your/repo>
@cap-js/asyncapi 1.0.2
@cap-js/audit-logging 0.8.1
@cap-js/cds-types 0.7.0
@cap-js/db-service 1.14.1
@cap-js/hana 1.4.1
@cap-js/openapi 1.0.7
@cap-js/sqlite 1.7.6
@cap-js/telemetry 1.0.1
@sap/cds 8.4.0
@sap/cds-compiler 5.4.0
@sap/cds-dk 8.4.0
@sap/cds-dk (global) 8.4.0
@sap/cds-fiori 1.2.7
@sap/cds-foss 5.0.1
@sap/cds-mtxs 2.3.0
@sap/eslint-plugin-cds 3.0.4
Node.js v20.15.1

Anything else? Logs?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions