Skip to content

Commit

Permalink
fix: types from ts upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Nov 16, 2022
1 parent 6154121 commit 7ede187
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -84,7 +84,7 @@ jobs:
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov;
chmod +x codecov;
yarn run test:coverage --ci --maxWorkers=4 --coverageReporters=text-lcov > ./lcov.info;
yarn run test:coverage --ci --maxWorkers=3 --coverageReporters=text-lcov > ./lcov.info;
if [ "$CODECOV_TOKEN" != "" ]; then
./codecov -t ${CODECOV_TOKEN} < ./lcov.info || true;
else
Expand Down
12 changes: 10 additions & 2 deletions docs/core/upgrade/upgrading-to-7.md
Expand Up @@ -4,7 +4,7 @@ title: Upgrading from 6 to 7
import BeforeAfterTabs from '@site/src/components/BeforeAfterTabs';
import PkgTabs from '@site/src/components/PkgTabs';

<PkgTabs pkgs="rest-hooks@7 @rest-hooks/react @rest-hooks/redux @rest-hooks/test@8" upgrade />
<PkgTabs pkgs="rest-hooks@7 @rest-hooks/react@6 @rest-hooks/redux@6 @rest-hooks/test@9" upgrade />

[@rest-hooks/react](https://www.npmjs.com/package/@rest-hooks/react) is now a peerDependency
so be sure to install it. The [rest-hooks](https://www.npmjs.com/package/rest-hooks) will eventually
Expand Down Expand Up @@ -61,7 +61,7 @@ function MyComponent() {
}
```

## Test @8
## Test @9

Old-style fixtures using FetchShape were removed here.

Expand All @@ -88,3 +88,11 @@ const fixtures = [
},
];
```

## Preparing for the future

Once you have successfully upgraded, you can try converting all 'rest-hooks' imports to '@rest-hooks/react'.
This will become the recommended way to consume rest hooks when using React. The 'rest-hooks' package will
still work but eventually remove any additions.

- `import {} from 'rest-hooks'` -> `import {} from '@rest-hooks/react'`
2 changes: 1 addition & 1 deletion examples/github-app/package.json
Expand Up @@ -64,6 +64,7 @@
"@rest-hooks/endpoint": "^3.0.1",
"@rest-hooks/graphql": "^0.3.1",
"@rest-hooks/hooks": "^3.0.7",
"@rest-hooks/react": "workspace:^",
"@rest-hooks/rest": "^6.0.1",
"antd": "4.24.2",
"parse-link-header": "^2.0.0",
Expand All @@ -74,7 +75,6 @@
"rehype-highlight": "6.0.0",
"remark-gfm": "^3.0.1",
"remark-remove-comments": "^0.2.0",
"rest-hooks": "^7.0.0",
"uuid": "^8.3.2"
}
}
2 changes: 1 addition & 1 deletion examples/github-app/src/Boundary.tsx
@@ -1,8 +1,8 @@
import { styled } from '@linaria/react';
import { NetworkErrorBoundary } from '@rest-hooks/react';
import { Spin } from 'antd';
import { memo, Suspense } from 'react';
import type { ReactNode } from 'react';
import { NetworkErrorBoundary } from 'rest-hooks';

