Skip to content

Commit

Permalink
internal: Test TypeScript 4.1, 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Mar 19, 2023
1 parent c0248d6 commit 7164818
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ jobs:
- run:
name: typecheck
command: |
yarn run tsc --project examples/todo-app/tsconfig.json
if [ "<< parameters.typescript-version >>" == "latest" ] || [ "<< parameters.typescript-version >>" == "~4.8" ]; then
yarn run tsc --project examples/todo-app/tsconfig.json
yarn run tsc --project examples/github-app/tsconfig.json
fi
yarn run tsc --project examples/todo-app/tsconfig.typetest.json
esmodule-loosenulltypes:
docker: *docker
Expand Down Expand Up @@ -179,8 +180,8 @@ workflows:
# 3.7 is min version for 'full enforcement' (TODO: we need to do a test without rest lib for this to work)
# 4.1 is min version for rest package working
# 4.3 is min version for rest package working well
# TODO: Add back "~4.1", "~4.3", once we can get around linaria types
typescript-version: ["~4.8", "latest"]
# 4.7 (but its broken so we do 4.8) lets you apply a generic type to a function type to see its return value
typescript-version: ["~4.1", "~4.3", "~4.8", "latest"]
requires:
- setup
- esmodule-loosenulltypes:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build packages
cache: 'yarn'
- name: Install packages
run: |
npm install -g corepack
corepack enable
yarn install --immutable
- name: Build packages
run: |
NODE_ENV=production BROWSERSLIST_ENV=modern yarn workspaces foreach -ptivR --from @rest-hooks/core run build:lib && NODE_ENV=production BROWSERSLIST_ENV=modern yarn workspaces foreach -ptivR --from @rest-hooks/endpoint run build:lib
- name: Run benchmark
run: yarn workspace example-benchmark build && yarn workspace example-benchmark start | tee output.txt
Expand Down
7 changes: 7 additions & 0 deletions examples/todo-app/tsconfig.typetest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"skipDefaultLibCheck": true,
},
"include": ["typetest.ts"],
}
29 changes: 29 additions & 0 deletions examples/todo-app/typetest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useCache, useController, useSuspense } from '@rest-hooks/react';

import { queryRemaining, TodoResource } from './src/resources/TodoResource';
import { UserResource } from './src/resources/UserResource';

function useTest() {
const ctrl = useController();
const payload = { id: 1, title: '', userId: 1 };
ctrl.fetch(TodoResource.create, payload);

const todos = useSuspense(TodoResource.getList, { userId: 1 });
useSuspense(TodoResource.getList);
todos.map((todo) => {
todo.pk();
todo.title;
ctrl.fetch(
TodoResource.partialUpdate,
{ id: todo.id },
{ completed: true },
);
});

const remaining = useCache(queryRemaining, { userId: 1 });

const users = useSuspense(UserResource.getList);
users.map((user) => {
user.name;
});
}

0 comments on commit 7164818

Please sign in to comment.