File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // dtslint expects an `index.d.ts` in the test folder.
Original file line number Diff line number Diff line change 1+ import { styled } from '..' ;
2+
3+ const Button = styled . button `` ;
4+
5+ // Should not require `children` for intrinsic elements on React 17 projects.
6+ Button ( { } ) ;
7+ < Button /> ;
8+ < Button > ok</ Button > ;
Original file line number Diff line number Diff line change 1+ declare module 'react/jsx-runtime' {
2+ const Fragment : unknown ;
3+ function jsx ( type : unknown , props : unknown , key ?: unknown ) : unknown ;
4+ function jsxs ( type : unknown , props : unknown , key ?: unknown ) : unknown ;
5+ }
6+
7+ declare module 'react/jsx-dev-runtime' {
8+ const Fragment : unknown ;
9+ function jsxDEV (
10+ type : unknown ,
11+ props : unknown ,
12+ key : unknown ,
13+ isStaticChildren : boolean ,
14+ source : unknown ,
15+ self : unknown
16+ ) : unknown ;
17+ }
Original file line number Diff line number Diff line change 1+ // Minimal React 17-like type surface for dtslint.
2+ // It intentionally does NOT export a module-level `JSX` namespace.
3+
4+ declare namespace React {
5+ type ElementType = unknown ;
6+
7+ interface CSSProperties {
8+ [ key : string ] : unknown ;
9+ }
10+
11+ interface FunctionComponent < P = Record < string , unknown > > {
12+ ( props : P & { children ?: unknown } ) : unknown ;
13+ }
14+
15+ function createElement ( ...args : unknown [ ] ) : unknown ;
16+ }
17+
18+ export = React ;
19+ export as namespace React ;
20+
21+ declare global {
22+ namespace JSX {
23+ interface IntrinsicElements {
24+ button : Record < string , unknown > ;
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ./tsconfig.json"
3+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "module" : " commonjs" ,
4+ "lib" : [" es6" ],
5+ "target" : " ES2015" ,
6+ "jsx" : " react-jsx" ,
7+ "noImplicitAny" : true ,
8+ "noImplicitThis" : true ,
9+ "strictNullChecks" : true ,
10+ "strictFunctionTypes" : true ,
11+ "esModuleInterop" : true ,
12+ "allowSyntheticDefaultImports" : true ,
13+ "types" : [],
14+ "noEmit" : true ,
15+ "baseUrl" : " ./" ,
16+ "paths" : {
17+ "react" : [" ./stubs/react17.d.ts" ],
18+ "react/jsx-runtime" : [" ./stubs/jsx-runtime.d.ts" ],
19+ "react/jsx-dev-runtime" : [" ./stubs/jsx-runtime.d.ts" ]
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 5353 "build:declarations" : " tsc --emitDeclarationOnly --outDir types" ,
5454 "build:dist" : " tsup --format cjs,esm" ,
5555 "test" : " jest --config ../../jest.config.js --rootDir ." ,
56- "test:dts" : " dtslint --localTs ../../node_modules/typescript/lib __dtslint__" ,
56+ "test:dts" : " dtslint --localTs ../../node_modules/typescript/lib __dtslint__ && dtslint --localTs ../../node_modules/typescript/lib __dtslint-react17__ " ,
5757 "typecheck" : " tsc --noEmit --composite false" ,
5858 "watch" : " pnpm build:dist --watch & pnpm build:declarations --watch"
5959 },
Original file line number Diff line number Diff line change @@ -107,25 +107,25 @@ interface IProps {
107107 style ?: Record < string , string > ;
108108}
109109
110- // React <19
111110declare global {
112111 // eslint-disable-next-line @typescript-eslint/no-namespace
113112 namespace JSX {
114113 interface IntrinsicElements { }
115114 }
116115}
117116
118- // React >=19
119- declare module 'react' {
120- // eslint-disable-next-line @typescript-eslint/no-namespace
121- namespace JSX {
122- interface IntrinsicElements { }
123- }
124- }
125-
126117let idx = 0 ;
127118
128- type IntrinsicElements = React . JSX . IntrinsicElements & JSX . IntrinsicElements ;
119+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
120+ type ReactIntrinsicElements = typeof import ( 'react' ) extends {
121+ JSX : { IntrinsicElements : infer T } ;
122+ }
123+ ? T
124+ : never ;
125+
126+ type IntrinsicElements = [ ReactIntrinsicElements ] extends [ never ]
127+ ? JSX . IntrinsicElements
128+ : ReactIntrinsicElements ;
129129
130130// Components with props are not allowed
131131function styled (
Original file line number Diff line number Diff line change 77 " node"
88 ],
99 },
10+ "include" : [" src" ],
1011 "references" : [{ "path" : " ../core" }]
1112}
You can’t perform that action at this time.
0 commit comments