-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type errors in older versions of Angular
- Loading branch information
1 parent
0c93db1
commit 762a61f
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |