mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Fix type errors in older versions of Angular
This commit is contained in:
parent
0c93db1272
commit
762a61f2df
@ -115,6 +115,7 @@
|
||||
},
|
||||
"builders": "dist/builders/builders.json",
|
||||
"bundler": {
|
||||
"post": "./scripts/postbuild.js",
|
||||
"tsConfig": "tsconfig.build.json"
|
||||
},
|
||||
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
|
||||
|
17
code/frameworks/angular/scripts/postbuild.js
vendored
Normal file
17
code/frameworks/angular/scripts/postbuild.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 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(
|
||||
/(\[K in keyof T\]: T\[K\] extends AngularCore.InputSignal)/g,
|
||||
' // @ts-ignore\n $1'
|
||||
);
|
||||
fs.writeFileSync(filePath, newContent, 'utf8');
|
Loading…
x
Reference in New Issue
Block a user