function Boundary({
children,
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/RootProvider.tsx
@@ -1,8 +1,8 @@
import { CacheProvider } from '@rest-hooks/react';
import { AuthdProvider } from 'navigation/authdContext';
import type { ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import type { FallbackProps } from 'react-error-boundary';
import { CacheProvider } from 'rest-hooks';

import Boundary from './Boundary';
import { Router } from './routing';
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/navigation/NavBar.tsx
@@ -1,10 +1,10 @@
import { Link, useShowLoading } from '@anansi/router';
import { styled } from '@linaria/react';
import { NetworkErrorBoundary, useSuspense } from '@rest-hooks/react';
import { Layout, Menu, Spin, Affix } from 'antd';
import { Avatar } from 'antd';
import { memo, Suspense, useContext, useState } from 'react';
import UserResource from 'resources/User';
import { NetworkErrorBoundary, useSuspense } from 'rest-hooks';

import { authdContext } from './authdContext';
import LoginModal from './LoginModal';
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/navigation/authdContext.tsx
@@ -1,7 +1,7 @@
import { useController } from '@rest-hooks/react';
import React, { createContext, useState, useCallback, useMemo } from 'react';
import { getAuth, setAuth, unAuth } from 'resources/Auth';
import UserResource from 'resources/User';
import { useController } from 'rest-hooks';

export const authdContext = createContext({
authed: false,
Expand Down
Expand Up @@ -10,7 +10,7 @@ import remarkGfm from 'remark-gfm';
import remarkRemoveComments from 'remark-remove-comments';
import { CommentResource, Comment } from 'resources/Comment';
import { UserResource } from 'resources/User';
import { useCache, useController } from 'rest-hooks';
import { useCache, useController } from '@rest-hooks/react';

import CommentForm from './CommentForm';

Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/IssueDetail/CommentsList.tsx
@@ -1,6 +1,6 @@
import { useSuspense } from '@rest-hooks/react';
import { Card } from 'antd';
import { CommentResource } from 'resources/Comment';
import { useSuspense } from 'rest-hooks';

import CommentInline from './CommentInline';

Expand Down
@@ -1,11 +1,11 @@
import { Link } from '@anansi/router';
import { css } from '@linaria/core';
import { useCache, useController } from '@rest-hooks/react';
import { Card, Avatar } from 'antd';
import { memo, useCallback } from 'react';
import { CommentResource } from 'resources/Comment';
import { Issue } from 'resources/Issue';
import UserResource from 'resources/User';
import { useCache, useController } from 'rest-hooks';

import CommentForm from './CommentForm';

Expand Down
Expand Up @@ -2,7 +2,7 @@ import { Tag } from 'antd';
import { Issue } from 'resources/Issue';
import { Reaction, ReactionResource, contentToIcon } from 'resources/Reaction';
import { UserResource } from 'resources/User';
import { useController, useCache } from 'rest-hooks';
import { useController, useCache } from '@rest-hooks/react';
import { v4 as uuid } from 'uuid';

const { CheckableTag } = Tag;
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/IssueDetail/ReactionSpan.tsx
@@ -1,9 +1,9 @@
import { useSuspense, useController, useCache } from '@rest-hooks/react';
import { Tag } from 'antd';
import React, { useCallback } from 'react';
import { Issue } from 'resources/Issue';
import { Reaction, ReactionResource } from 'resources/Reaction';
import { UserResource } from 'resources/User';
import { useSuspense, useController, useCache } from 'rest-hooks';
import { v4 as uuid } from 'uuid';

const { CheckableTag } = Tag;
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/IssueDetail/index.tsx
Expand Up @@ -14,7 +14,7 @@ import remarkRemoveComments from 'remark-remove-comments';
import { IssueResource } from 'resources/Issue';
import { ReactionResource, contentToIcon } from 'resources/Reaction';
import UserResource from 'resources/User';
import { useSuspense, useFetch, useCache } from 'rest-hooks';
import { useSuspense, useFetch, useCache } from '@rest-hooks/react';

import CommentsList, { CardLoading } from './CommentsList';
import CreateComment from './CreateComment';
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/IssueList.tsx
@@ -1,7 +1,7 @@
import { useLocation } from '@anansi/router';
import { useSuspense, useSubscription } from '@rest-hooks/react';
import { List } from 'antd';
import { Issue, IssueResource } from 'resources/Issue';
import { useSuspense, useSubscription } from 'rest-hooks';

import LinkPagination from '../navigation/LinkPagination';
import IssueListItem from './IssueListItem';
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/NextPage.tsx
@@ -1,6 +1,6 @@
import { useController } from '@rest-hooks/react';
import { useState } from 'react';
import { IssueResource } from 'resources/Issue';
import { useController } from 'rest-hooks';

export default function NextPage({
repo,
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/ProfileDetail/UserEvents.tsx
Expand Up @@ -20,7 +20,7 @@ import {
} from 'resources/Event';
import RepositoryResource, { Repository } from 'resources/Repository';
import { UserResource, User } from 'resources/User';
import { useSuspense } from 'rest-hooks';
import { useSuspense } from '@rest-hooks/react';

import FlexRow from '../../components/FlexRow';

Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/ProfileDetail/UserRepos.tsx
Expand Up @@ -4,7 +4,7 @@ import { Card, List, Layout, Space, Timeline, Typography, Divider } from 'antd';
import React from 'react';
import RepositoryResource, { Repository } from 'resources/Repository';
import { UserResource, User } from 'resources/User';
import { useCache, useSuspense } from 'rest-hooks';
import { useCache, useSuspense } from '@rest-hooks/react';

const { Title } = Typography;

Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/pages/ProfileDetail/index.tsx
Expand Up @@ -7,7 +7,7 @@ import Markdown from 'react-markdown';
import { EventResource, typeToIcon, Event } from 'resources/Event';
import RepositoryResource, { Repository } from 'resources/Repository';
import { UserResource, User } from 'resources/User';
import { useSuspense } from 'rest-hooks';
import { useSuspense } from '@rest-hooks/react';

import UserEvents from './UserEvents';
import UserRepositories from './UserRepos';
Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/routing/index.tsx
@@ -1,6 +1,6 @@
import { RouteProvider, RouteController } from '@anansi/router';
import { useController } from '@rest-hooks/react';
import { createBrowserHistory } from 'history';
import { useController } from 'rest-hooks';

import { routes, namedPaths } from './routes';

Expand Down
2 changes: 1 addition & 1 deletion examples/github-app/src/routing/routes.tsx
@@ -1,12 +1,12 @@
import { lazy, Route } from '@anansi/router';
import { getImage } from '@rest-hooks/img';
import { Controller } from '@rest-hooks/react';
import CommentResource from 'resources/Comment';
import { EventResource } from 'resources/Event';
import IssueResource from 'resources/Issue';
import ReactionResource from 'resources/Reaction';
import RepositoryResource from 'resources/Repository';
import UserResource from 'resources/User';
import { Controller } from 'rest-hooks';

const lazyPage = (pageName: string) =>
lazy(
Expand Down
4 changes: 2 additions & 2 deletions examples/todo-app/package.json
Expand Up @@ -57,9 +57,9 @@
},
"dependencies": {
"@rest-hooks/endpoint": "^3.0.1",
"@rest-hooks/react": "workspace:^",
"@rest-hooks/rest": "^6.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"rest-hooks": "^7.0.0"
"react-dom": "18.2.0"
}
}
2 changes: 1 addition & 1 deletion examples/todo-app/src/Boundary.tsx
@@ -1,6 +1,6 @@
import { NetworkErrorBoundary } from '@rest-hooks/react';
import { memo, Suspense } from 'react';
import type { ReactNode } from 'react';
import { NetworkErrorBoundary } from 'rest-hooks';

function Boundary({ children }: { children: ReactNode }) {
return (
Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/src/RootProvider.tsx
@@ -1,5 +1,5 @@
import type { ReactNode } from 'react';
import { CacheProvider } from 'rest-hooks';
import { CacheProvider } from '@rest-hooks/react';

import Boundary from './Boundary';

Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/src/pages/Home/NewTodo.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { useCallback, useRef, useState } from 'react';
import { TodoResource, Todo } from 'resources/TodoResource';
import { useController } from 'rest-hooks';
import { useController } from '@rest-hooks/react';

export default function NewTodo({ lastId }: { lastId: number }) {
const { fetch } = useController();
Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/src/pages/Home/TodoListComponent.tsx
@@ -1,5 +1,5 @@
import { useSuspense } from '@rest-hooks/react';
import { TodoResource, Todo } from 'resources/TodoResource';
import { useSuspense } from 'rest-hooks';

import NewTodo from './NewTodo';
import TodoListItem from './TodoListItem';
Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/src/pages/Home/TodoListItem.tsx
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { memo, useCallback } from 'react';
import { TodoResource, Todo } from 'resources/TodoResource';
import { useController } from 'rest-hooks';
import { useController } from '@rest-hooks/react';

function TodoListItem({ todo }: { todo: Todo }) {
const controller = useController();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,7 +19,7 @@
"build:copy:ambient": "mkdirp ./packages/endpoint/lib && copyfiles --flat ./packages/endpoint/src/schema.d.ts ./packages/endpoint/lib/ && copyfiles --flat ./packages/endpoint/src/endpoint.d.ts ./packages/endpoint/lib/&& mkdirp ./packages/core/lib && copyfiles --flat ./packages/core/src/state/RIC.d.ts ./packages/core/lib/state && mkdirp ./packages/experimental/lib && copyfiles --flat ./packages/experimental/src/rest/RestEndpoint.d.ts ./packages/experimental/lib/rest && copyfiles --flat ./packages/rest/src/RestEndpoint.d.ts ./packages/rest/lib",
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest",
"test:ci": "yarn test --ci",
"test:coverage": "yarn test --coverage",
"test:coverage": "yarn test --coverage --testPathIgnorePatterns=\"packages/(experimental)\"",
"prepare": "yarn build:copy:ambient && tsc --build",
"prepack": "yarn prepare",
"prepublishOnly": "yarn workspaces foreach -pti --no-private run build:legacy-types",
Expand Down
2 changes: 1 addition & 1 deletion packages/experimental/src/rest/createResource.ts
Expand Up @@ -62,7 +62,7 @@ export default function createResource<
schema: (schema as any).process ? new Delete(schema as any) : schema,
method: 'DELETE',
name: getName('delete'),
process(res, params) {
process(res: any, params: any) {
return res && Object.keys(res).length ? res : params;
},
}),
Expand Down

0 comments on commit 7ede187

Please sign in to comment.