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

[docs] Type check docs in CI #4560

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ jobs:
- checkout
- install_js
- run:
name: Check Typescript types
command: pnpm check-types
name: Tests TypeScript definitions
command: pnpm typescript
Comment on lines -99 to +100
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy script naming convention from main repo.

environment:
NODE_OPTIONS: --max-old-space-size=3584
test_static:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { AppProvider } from '@toolpad/core/AppProvider';
import { SignInPage } from '@toolpad/core/SignInPage';
import { createTheme } from '@mui/material/styles';

import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext';
import { getDesignTokens, inputsCustomizations } from './customTheme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type AuthResponse,
} from '@toolpad/core/SignInPage';
import { createTheme } from '@mui/material/styles';
// @ts-ignore
import { useColorSchemeShim } from 'docs/src/modules/components/ThemeContext';
Comment on lines +9 to 10
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source are in JavaScript.

import { getDesignTokens, inputsCustomizations } from './customTheme';

Expand Down
38 changes: 0 additions & 38 deletions docs/data/toolpad/core/components/sign-in-page/auth.js

This file was deleted.

39 changes: 0 additions & 39 deletions docs/data/toolpad/core/components/sign-in-page/auth.ts

This file was deleted.

8 changes: 6 additions & 2 deletions docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));

const require = createRequire(import.meta.url);

// @ts-ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const withDocsInfra = require('@mui/monorepo/docs/nextConfigDocsInfra');

const pkg = require('../package.json');
const { findPages } = require('./src/modules/utils/find');
const { findPages } = require('./src/modules/utils/find.js');

const WORKSPACE_ROOT = path.resolve(currentDirectory, '../');
const MONOREPO_PATH = path.resolve(currentDirectory, '../node_modules/@mui/monorepo');
Expand Down Expand Up @@ -44,6 +44,7 @@ export default withDocsInfra({
TOOLPAD_CORE_VERSION: toolpadCorePkg.version,
TOOLPAD_STUDIO_VERSION: toolpadStudioPkg.version,
},
// @ts-ignore
webpack: (config, options) => {
return {
...config,
Expand Down Expand Up @@ -126,11 +127,14 @@ export default withDocsInfra({
const pages = findPages();
const map = {};

// @ts-ignore
function traverse(pages2, userLanguage) {
const prefix = userLanguage === 'en' ? '' : `/${userLanguage}`;

// @ts-ignore
pages2.forEach((page) => {
if (!page.children) {
// @ts-ignore
map[`${prefix}${page.pathname.replace(/^\/api-docs\/(.*)/, '/api/$1')}`] = {
page: page.pathname,
query: {
Expand Down
9 changes: 5 additions & 4 deletions docs/src/components/landing/ToolpadAuthDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import Paper from '@mui/material/Paper';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
// @ts-ignore
import DemoSandbox from 'docs/src/modules/components/DemoSandbox';
import { AppProvider } from '@toolpad/core/AppProvider';
import { SignInPage, type AuthProvider } from '@toolpad/core/SignInPage';
Expand All @@ -16,9 +17,9 @@ const providers = [
{ id: 'facebook', name: 'Facebook' },
];

const signIn = async (provider) => {
try {
await signIn(provider.id);
const signIn = async (provider) => {
try {
await signIn(provider.id);
} catch (error) {
// Handle errors
}
Expand All @@ -28,7 +29,7 @@ export default function OAuthSignInPage() {
return (
<AppProvider>
<SignInPage signIn={signIn} providers={providers} />
</AppProvider>
</AppProvider>
);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/landing/ToolpadDashboardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import Paper from '@mui/material/Paper';
import { HighlightedCode } from '@mui/docs/HighlightedCode';

import DashboardIcon from '@mui/icons-material/Dashboard';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import BarChartIcon from '@mui/icons-material/BarChart';
Expand All @@ -10,6 +9,7 @@ import LayersIcon from '@mui/icons-material/Layers';
import { AppProvider, type Navigation, type Router } from '@toolpad/core/AppProvider';
import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import { PageContainer } from '@toolpad/core/PageContainer';
// @ts-ignore
import DemoSandbox from 'docs/src/modules/components/DemoSandbox';
import Grid from '@mui/material/Grid2';
import { styled } from '@mui/material/styles';
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/landing/ToolpadPageContainerDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import Frame from 'docs/src/components/action/Frame';
import Paper from '@mui/material/Paper';
// @ts-ignore
import DemoSandbox from 'docs/src/modules/components/DemoSandbox';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
import { AppProvider } from '@toolpad/core/AppProvider';
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules/components/Examples/FeaturedExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Visibility from '@mui/icons-material/Visibility';
import CodeRoundedIcon from '@mui/icons-material/CodeRounded';
import OpenInNewRoundedIcon from '@mui/icons-material/OpenInNewRounded';
import { useTheme } from '@mui/material/styles';
// @ts-ignore
import { sxChip } from 'docs/src/modules/components/AppNavDrawerItem';
import type { Example } from './types';

Expand Down
14 changes: 2 additions & 12 deletions docs/src/modules/components/SchemaReference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,6 @@ function JsonSchemaNameValueDisplay({
);
}

interface HeadingProps {
hash: string;
level: 'h2' | 'h3';
title: string;
}

function Heading({ hash, level: Level, title }: HeadingProps) {
return <SectionTitle title={title} id={hash} level={Level} />;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

interface JsonSchemaDisplayProps {
name: string;
hash: string;
Expand All @@ -461,7 +451,7 @@ interface JsonSchemaDisplayProps {
function JsonSchemaDisplay({ name, hash, schema, idPrefix = '' }: JsonSchemaDisplayProps) {
return (
<React.Fragment>
<Heading hash={hash} level="h3" title={name} />
<SectionTitle hash={hash} level="h3" title={name} />
<Typography>{schema.description}</Typography>
<Wrapper>
<JsonSchemaValueDisplay schema={schema} idPrefix={idPrefix} />
Expand Down Expand Up @@ -525,7 +515,7 @@ export default function SchemaReference(props: SchemaReferenceProps) {
{toc.map((tocNode) => {
return (
<React.Fragment key={tocNode.hash}>
<Heading hash={tocNode.hash} level="h2" title={tocNode.text} />
<SectionTitle hash={tocNode.hash} level="h2" title={tocNode.text} />
<Typography>{tocNode.introduction}</Typography>
{tocNode.children.map((tocItemNode) => {
invariant(typeof tocItemNode.content !== 'boolean', 'Invalid top level schema');
Expand Down
1 change: 0 additions & 1 deletion docs/src/modules/utils/babel-plugin-jsx-preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
const fs = require('fs');

const pluginName = 'babel-plugin-jsx-preview';
Expand Down
10 changes: 4 additions & 6 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "bundler",
"allowJs": true,
"isolatedModules": true,
/* files are emitted by babel */
"noEmit": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"esModuleInterop": true,
"types": ["react", "node"],
"incremental": true,
"noImplicitAny": true,
"jsx": "preserve"
"moduleResolution": "bundler"
},
"include": ["docs-env.d.ts", "pages/**/*", "src/**/*", "data/**/*", "next.config.mjs"],
"exclude": ["docs/.next", "docs/export"]
"include": ["next-env.d.ts", "next.config.mjs", "docs-env.d.ts", "src", "pages/**/*.ts*", "data"],
"exclude": ["docs/.next", "docs/export", "node_modules"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"test:browser": "FORCE_COLOR=1 pnpm run -r test:browser",
"test:argos": "node ./scripts/pushArgos.mjs",
"test": "lerna run test --stream",
"check-types": "lerna run --concurrency 1 check-types",
"typescript": "lerna run --concurrency 1 --no-bail typescript",
"typescript:ci": "lerna run --concurrency 2 --no-bail typescript",
"toolpad-studio": "node --enable-source-maps packages/toolpad-studio/cli.mjs",
"jsonSchemas": "tsx ./scripts/docs/generateJsonSchemas.ts",
"monorepo:update": "tsx ./scripts/updateMonorepo.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-toolpad-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"check-types": "tsc --noEmit",
"typescript": "tsc --noEmit",
"test": "vitest run"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"build:types": "tsc -b tsconfig.build.json",
"predev": "pnpm clean",
"dev": "mkdir -p build && concurrently \"pnpm build:stable --watch\" \"pnpm build:types --watch --preserveWatchOutput\" \"pnpm build:copy-files\"",
"check-types": "pnpm build:types && tsc --noEmit",
"typescript": "pnpm build:types && tsc --noEmit",
"test": "vitest run --coverage",
"test:dev": "vitest",
"test:browser": "vitest run --browser.enabled",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-studio-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"check-types": "tsup && tsc --noEmit",
"typescript": "tsup && tsc --noEmit",
"build:types": "tsc --declaration --emitDeclarationOnly"
},
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-studio-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"check-types": "tsup && tsc --noEmit"
"typescript": "tsup && tsc --noEmit"
},
"bugs": {
"url": "https://github.com/mui/toolpad/issues"
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"fix": "prettier --write .",
"build:cli": "tsup",
"dev:cli": "tsup --watch",
"check-types": "tsup && tsc --noEmit",
"typescript": "tsup && tsc --noEmit",
"test": "vitest run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"check-types": "tsup && tsc --noEmit",
"typescript": "tsup && tsc --noEmit",
"test": "vitest run --coverage"
},
"bugs": {
Expand Down
Loading