-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Regression] Incorrect types generated with composition of many #225
Comments
There seems to be a second issue with regards to composition of many. Having: entity Test.UserInterfaces {
key id : String;
testProperty1 : Composition of many {
test : String;
};
testProperty2 : Composition of many {
test : String;
};
}
service TestService {
entity UserInterfaces as projection on Test.UserInterfaces;
} yields the following: [...]
export function _UserInterfaceAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
return class UserInterface extends Base {
id?: string;
usageStatus?: __.Composition.of.many<__.DeepRequired<sap.test.TestService.UserInterface>['usageStatus']>;
intentMapping?: __.Composition.of.many<__.DeepRequired<sap.test.TestService.UserInterface>['intentMapping']>;
static readonly actions: Record<never, never>
};
}
export class UserInterface extends _UserInterfaceAspect(__.Entity) {}
Object.defineProperty(UserInterface, 'name', { value: 'sap.test.TestService.UserInterfaces' })
export class UserInterfaces extends Array<UserInterface> {$count?: number}
Object.defineProperty(UserInterfaces, 'name', { value: 'sap.test.TestService.UserInterfaces' })
export namespace UserInterfaces {
export function _usageStatuAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
return class usageStatu extends Base {
up_?: __.Association.to<_sap_test_Test.UserInterface>;
up__id?: string;
contextContent?: string | null;
static readonly actions: Record<never, never>
};
}
export class usageStatu extends _usageStatuAspect(__.Entity) {}
Object.defineProperty(usageStatu, 'name', { value: 'sap.test.Test.UserInterfaces.usageStatus' })
export class UserInterfaces extends Array<usageStatu> {$count?: number}
Object.defineProperty(UserInterfaces, 'name', { value: 'sap.test.Test.UserInterfaces.usageStatus' })
export function _intentMappingAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
return class intentMapping extends Base {
up_?: __.Association.to<_sap_test_Test.UserInterface>;
up__id?: string;
externalLinkOpenInNewTab?: boolean | null;
static readonly actions: Record<never, never>
};
}
export class intentMapping extends _intentMappingAspect(__.Entity) {}
Object.defineProperty(intentMapping, 'name', { value: 'sap.test.Test.UserInterfaces.intentMapping' })
export class UserInterfaces extends Array<intentMapping> {$count?: number}
Object.defineProperty(UserInterfaces, 'name', { value: 'sap.test.Test.UserInterfaces.intentMapping' })
} With the pluralized versions appearing to be named as the containing entity: [...]
export class usageStatu extends _usageStatuAspect(__.Entity) {}
Object.defineProperty(usageStatu, 'name', { value: 'sap.test.Test.UserInterfaces.usageStatus' })
export class UserInterfaces extends Array<usageStatu> {$count?: number}
Object.defineProperty(UserInterfaces, 'name', { value: 'sap.test.Test.UserInterfaces.usageStatus' })
[...]
export class intentMapping extends _intentMappingAspect(__.Entity) {}
Object.defineProperty(intentMapping, 'name', { value: 'sap.test.Test.UserInterfaces.intentMapping' })
export class UserInterfaces extends Array<intentMapping> {$count?: number}
Object.defineProperty(UserInterfaces, 'name', { value: 'sap.test.Test.UserInterfaces.intentMapping' })
[...] Which a) seems to incorrect and b) yields the type error |
The bottom one seems to be due to: cds-typer/lib/components/resolver.js Line 315 in 3120af3
Here it's running as {
typeName: undefined,
singular: 'usageStatu',
plural: 'UserInterfaces'
}
{
'typeInfo.csn.name': '[...].UserInterfaces.usageStatus'
}
{ 'typeInfo.plainName': 'UserInterfaces' } {
typeName: undefined,
singular: 'intentMapping',
plural: 'UserInterfaces'
},
{
'typeInfo.csn.name': '[...].UserInterfaces.intentMapping'
}
{ 'typeInfo.plainName': 'UserInterfaces' } So the fallback here (plainName) seems to not work properly. // Edit: I assume it boils down to cds-typer/lib/components/resolver.js Line 173 in 3120af3
Due to |
I am facing the same issue. The issue is reproducible for >= 0.20.0. |
This issue has not been updated in a while. If it is still relevant, please comment on it to keep it open. The issue will be closed soon if it remains inactive. |
I'm facing the same issue. I'd like to add a few information blocks to the thread:
As it was written before me it is reproducable in older versions, as well as in the new 0.23.0. I was just learning CAP with ts, but I'd like to add my use case as well, maybe it will help resolve this issue. I have the schema.cds file
I have more compositions in the entity, and I have other entities that I haven't included just for the sake of simplicity.
And the service.ts that looks like this:
All this results the following in the cds-models/AdminService/index.ts
cds-models/AdminService/index.ts
When trying to transpile this file, I'm getting a bunch of errors such as:
|
Is there an existing issue for this?
Nature of Your Project
TypeScript
Current Behavior
(Could be related to earlier behavior in #183)
Given a definition such as:
Leads in the
@cds-models/TestService/index.ts
to:With
<__.DeepRequired<TestService
< ---Cannot find namespace 'TestService'.ts(2503)
Expected Behavior
Would've expected the generated types be correct.
Steps To Reproduce
See above
Environment
Repository Containing a Minimal Reproducible Example
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: