Skip to content

Commit

Permalink
Fix Angular sandbox generation
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Dec 12, 2023
1 parent 791ba23 commit 2ee9a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { expect } from '@storybook/jest';
export default {
component: globalThis.Components.Pre,
play: async ({ canvasElement, name }: PlayFunctionContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toEqual({
await expect(
JSON.parse(within(canvasElement as HTMLPreElement).getByTestId('pre').innerText)
).toEqual({
name,
});
},
Expand Down
10 changes: 9 additions & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ async function prepareAngularSandbox(cwd: string, templateName: string) {

// Set tsConfig compilerOptions

const tsConfigPath = join(cwd, 'tsconfig.json');
const tsConfigPath = join(cwd, '.storybook', 'tsconfig.json');
const tsConfigContent = readFileSync(tsConfigPath, { encoding: 'utf-8' });
// This does not preserve comments, but that shouldn't be an issue for sandboxes
const tsConfigJson = JSON5.parse(tsConfigContent);
Expand All @@ -620,6 +620,14 @@ async function prepareAngularSandbox(cwd: string, templateName: string) {
tsConfigJson.compilerOptions.noPropertyAccessFromIndexSignature = false;
tsConfigJson.compilerOptions.jsx = 'react';
tsConfigJson.compilerOptions.skipLibCheck = true;
tsConfigJson.compilerOptions.noImplicitAny = false;
tsConfigJson.compilerOptions.strict = false;
tsConfigJson.include = [
...tsConfigJson.include,
'../template-stories/**/*.stories.ts',
// This is necessary since template stories depend on globalThis.components, which Typescript can't look up automatically
'../src/stories/**/*',
];

if (templateName === 'Angular CLI (Version 15)') {
tsConfigJson.compilerOptions.paths = {
Expand Down

0 comments on commit 2ee9a72

Please sign in to comment.