Closed scmx closed 1 year ago
FYI: Here's the patch I've doing to the resulting file Maybe some of this should end up in a pull request.
function fixTypesFileInconsistencies(typesFile: string) {
const lines = fs.readFileSync(typesFile, 'utf-8').split('\n');
const newLines = lines.flatMap((line) => {
if (line === 'export interface AssetStoryblok {') {
return [line, `\tfocus?: null;`, `\tfieldtype?: 'asset';`];
}
if (line === `\t_uid: string;`) {
return [line, `\t_editable?: string;`];
}
if (line === `\t[k: string]: any;`) {
return [];
}
return [line];
});
fs.writeFileSync(typesFile, newLines.join('\n'));
}
[k: string]: any
typing. This typing has caused many issues and we were very happy to get rid of it_editable?: string
typing for preview mode[k: string]: any
Hi 👋 ! Nice library. Been using it for a while. Here's some suggested changes:
1. Return promise from storyblokToTypescript node api
Otherwise the node api can't really be used when you can't know when it completes.
2. Change return
Promise<string>[]
resolve tsStringChange result
Promise<void>
intoPromise<string[]>
, returning the tsString output.3. Skip write file if path null
Skip write the tsString to path location if empty string is passed in as path. Default value is a string so it will continue to save by default.
The first change is the most interesting one for me. I am currently working around all three things by: