You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it helps with a fix: The problem occurs because of enumVal in ./lib/components/enum.js. With the minimal example I've provided, the enumType is an array ['my.bookshop.Qualities', 'quality'] so the value is not escaped anymore.
For anyone coming across this, I've quick-fixed this locally with a script that changes the "faulty" line of code to escape any value, independent of enumType.
constfs=require('fs');constpath=require('path');// Path to the target fileconstfilePath=path.resolve(__dirname,'./node_modules/@cap-js/cds-typer/lib/components/enum.js');// Read the filefs.readFile(filePath,'utf8',(err,data)=>{if(err){console.error('Error reading file:',err);return;}// Replace the specific line of codeconstupdatedData=data.replace(/enumType === 'cds\.String' \? JSON\.stringify\(`\$\{value \?\? key\}`\) : value/g,'JSON.stringify(`${value ?? key}`)');// Check if a change was madeif(updatedData!==data){// Write the updated content back to the filefs.writeFile(filePath,updatedData,'utf8',(writeErr)=>{if(writeErr){console.error('Error writing to file:',writeErr);}else{console.log('File successfully updated.');}});}else{console.log('No changes were made, pattern not found.');}});
that I call in the postinstall script of the package.json:
Is there an existing issue for this?
Nature of Your Project
TypeScript
Current Behavior
When using an unmanaged association to a
String enum
, the enum values are not quoted in the generated types. This causesCannot find name
errors:Expected Behavior
It would be expected to have the strings quoted:
Steps To Reproduce
cds init bookshop --add typescript,typer
npm i
cds
fiel to generate typesEnvironment
Repository Containing a Minimal Reproducible Example
https://github.com/MarvinWeitz/cds-typer-quote-bug
Anything else?
No response
The text was updated successfully, but these errors were encountered: