Skip to content

Commit 1f7294a

Browse files
authored
Merge pull request #7972 from QwikDev/fix-css-properties
fix(repl): CSS types
2 parents 70a8bea + 108e7ee commit 1f7294a

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

packages/docs/src/repl/ui/monaco.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getColorPreference } from '../../components/theme-toggle/theme-toggle';
77
import { bundled, getDeps, getNpmCdnUrl } from '../bundler/bundled';
88
import { isServer } from '@builder.io/qwik';
99
import { QWIK_PKG_NAME_V1, QWIK_PKG_NAME_V2 } from '../repl-constants';
10+
import cssTypes from '../../../../qwik/node_modules/csstype/index.d.ts?raw';
1011

1112
export const initMonacoEditor = async (
1213
containerElm: any,
@@ -213,6 +214,7 @@ export const addQwikLibs = async (version: string) => {
213214
'/node_modules/@builder.io/qwik/dist/jsx-runtime.d.ts'
214215
);
215216
typescriptDefaults.addExtraLib(CLIENT_LIB);
217+
typescriptDefaults.addExtraLib(cssTypes, '/node_modules/csstype/index.d.ts');
216218
};
217219

218220
const loadDeps = async (pkgVersion: string) => {

packages/qwik/src/core/render/jsx/types/jsx-types.unit.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { assertType, describe, expectTypeOf, test } from 'vitest';
2+
import { component$, type PropsOf, type PublicProps } from '../../../component/component.public';
23
import { $, type PropFunction } from '../../../qrl/qrl.public';
3-
import type { EventHandler, QRLEventHandlerMulti } from './jsx-qwik-attributes';
4+
import type { JSX } from '../jsx-runtime';
5+
import type { QwikHTMLElements, QwikSVGElements, Size } from './jsx-generated';
46
import type { FunctionComponent, JSXOutput } from './jsx-node';
7+
import type { EventHandler, JSXChildren, QRLEventHandlerMulti } from './jsx-qwik-attributes';
58
import type { QwikIntrinsicElements } from './jsx-qwik-elements';
6-
import type { JSXChildren } from './jsx-qwik-attributes';
7-
import { component$, type PropsOf, type PublicProps } from '../../../component/component.public';
8-
import type { QwikHTMLElements, QwikSVGElements, Size } from './jsx-generated';
9-
import type { JSX } from '../jsx-runtime';
109

1110
describe('types', () => {
1211
// Note, these type checks happen at compile time. We don't need to call anything, so we do ()=>()=>. We just need to
@@ -327,4 +326,21 @@ describe('types', () => {
327326

328327
expectTypeOf<PropsOf<17>>().toEqualTypeOf<never>();
329328
});
329+
330+
test('CSSProperties', () => () => {
331+
return (
332+
<div
333+
style={{
334+
color: 'red',
335+
backgroundColor: 'blue',
336+
// Using a CSS variable
337+
'--my-variable': '10px',
338+
// Using a number value
339+
marginTop: 10,
340+
// Using a string value
341+
padding: '5px',
342+
}}
343+
/>
344+
);
345+
});
330346
});

0 commit comments

Comments
 (0)