Skip to content

Commit

Permalink
Merge branch 'canary' into use-typescript-for-image-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Aug 16, 2022
2 parents d5692b1 + 7de3cf5 commit 3a4f9e5
Show file tree
Hide file tree
Showing 36 changed files with 1,012 additions and 708 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.json
Expand Up @@ -93,7 +93,9 @@
}
],
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "warn"
"@typescript-eslint/no-useless-constructor": "warn",
"@typescript-eslint/prefer-literal-enum-member": "error",
"@typescript-eslint/prefer-namespace-keyword": "error"
}
},
{
Expand Down Expand Up @@ -326,6 +328,8 @@
"react/react-in-jsx-scope": "error",
"react/require-render-return": "error",
"react/style-prop-object": "warn",
"react-hooks/rules-of-hooks": "error"
"react-hooks/rules-of-hooks": "error",
// "@typescript-eslint/non-nullable-type-assertion-style": "warn",
"@typescript-eslint/prefer-as-const": "warn"
}
}
14 changes: 7 additions & 7 deletions examples/convex/convex/_generated/dataModel.ts
Expand Up @@ -9,8 +9,8 @@
* @module
*/

import { AnyDataModel } from "convex/server";
import { GenericId } from "convex/values";
import { AnyDataModel } from 'convex/server'
import { GenericId } from 'convex/values'

/**
* No `schema.ts` file found!
Expand All @@ -26,12 +26,12 @@ import { GenericId } from "convex/values";
/**
* The names of all of your Convex tables.
*/
export type TableNames = string;
export type TableNames = string

/**
* The type of a document stored in Convex.
*/
export type Document = any;
export type Document = any

/**
* An identifier for a document in Convex.
Expand All @@ -45,8 +45,8 @@ export type Document = any;
* Using `===` will not work because two different instances of `Id` can refer
* to the same document.
*/
export type Id = GenericId<string>;
export const Id = GenericId;
export type Id = GenericId<string>
export const Id = GenericId

/**
* A type describing your Convex data model.
Expand All @@ -57,4 +57,4 @@ export const Id = GenericId;
* This type is used to parameterize methods like `queryGeneric` and
* `mutationGeneric` to make them type-safe.
*/
export type DataModel = AnyDataModel;
export type DataModel = AnyDataModel
28 changes: 14 additions & 14 deletions examples/convex/convex/_generated/react.ts
Expand Up @@ -9,10 +9,10 @@
* @module
*/

import type getCounter from "../getCounter";
import type incrementCounter from "../incrementCounter";
import type { OptimisticLocalStore as GenericOptimisticLocalStore } from "convex/browser";
import type { ClientMutation, ClientQuery } from "convex/server";
import type getCounter from '../getCounter'
import type incrementCounter from '../incrementCounter'
import type { OptimisticLocalStore as GenericOptimisticLocalStore } from 'convex/browser'
import type { ClientMutation, ClientQuery } from 'convex/server'

/**
* A type describing your app's public Convex API.
Expand All @@ -25,14 +25,14 @@ import type { ClientMutation, ClientQuery } from "convex/server";
*/
export type ConvexAPI = {
queries: {
getCounter: ClientQuery<typeof getCounter>;
};
getCounter: ClientQuery<typeof getCounter>
}
mutations: {
incrementCounter: ClientMutation<typeof incrementCounter>;
};
};
incrementCounter: ClientMutation<typeof incrementCounter>
}
}

import { makeUseQuery, makeUseMutation, makeUseConvex } from "convex/react";
import { makeUseQuery, makeUseMutation, makeUseConvex } from 'convex/react'

/**
* Load a reactive query within a React component.
Expand All @@ -46,7 +46,7 @@ import { makeUseQuery, makeUseMutation, makeUseConvex } from "convex/react";
* @param args - The arguments to the query function.
* @returns `undefined` if loading and the query's return value otherwise.
*/
export const useQuery = makeUseQuery<ConvexAPI>();
export const useQuery = makeUseQuery<ConvexAPI>()

/**
* Construct a new {@link ReactMutation}.
Expand All @@ -64,7 +64,7 @@ export const useQuery = makeUseQuery<ConvexAPI>();
* @param name - The name of the mutation.
* @returns The {@link ReactMutation} object with that name.
*/
export const useMutation = makeUseMutation<ConvexAPI>();
export const useMutation = makeUseMutation<ConvexAPI>()

/**
* Get the {@link ConvexReactClient} within a React component.
Expand All @@ -73,10 +73,10 @@ export const useMutation = makeUseMutation<ConvexAPI>();
*
* @returns The active {@link ConvexReactClient} object, or `undefined`.
*/
export const useConvex = makeUseConvex<ConvexAPI>();
export const useConvex = makeUseConvex<ConvexAPI>()

/**
* A view of the query results currently in the Convex client for use within
* optimistic updates.
*/
export type OptimisticLocalStore = GenericOptimisticLocalStore<ConvexAPI>;
export type OptimisticLocalStore = GenericOptimisticLocalStore<ConvexAPI>
16 changes: 8 additions & 8 deletions examples/convex/convex/_generated/server.ts
Expand Up @@ -16,8 +16,8 @@ import {
MutationCtx as GenericMutationCtx,
DatabaseReader as GenericDatabaseReader,
DatabaseWriter as GenericDatabaseWriter,
} from "convex/server";
import { DataModel } from "./dataModel.js";
} from 'convex/server'
import { DataModel } from './dataModel.js'

/**
* Define a query in this Convex app's public API.
Expand All @@ -27,7 +27,7 @@ import { DataModel } from "./dataModel.js";
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
*/
export const query = makeQuery<DataModel>();
export const query = makeQuery<DataModel>()

/**
* Define a mutation in this Convex app's public API.
Expand All @@ -37,7 +37,7 @@ export const query = makeQuery<DataModel>();
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
*/
export const mutation = makeMutation<DataModel>();
export const mutation = makeMutation<DataModel>()

/**
* A set of services for use within Convex query functions.
Expand All @@ -48,15 +48,15 @@ export const mutation = makeMutation<DataModel>();
* This differs from the {@link MutationCtx} because all of the services are
* read-only.
*/
export type QueryCtx = GenericQueryCtx<DataModel>;
export type QueryCtx = GenericQueryCtx<DataModel>

/**
* A set of services for use within Convex mutation functions.
*
* The mutation context is passed as the first argument to any Convex mutation
* function run on the server.
*/
export type MutationCtx = GenericMutationCtx<DataModel>;
export type MutationCtx = GenericMutationCtx<DataModel>

/**
* An interface to read from the database within Convex query functions.
Expand All @@ -65,7 +65,7 @@ export type MutationCtx = GenericMutationCtx<DataModel>;
* document by its {@link Id}, or {@link DatabaseReader.table}, which starts
* building a query.
*/
export type DatabaseReader = GenericDatabaseReader<DataModel>;
export type DatabaseReader = GenericDatabaseReader<DataModel>

/**
* An interface to read from and write to the database within Convex mutation
Expand All @@ -76,4 +76,4 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
* for the guarantees Convex provides your functions.
*/
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
export type DatabaseWriter = GenericDatabaseWriter<DataModel>
10 changes: 8 additions & 2 deletions examples/with-loading/package.json
Expand Up @@ -8,7 +8,13 @@
"dependencies": {
"next": "latest",
"nprogress": "^0.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "18.7.5",
"@types/nprogress": "0.2.0",
"@types/react": "18.0.17",
"typescript": "4.7.4"
}
}
@@ -1,17 +1,19 @@
import type { AppProps } from 'next/app'
import { useEffect } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import NProgress from 'nprogress'
import '../public/nprogress.css'
import 'nprogress/nprogress.css'

export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()

useEffect(() => {
const handleStart = (url) => {
const handleStart = (url: string) => {
console.log(`Loading: ${url}`)
NProgress.start()
}

const handleStop = () => {
NProgress.done()
}
Expand Down
@@ -1,10 +1,10 @@
const AboutPage = () => <p>This is about Next.js!</p>

export async function getServerSideProps() {
await new Promise((resolve) => {
setTimeout(resolve, 500)
})
return { props: {} }
}

export default AboutPage
export default function AboutPage() {
return <p>This is about Next.js!</p>
}
@@ -1,10 +1,10 @@
const ForeverPage = () => <p>This page was rendered for a while!</p>

export async function getServerSideProps() {
await new Promise((resolve) => {
setTimeout(resolve, 3000)
})
return { props: {} }
}

export default ForeverPage
export default function ForeverPage() {
return <p>This page was rendered for a while!</p>
}
3 changes: 0 additions & 3 deletions examples/with-loading/pages/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions examples/with-loading/pages/index.tsx
@@ -0,0 +1,3 @@
export default function IndexPage() {
return <p>Hello Next.js!</p>
}
81 changes: 0 additions & 81 deletions examples/with-loading/public/nprogress.css

This file was deleted.

20 changes: 20 additions & 0 deletions examples/with-loading/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
13 changes: 9 additions & 4 deletions examples/with-slate/package.json
Expand Up @@ -7,10 +7,15 @@
},
"dependencies": {
"next": "latest",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"slate": "^0.76.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"slate": "^0.82.0",
"slate-history": "0.66.0",
"slate-react": "^0.76.1"
"slate-react": "^0.82.0"
},
"devDependencies": {
"@types/node": "18.7.5",
"@types/react": "18.0.17",
"typescript": "4.7.4"
}
}

0 comments on commit 3a4f9e5

Please sign in to comment.