-
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] TS2612 - Property 'ID' will overwrite the base property in '_cuidAspect<TBase> (v0.23.0) #274
Comments
Thank you @geert-janklaps for the mentioned fix. @cap-js/asyncapi: 1.0.2 |
Hi Geert-Jan, thanks for reporting this issue! With the following tsconfig.json: {
"compilerOptions": {
"paths": {
"#cds-models/*": [
"./@cds-models/*"
]
},
"rootDir": "./",
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"sourceMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": false,
"skipLibCheck": true,
"useDefineForClassFields": true
}
} and this minimal model: using { cuid } from '@sap/cds/common';
namespace my.bookshop;
entity Book: cuid {
key ID : Integer;
title : String;
author : String;
stock : Integer;
price : Decimal(9,2);
} I am running Could you please expand your sample with a minimal model I can reproduce the issue with? Thanks! Best, |
I can support here as well as I also had this issue. Steps to reproduce cds init typerbug
cds add typescript
npm install The generated tsconfig file provided by CAP looks like this {
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"sourceMap": true,
"allowJs": true,
"paths": {
"#cds-models/*": [
"./@cds-models/*/index.ts"
]
}
}
} Now add the following schema.cds to your db folder
Now create a service.cds in the srv folder
Run build cds-ts build Output Error: @cds-models/ManagedService/index.ts(7,5): error TS2612: Property 'createdAt' will overwrite the base property in '_managedAspect<TBase>.managed & object'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.
@cds-models/ManagedService/index.ts(11,5): error TS2612: Property 'createdBy' will overwrite the base property in '_managedAspect<TBase>.managed & object'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.
@cds-models/ManagedService/index.ts(12,5): error TS2612: Property 'modifiedAt' will overwrite the base property in '_managedAspect<TBase>.managed & object'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.
@cds-models/ManagedService/index.ts(16,5): error TS2612: Property 'modifiedBy' will overwrite the base property in '_managedAspect<TBase>.managed & object'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration. |
Hi Christian, thanks for adding the reproduction steps! I can now see the error and will look into it. Best, |
Hi everyone, I have prepared an experimental fix for this issue that will add the Best, |
Hi @daogrady , |
Hi Christian, sorry, I forgot to attach the relevant wiki page. Best, |
@daogrady I try to do it this week. |
Hi Christian, sorry to hear and hope you recover quickly! 😕 I have merged the fix in question for a related problem. So I will for now assume the problem is fixed (with the next release). If you notice the problem resurfacing, feel free to reopen this issue. Best, |
Is there an existing issue for this?
Nature of Your Project
TypeScript
Current Behavior
As of release v0.23.0 generated types using cuidAspect produce TS2612 errors. (strict tsconfig)
This issue might be closely related to #273.
The fix however is different, in the compilerOptions you need to disable useDefineForClassFields.
Expected Behavior
The generated types not to produce errors in strict mode
Steps To Reproduce
No response
Environment
Repository Containing a Minimal Reproducible Example
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: