Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular: Reduce the warnings from ts-loader via stricter list of includes #24531

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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