Skip to content

Commit 313ad1f

Browse files
committed
[code-infra] Convert remaining @mui/system .js+.d.ts pairs to TypeScript (part 2)
Completes the @mui/system TypeScript conversion started in mui#48578. Collapses the 9 remaining hand-written .js + .d.ts pairs into single .ts/.tsx source (tsc-emitted declarations) and renames the standalone CSSProperties.d.ts: - RtlProvider/index, colorManipulator, createStyled, createTheme/{createTheme,index}, styleFunctionSx/{styleFunctionSx,index}, cssVars/createCssVarsProvider - CSSProperties.d.ts -> CSSProperties.ts (type-only csstype import) Pragmatic conversions follow the ts-package-migration skill: as any / as unknown as T casts Babel strips (never restructuring runtime), Pattern A propTypes (Identifier LHS) so the production guard survives, and private_createBreakpoints kept at runtime but @internal (stripInternal) so the published type surface is unchanged. Tooling/config updates required by the conversion: - scripts/coreTypeScriptProjects.js: point the api-docs-builder's @mui/system entry at src/index.ts (was src/index.d.ts, which the conversion removes) so pnpm proptypes (test_static) can build the project. - @mui/material-pigment-css imports @mui/system/RtlProvider (now .tsx) and builds via tsc; added the @mui/system project reference to its tsconfig.build.json. - exports map: drop redundant ./createTheme + ./styleFunctionSx entries (wildcard covers them as .ts), keep explicit ./RtlProvider pointing at index.tsx. Documented non-breaking type-surface deltas: unstable_resolveBreakpointValues is now in the root .d.ts (real runtime export consumed by @mui/lab Masonry, missing from the hand-written index.d.ts); names the old index.d.ts claimed as values via export * but index.js never exported at runtime (breakpointKeys, getStyleValue2, extendSxProp, prepareCssVars, ...) are now correctly type-only at the root. Verified: @mui/system build + typescript + test (1112 pass) + proptypes + module augmentation, and downstream builds of @mui/material, @mui/lab, @mui/material-pigment-css.
1 parent bff3c4a commit 313ad1f

25 files changed

Lines changed: 734 additions & 876 deletions

packages/mui-material-pigment-css/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"rootDir": "./src"
1010
},
1111
"include": ["./src/**/*.ts*"],
12-
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]
12+
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"],
13+
"references": [{ "path": "../mui-system/tsconfig.build.json" }]
1314
}

packages/mui-system/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,8 @@
8282
"node": ">=14.0.0"
8383
},
8484
"exports": {
85-
".": "./src/index.js",
86-
"./createTheme": "./src/createTheme/index.js",
87-
"./RtlProvider": "./src/RtlProvider/index.js",
88-
"./styleFunctionSx": "./src/styleFunctionSx/index.js",
85+
".": "./src/index.ts",
86+
"./RtlProvider": "./src/RtlProvider/index.tsx",
8987
"./*": "./src/*/index.ts"
9088
}
9189
}

packages/mui-system/src/CSSProperties.d.ts renamed to packages/mui-system/src/CSSProperties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as CSS from 'csstype';
1+
import type * as CSS from 'csstype';
22

33
/**
44
* All non-vendor-prefixed CSS properties. (Also allows `number` in order to support CSS-in-JS libs,

packages/mui-system/src/RtlProvider/index.d.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/mui-system/src/RtlProvider/index.js renamed to packages/mui-system/src/RtlProvider/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
import * as React from 'react';
33
import PropTypes from 'prop-types';
44

5-
const RtlContext = React.createContext();
5+
interface RtlProviderProps {
6+
children?: React.ReactNode;
7+
value?: boolean | undefined;
8+
}
9+
10+
const RtlContext = React.createContext<boolean | undefined>(undefined);
611

7-
function RtlProvider({ value, ...props }) {
12+
function RtlProvider({ value, ...props }: RtlProviderProps) {
813
return <RtlContext.Provider value={value ?? true} {...props} />;
914
}
1015

1116
RtlProvider.propTypes = {
1217
children: PropTypes.node,
1318
value: PropTypes.bool,
14-
};
19+
} as any;
1520

1621
export const useRtl = () => {
1722
const value = React.useContext(RtlContext);
1823
return value ?? false;
1924
};
2025

21-
export default RtlProvider;
26+
export default RtlProvider as React.FC<RtlProviderProps>;

packages/mui-system/src/colorManipulator/colorManipulator.d.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)