Valentin Palkovic 7a0a1c7bd5 Angular: Add support for Angular's output signals
Support the new signal-based output function in Angular 17.3 and upwards in Storybook's helper types as StoryObj or StoryFn. I also ensured that TypeScript doesn't complain in Angular versions that don't support this feature.

Please be aware, that controls might not reflect the proper types when Signals are used. For component and property analysis, we are relying on Compodoc. Compodoc doesn't support the new output signal yet.
2024-03-18 09:05:14 +01:00

17 lines
824 B
JavaScript

/**
* This postbuild fix is needed to add a ts-ignore to the generated public-types.d.ts file.
* The AngularCore.InputSignal and AngularCore.InputSignalWithTransform types do not exist in Angular
* versions < 17.2. In these versions, the unresolved types will error and prevent Storybook from starting/building.
* This postbuild script adds a ts-ignore statement above the unresolved types to prevent the errors.
*/
const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, '../dist/client/public-types.d.ts');
const fileContent = fs.readFileSync(filePath, 'utf8');
const newContent = fileContent
.replaceAll(/(type AngularInputSignal)/g, '// @ts-ignore\n$1')
.replaceAll(/(type AngularOutputEmitterRef)/g, '// @ts-ignore\n$1');
fs.writeFileSync(filePath, newContent, 'utf8');