Skip to content

Commit 39589d9

Browse files
committed
Export everything in type-portability example apps
1 parent c9e74ab commit 39589d9

File tree

33 files changed

+94
-69
lines changed

33 files changed

+94
-69
lines changed

examples/type-portability/bundler/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PollingToggles } from './features/polling/PollingToggles'
55
import { PostsManager } from './features/posts/PostsManager'
66
import { TimeList } from './features/time/TimeList'
77

8-
function App() {
8+
export function App() {
99
return (
1010
<div className="App">
1111
<div className="row">
@@ -20,7 +20,7 @@ function App() {
2020
<PollingToggles />
2121
</div>
2222
</div>
23-
<div></div>
23+
<div />
2424
<div>
2525
<Routes>
2626
<Route path="/" element={<TimeList />} />

examples/type-portability/bundler/src/app/services/counter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { apiSlice } from './api'
22

3-
interface CountResponse {
3+
export interface CountResponse {
44
count: number
55
}
66

examples/type-portability/bundler/src/app/services/posts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface Post {
77
fetched_at: string
88
}
99

10-
type PostsResponse = Post[]
10+
export type PostsResponse = Post[]
1111

1212
export interface User {
1313
first_name: string

examples/type-portability/bundler/src/app/services/times.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { apiSlice } from './api'
22

3-
interface TimeResponse {
3+
export interface TimeResponse {
44
time: string
55
}
66

examples/type-portability/bundler/src/features/bundleSplitting/Post.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// import the file that injects "post" to make sure it has been loaded
22
import { postApi } from '../../app/services/post'
33

4-
function assert(condition: any, msg = 'Generic Assertion'): asserts condition {
4+
export function assert(
5+
condition: any,
6+
msg = 'Generic Assertion',
7+
): asserts condition {
58
if (!condition) {
69
throw new Error(`Assertion failed: ${msg}`)
710
}
811
}
912

10-
const Post = ({ id }: { id: number }) => {
13+
export const Post = ({ id }: { id: number }) => {
1114
assert(postApi.endpoints.getPost?.useQuery, 'Endpoint `getPost` not loaded!')
1215

1316
const { data, error } = postApi.endpoints.getPost.useQuery(id)
@@ -20,4 +23,5 @@ const Post = ({ id }: { id: number }) => {
2023
<h1>{data.name}</h1>
2124
)
2225
}
26+
2327
export default Post

examples/type-portability/bundler/src/features/bundleSplitting/PostsList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react'
22
import { Post } from '.'
33
import { postsApi } from '../../app/services/posts'
44

5-
const PostsList = () => {
5+
export const PostsList = () => {
66
const { data, error } = postsApi.endpoints.getPosts.useQuery()
77
const [selected, select] = useState<number | undefined>()
88

@@ -23,4 +23,5 @@ const PostsList = () => {
2323
</>
2424
)
2525
}
26+
2627
export default PostsList

examples/type-portability/bundler/src/features/polling/PollingToggles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
updatePolling,
88
} from './pollingSlice'
99

10-
const PollingToggleButton = ({
10+
export const PollingToggleButton = ({
1111
enabled,
1212
onClick,
1313
children,

examples/type-portability/bundler/src/features/polling/pollingSlice.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import type { PayloadAction } from '@reduxjs/toolkit'
22
import { createSlice } from '@reduxjs/toolkit'
33
import type { RootState } from '../../app/store'
44

5-
type PollingConfig = {
5+
export type PollingConfig = {
66
enabled: boolean
77
interval: number
88
}
99

10-
type SliceState = {
10+
export type SliceState = {
1111
enabled: boolean
1212
apps: {
1313
[key: string]: PollingConfig
1414
}
1515
}
1616

17-
const initialState: SliceState = {
17+
export const initialState: SliceState = {
1818
enabled: true,
1919
apps: {
2020
counters: {
@@ -32,7 +32,7 @@ const initialState: SliceState = {
3232
},
3333
}
3434

35-
type PollingAppKey = keyof (typeof initialState)['apps']
35+
export type PollingAppKey = keyof (typeof initialState)['apps']
3636

3737
export const pollingSlice = createSlice({
3838
name: 'polling',

examples/type-portability/bundler/src/features/posts/PostDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '../../app/services/posts'
1010
import { selectGlobalPollingEnabled } from '../polling/pollingSlice'
1111

12-
const EditablePostName = ({
12+
export const EditablePostName = ({
1313
name: initialName,
1414
onUpdate,
1515
onCancel,
@@ -51,7 +51,7 @@ const EditablePostName = ({
5151
)
5252
}
5353

54-
const PostJsonDetail = ({ id }: { id: number }) => {
54+
export const PostJsonDetail = ({ id }: { id: number }) => {
5555
const { data: post } = useGetPostQuery(id)
5656

5757
return (

examples/type-portability/bundler/src/features/posts/PostsManager.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { logout, selectIsAuthenticated } from '../auth/authSlice'
1313
import { PostDetail } from './PostDetail'
1414

15-
const AddPost = () => {
15+
export const AddPost = () => {
1616
const initialValue = { name: '' }
1717
const [post, setPost] = useState<Partial<Post>>(initialValue)
1818
const [addPost, { isLoading }] = useAddPostMutation()
@@ -52,7 +52,7 @@ const AddPost = () => {
5252
)
5353
}
5454

55-
const PostListItem = ({
55+
export const PostListItem = ({
5656
data: { name, id },
5757
onSelect,
5858
}: {
@@ -68,7 +68,7 @@ const PostListItem = ({
6868
)
6969
}
7070

71-
const PostList = () => {
71+
export const PostList = () => {
7272
const { data: posts, isLoading } = useGetPostsQuery()
7373
const navigate = useNavigate()
7474

0 commit comments

Comments
 (0)