Skip to content

Commit ce530d0

Browse files
authored
[babel-plugin] various TypeScript fixes (#1298)
1 parent 85d556f commit ce530d0

File tree

4 files changed

+119
-5
lines changed

4 files changed

+119
-5
lines changed

packages/@stylexjs/babel-plugin/src/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ declare function processStylexRules(
3939
config?:
4040
| boolean
4141
| {
42-
useLayers?: boolean,
43-
enableLTRRTLComments?: boolean,
44-
legacyDisableLayers?: boolean,
45-
}
42+
useLayers?: boolean;
43+
enableLTRRTLComments?: boolean;
44+
legacyDisableLayers?: boolean;
45+
},
4646
): string;
4747
export type StyleXTransformObj = Readonly<{
4848
(): PluginObj;
4949
withOptions: typeof stylexPluginWithOptions;
5050
processStylexRules: typeof processStylexRules;
5151
}>;
5252
declare const $$EXPORT_DEFAULT_DECLARATION$$: StyleXTransformObj;
53-
export = $$EXPORT_DEFAULT_DECLARATION$$;
53+
export default $$EXPORT_DEFAULT_DECLARATION$$;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*
8+
*/
9+
10+
export type TRawValue = number | string | ReadonlyArray<number | string>;
11+
export type TStyleValue = null | TRawValue;
12+
export type TNestableStyleValue = TStyleValue | PrimitiveRawStyles;
13+
export type RawStyles = Readonly<{ [$$Key$$: string]: TNestableStyleValue }>;
14+
export type PrimitiveRawStyles = Readonly<{
15+
[$$Key$$: string]: TNestableStyleValue;
16+
}>;
17+
export type InjectableStyle = {
18+
readonly priority: number;
19+
readonly ltr: string;
20+
readonly rtl: null | string;
21+
};
22+
export type InjectableConstStyle = {
23+
readonly priority: number;
24+
readonly ltr: string;
25+
readonly rtl: null | string;
26+
readonly constKey: string;
27+
readonly constVal: string | number;
28+
};
29+
export type StyleRule = [string, string, InjectableStyle];
30+
export type CompiledStyles = Readonly<{
31+
[$$Key$$: string]:
32+
| null
33+
| string
34+
| Readonly<{ [$$Key$$: string]: null | string }>;
35+
}>;
36+
export type FlatCompiledStyles = Readonly<
37+
{ [$$Key$$: string]: string | null } & { $$css: true | string }
38+
>;
39+
export type StyleXOptions = Readonly<{
40+
classNamePrefix: string;
41+
debug: null | undefined | boolean;
42+
definedStylexCSSVariables?: { [key: string]: unknown };
43+
dev: boolean;
44+
enableDebugClassNames?: null | undefined | boolean;
45+
enableDebugDataProp?: null | undefined | boolean;
46+
enableDevClassNames?: null | undefined | boolean;
47+
enableFontSizePxToRem?: null | undefined | boolean;
48+
enableMediaQueryOrder?: null | undefined | boolean;
49+
enableLegacyValueFlipping?: null | undefined | boolean;
50+
enableLogicalStylesPolyfill?: null | undefined | boolean;
51+
enableLTRRTLComments?: null | undefined | boolean;
52+
enableMinifiedKeys?: null | undefined | boolean;
53+
styleResolution:
54+
| 'application-order'
55+
| 'property-specificity'
56+
| 'legacy-expand-shorthands';
57+
test: boolean;
58+
}>;
59+
export type MutableCompiledNamespaces = { [key: string]: FlatCompiledStyles };
60+
export type CompiledNamespaces = Readonly<MutableCompiledNamespaces>;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*
8+
*/
9+
10+
import type { InjectableStyle, StyleXOptions } from './common-types';
11+
declare function styleXCreateTheme(
12+
themeVars: {
13+
readonly __varGroupHash__: string;
14+
readonly [$$Key$$: string]: string;
15+
},
16+
variables: {
17+
readonly [$$Key$$: string]:
18+
| string
19+
| { default: string; readonly [$$Key$$: string]: string };
20+
},
21+
options?: StyleXOptions,
22+
): [
23+
{ $$css: true } & { readonly [$$Key$$: string]: string },
24+
{ [$$Key$$: string]: InjectableStyle },
25+
];
26+
export default styleXCreateTheme;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
*
8+
*/
9+
10+
import type { InjectableStyle, StyleXOptions } from './common-types';
11+
import type { VarsConfig } from './stylex-vars-utils';
12+
type VarsKeysWithStringValues<Vars extends VarsConfig> = Readonly<{
13+
[$$Key$$ in keyof Vars]: string;
14+
}>;
15+
type VarsObject<Vars extends VarsConfig> = Readonly<
16+
Omit<VarsKeysWithStringValues<Vars>, keyof { __varGroupHash__: string }> & {
17+
__varGroupHash__: string;
18+
}
19+
>;
20+
declare function styleXDefineVars<Vars extends VarsConfig>(
21+
variables: Vars,
22+
options: Readonly<
23+
Omit<Partial<StyleXOptions>, keyof { exportId: string }> & {
24+
exportId: string;
25+
}
26+
>,
27+
): [VarsObject<Vars>, { [$$Key$$: string]: InjectableStyle }];
28+
export default styleXDefineVars;

0 commit comments

Comments
 (0)