Skip to content

Commit

Permalink
fix: Ensure resolution of core types goes through typesVersions resol…
Browse files Browse the repository at this point in the history
…ution (#4576)
  • Loading branch information
rschristian authored Dec 1, 2024
1 parent f7ac8dc commit daa124a
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 11 deletions.
4 changes: 3 additions & 1 deletion compat/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as preact from '../src';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import * as preact from 'preact';

export function createRoot(container: preact.ContainerNode): {
render(children: preact.ComponentChild): void;
Expand Down
4 changes: 3 additions & 1 deletion compat/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as _hooks from '../../hooks';
import * as preact from '../../src';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import * as preact from 'preact';
import { JSXInternal } from '../../src/jsx';
import * as _Suspense from './suspense';
import * as _SuspenseList from './suspense-list';
Expand Down
4 changes: 3 additions & 1 deletion compat/src/suspense-list.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, ComponentChild, ComponentChildren } from '../../src';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import { Component, ComponentChild, ComponentChildren } from 'preact';

//
// SuspenseList
Expand Down
4 changes: 3 additions & 1 deletion compat/src/suspense.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component, ComponentChild, ComponentChildren } from '../../src';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import { Component, ComponentChild, ComponentChildren } from 'preact';

//
// Suspense/lazy
Expand Down
7 changes: 5 additions & 2 deletions compat/test/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"noEmit": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"paths": {
"preact": ["../../../src/index.d.ts"]
}
},
"include": ["./**/*.ts", "./**/*.tsx"]
}
}
4 changes: 3 additions & 1 deletion hooks/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ErrorInfo, PreactContext, Ref, RefObject } from '../..';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import { ErrorInfo, PreactContext, Ref, RefObject } from 'preact';

type Inputs = ReadonlyArray<unknown>;

Expand Down
6 changes: 4 additions & 2 deletions jsx-runtime/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export { Fragment } from '../../';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
export { Fragment } from 'preact';
import {
ComponentType,
ComponentChild,
ComponentChildren,
VNode,
Attributes
} from '../../';
} from 'preact';
import { JSXInternal } from '../../src/jsx';

export function jsx(
Expand Down
4 changes: 3 additions & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as preact from './index';
// Intentionally not using a relative path to take advantage of
// the TS version resolution mechanism
import * as preact from 'preact';

export enum HookType {
useState = 1,
Expand Down
2 changes: 1 addition & 1 deletion src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
FunctionComponent,
PreactDOMAttributes,
VNode
} from './index';
} from 'preact';

type Defaultize<Props, Defaults> =
// Distribute over unions
Expand Down

0 comments on commit daa124a

Please sign in to comment.