File tree 6 files changed +111
-6
lines changed
horizontal-slider-vdom/src
6 files changed +111
-6
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,37 @@ jobs:
107
107
- run :
108
108
name : Type checking
109
109
command : yarn run test:types
110
+ test_types_no_jsx_implementation :
111
+ << : *defaults
112
+ steps :
113
+ - checkout
114
+ - run : *install_yarn_version
115
+ - restore_cache : *restore_yarn_cache
116
+ - run :
117
+ name : Remove React types
118
+ command : |
119
+ # This simulates @types/react and preact not being installed
120
+ node -e "
121
+ fs.writeFileSync(
122
+ './package.json',
123
+ JSON.stringify(
124
+ Object.assign(require('./package.json'), {
125
+ resolutions: {
126
+ '@types/react': 'file:./scripts/empty-package',
127
+ 'preact': 'file:./scripts/empty-package',
128
+ },
129
+ }),
130
+ null,
131
+ 2
132
+ )
133
+ );
134
+ "
135
+ # not running the scripts, as they should not run for *-react
136
+ yarn install --ignore-scripts
137
+ - run :
138
+ name : Type checking
139
+ # Using build:types instead of test:types, as it's easier to run only the VDOM types
140
+ command : yarn build:types --scope '@algolia/*-{shared,vdom}'
110
141
test_unit :
111
142
<< : *defaults
112
143
steps :
@@ -152,10 +183,11 @@ workflows:
152
183
ci :
153
184
jobs :
154
185
- build
186
+ - test_types
187
+ - test_types_no_jsx_implementation
155
188
- test_lint :
156
189
requires :
157
190
- build
158
- - test_types
159
191
- test_unit :
160
192
requires :
161
193
- build
Original file line number Diff line number Diff line change @@ -7,6 +7,23 @@ import {
7
7
Renderer ,
8
8
} from '@algolia/ui-components-shared' ;
9
9
10
+ // Basic types to allow this file to compile without a JSX implementation.
11
+ // This is a minimal subset of the actual types from the `JSX` namespace.
12
+ interface IntrinsicElement extends JSX . IntrinsicAttributes {
13
+ children ?: ComponentChildren ;
14
+ className ?: string ;
15
+ }
16
+
17
+ declare global {
18
+ // eslint-disable-next-line @typescript-eslint/no-namespace
19
+ namespace JSX {
20
+ interface IntrinsicElements {
21
+ span : IntrinsicElement ;
22
+ mark : IntrinsicElement ;
23
+ }
24
+ }
25
+ }
26
+
10
27
type HighlightPartProps = {
11
28
children : ComponentChildren ;
12
29
classNames : Partial < HighlightClassNames > ;
Original file line number Diff line number Diff line change 1
1
/** @jsx createElement */
2
- import { cx , Renderer } from '@algolia/ui-components-shared' ;
2
+ import { ComponentChildren , cx , Renderer } from '@algolia/ui-components-shared' ;
3
3
4
4
import {
5
5
FrameworkProps ,
@@ -8,6 +8,45 @@ import {
8
8
RecordWithObjectID ,
9
9
} from './types' ;
10
10
11
+ // basic types to allow this file to compile without @types /react or preact
12
+ // this is a minimal subset of the actual types, coming from the JSX namespace
13
+ interface IntrinsicElement extends JSX . IntrinsicAttributes {
14
+ children ?: ComponentChildren ;
15
+
16
+ className ?: string ;
17
+ id ?: string ;
18
+ tabIndex ?: string | number ;
19
+ title ?: string ;
20
+
21
+ onClick ?: ( event : MouseEvent ) => void ;
22
+ onKeyDown ?: ( event : KeyboardEvent ) => void ;
23
+ onScroll ?: ( event : MouseEvent ) => void ;
24
+ }
25
+
26
+ interface IntrinsicSvgElement extends IntrinsicElement {
27
+ width ?: string ;
28
+ height ?: string ;
29
+ viewBox ?: string ;
30
+ fill ?: string ;
31
+ fillRule ?: string ;
32
+ clipRule ?: string ;
33
+ d ?: string ;
34
+ }
35
+
36
+ declare global {
37
+ // eslint-disable-next-line @typescript-eslint/no-namespace
38
+ namespace JSX {
39
+ interface IntrinsicElements {
40
+ div : IntrinsicElement ;
41
+ button : IntrinsicElement ;
42
+ ol : IntrinsicElement ;
43
+ li : IntrinsicElement ;
44
+ svg : IntrinsicSvgElement ;
45
+ path : IntrinsicSvgElement ;
46
+ }
47
+ }
48
+ }
49
+
11
50
let lastHorizontalSliderId = 0 ;
12
51
13
52
export function generateHorizontalSliderId ( ) {
Original file line number Diff line number Diff line change
1
+ /* eslint-disable @typescript-eslint/no-empty-interface */
1
2
// Prevents type errors when using without a JSX implementation
2
3
// (e.g., Angular InstantSearch via InstantSearch.js)
3
4
// In the future, this may be fixable by accepting a JSX generic to every type
7
8
declare global {
8
9
// eslint-disable-next-line @typescript-eslint/no-namespace
9
10
namespace JSX {
10
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
- interface Element { }
12
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
+ interface IntrinsicAttributes {
12
+ key ?: string | number | null ;
13
+ ref ?: unknown ;
14
+ }
15
+
16
+ interface ElementChildrenAttribute {
17
+ children : ComponentChildren ;
18
+ }
19
+
20
+ interface Element extends VNode { }
13
21
interface IntrinsicElements { }
14
22
}
15
23
}
@@ -59,7 +67,10 @@ export type ComponentProps<
59
67
60
68
export type VNode < TProps = any > = {
61
69
type : any ;
62
- props : TProps & { children : ComponentChildren ; key ?: any } ;
70
+ props : TProps & {
71
+ children : ComponentChildren ;
72
+ key ?: string | number | null ;
73
+ } ;
63
74
} ;
64
75
65
76
export type Renderer = {
Original file line number Diff line number Diff line change
1
+ // This file allows `empty-package` to be an `@types/` package
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " empty-package" ,
3
+ "version" : " 0.0.0" ,
4
+ "description" : " An empty package used in tests as an alias for @types/"
5
+ }
You can’t perform that action at this time.
0 commit comments