Skip to content

Commit

Permalink
Merge pull request #24531 from storybookjs/norbert/fix-24487-angular-…
Browse files Browse the repository at this point in the history
…tsconfig

Angular: Reduce the warnings from `ts-loader` via stricter list of `includes`
  • Loading branch information
valentinpalkovic committed Dec 12, 2023
2 parents 8a9dce4 + 2ee9a72 commit 593a774
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"resolveJsonModule": true
},
"exclude": ["../src/test.ts", "../src/**/*.spec.ts"],
"include": ["../src/**/*", "./preview.ts"],
"include": ["../src/**/*.stories.*", "./preview.ts"],
"files": ["./typings.d.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"resolveJsonModule": true
},
"exclude": ["../src/test.ts", "../src/**/*.spec.ts"],
"include": ["../src/**/*", "./preview.ts"],
"include": ["../src/**/*.stories.*", "./preview.ts"],
"files": ["./typings.d.ts"]
}
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 593a774

Please sign in to comment.