diff --git a/examples/tutorials/TodoApp/main.wasp b/examples/tutorials/TodoApp/main.wasp
index 58949278d..fff7baa2b 100644
--- a/examples/tutorials/TodoApp/main.wasp
+++ b/examples/tutorials/TodoApp/main.wasp
@@ -21,7 +21,7 @@ app TodoApp {
route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
- component: import Main from "@client/MainPage.js"
+ component: import Main from "@client/MainPage"
}
route SignupRoute { path: "/signup", to: SignupPage }
@@ -50,16 +50,16 @@ entity Task {=psl
psl=}
query getTasks {
- fn: import { getTasks } from "@server/queries.js",
+ fn: import { getTasks } from "@server/queries",
entities: [Task]
}
action createTask {
- fn: import { createTask } from "@server/actions.js",
+ fn: import { createTask } from "@server/actions",
entities: [Task]
}
action updateTask {
- fn: import { updateTask } from "@server/actions.js",
+ fn: import { updateTask } from "@server/actions",
entities: [Task]
}
diff --git a/examples/tutorials/TodoApp/src/client/Clocks.js b/examples/tutorials/TodoApp/src/client/Clocks.jsx
similarity index 89%
rename from examples/tutorials/TodoApp/src/client/Clocks.js
rename to examples/tutorials/TodoApp/src/client/Clocks.jsx
index 01221a39e..74ec96738 100644
--- a/examples/tutorials/TodoApp/src/client/Clocks.js
+++ b/examples/tutorials/TodoApp/src/client/Clocks.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react'
+import { useEffect, useState } from 'react'
import Clock from 'react-clock'
import 'react-clock/dist/Clock.css'
diff --git a/examples/tutorials/TodoApp/src/client/LoginPage.js b/examples/tutorials/TodoApp/src/client/LoginPage.jsx
similarity index 92%
rename from examples/tutorials/TodoApp/src/client/LoginPage.js
rename to examples/tutorials/TodoApp/src/client/LoginPage.jsx
index 4671408bf..fbe42d6b4 100644
--- a/examples/tutorials/TodoApp/src/client/LoginPage.js
+++ b/examples/tutorials/TodoApp/src/client/LoginPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import { Link } from 'react-router-dom'
import LoginForm from '@wasp/auth/forms/Login'
diff --git a/examples/tutorials/TodoApp/src/client/MainPage.js b/examples/tutorials/TodoApp/src/client/MainPage.jsx
similarity index 94%
rename from examples/tutorials/TodoApp/src/client/MainPage.js
rename to examples/tutorials/TodoApp/src/client/MainPage.jsx
index 43243d5f7..6916d017e 100644
--- a/examples/tutorials/TodoApp/src/client/MainPage.js
+++ b/examples/tutorials/TodoApp/src/client/MainPage.jsx
@@ -1,10 +1,8 @@
-import React from 'react'
-
-import logout from '@wasp/auth/logout.js'
import { useQuery } from '@wasp/queries'
import getTasks from '@wasp/queries/getTasks'
import createTask from '@wasp/actions/createTask'
import updateTask from '@wasp/actions/updateTask'
+import logout from '@wasp/auth/logout'
import Clocks from './Clocks'
const MainPage = () => {
@@ -37,7 +35,6 @@ const Task = (props) => {
window.alert('Error while updating task: ' + error.message)
}
}
-
return (
{
return props.tasks.map((task, idx) => )
}
-const NewTaskForm = () => {
+const NewTaskForm = (props) => {
const handleSubmit = async (event) => {
event.preventDefault()
try {
@@ -80,3 +77,4 @@ const NewTaskForm = () => {
}
export default MainPage
+
diff --git a/examples/tutorials/TodoApp/src/client/SignupPage.js b/examples/tutorials/TodoApp/src/client/SignupPage.jsx
similarity index 92%
rename from examples/tutorials/TodoApp/src/client/SignupPage.js
rename to examples/tutorials/TodoApp/src/client/SignupPage.jsx
index d01997ae6..f06c2e75a 100644
--- a/examples/tutorials/TodoApp/src/client/SignupPage.js
+++ b/examples/tutorials/TodoApp/src/client/SignupPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import { Link } from 'react-router-dom'
import SignupForm from '@wasp/auth/forms/Signup'
diff --git a/examples/tutorials/TodoApp/src/client/jsconfig.json b/examples/tutorials/TodoApp/src/client/jsconfig.json
deleted file mode 100644
index e9b5551fd..000000000
--- a/examples/tutorials/TodoApp/src/client/jsconfig.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "compilerOptions": {
- // The following settings enable IDE support in user-provided source files.
- // Editing them might break features like import autocompletion and
- // definition lookup. Don't change them unless you know what you're doing.
- //
- // The relative path to the generated web app's root directory. This must be
- // set to define the "paths" option.
- "baseUrl": "../../.wasp/out/web-app/",
- "paths": {
- // Resolve all "@wasp" imports to the generated source code.
- "@wasp/*": [
- "src/*"
- ],
- // Resolve all non-relative imports to the correct node module. Source:
- // https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
- "*": [
- // Start by looking for the definiton inside the node modules root
- // directory...
- "node_modules/*",
- // ... If that fails, try to find it inside definitely-typed type
- // definitions.
- "node_modules/@types/*"
- ]
- }
- }
-}
diff --git a/examples/tutorials/TodoApp/src/client/react-app-env.d.ts b/examples/tutorials/TodoApp/src/client/react-app-env.d.ts
new file mode 100644
index 000000000..e80934ce3
--- /dev/null
+++ b/examples/tutorials/TodoApp/src/client/react-app-env.d.ts
@@ -0,0 +1,60 @@
+declare module '*.avif' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.bmp' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.gif' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.jpg' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.jpeg' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.png' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.webp' {
+ const src: string;
+ export default src;
+}
+
+declare module '*.svg' {
+ import * as React from 'react';
+
+ export const ReactComponent: React.FunctionComponent & { title?: string }>;
+
+ const src: string;
+ export default src;
+}
+
+declare module '*.module.css' {
+ const classes: { readonly [key: string]: string };
+ export default classes;
+}
+
+declare module '*.module.scss' {
+ const classes: { readonly [key: string]: string };
+ export default classes;
+}
+
+declare module '*.module.sass' {
+ const classes: { readonly [key: string]: string };
+ export default classes;
+}
diff --git a/examples/tutorials/TodoApp/src/client/tsconfig.json b/examples/tutorials/TodoApp/src/client/tsconfig.json
new file mode 100644
index 000000000..d501a4193
--- /dev/null
+++ b/examples/tutorials/TodoApp/src/client/tsconfig.json
@@ -0,0 +1,55 @@
+// =============================== IMPORTANT =================================
+//
+// This file is only used for Wasp IDE support. You can change it to configure
+// your IDE checks, but none of these options will affect the TypeScript
+// compiler. Proper TS compiler configuration in Wasp is coming soon :)
+{
+ "compilerOptions": {
+ // JSX support
+ "jsx": "preserve",
+ "strict": true,
+ // Allow default imports.
+ "esModuleInterop": true,
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext"
+ ],
+ "allowJs": true,
+ // Wasp needs the following settings enable IDE support in your source
+ // files. Editing them might break features like import autocompletion and
+ // definition lookup. Don't change them unless you know what you're doing.
+ //
+ // The relative path to the generated web app's root directory. This must be
+ // set to define the "paths" option.
+ "baseUrl": "../../.wasp/out/web-app/",
+ "paths": {
+ // Resolve all "@wasp" imports to the generated source code.
+ "@wasp/*": [
+ "src/*"
+ ],
+ // Resolve all non-relative imports to the correct node module. Source:
+ // https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
+ "*": [
+ // Start by looking for the definiton inside the node modules root
+ // directory...
+ "node_modules/*",
+ // ... If that fails, try to find it inside definitely-typed type
+ // definitions.
+ "node_modules/@types/*"
+ ]
+ },
+ // Correctly resolve types: https://www.typescriptlang.org/tsconfig#typeRoots
+ "typeRoots": [
+ "../../.wasp/out/web-app/node_modules/@types"
+ ],
+ // Since this TS config is used only for IDE support and not for
+ // compilation, the following directory doesn't exist. We need to specify
+ // it to prevent this error:
+ // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file
+ "outDir": "phantom"
+ },
+ "exclude": [
+ "phantom"
+ ],
+}
\ No newline at end of file
diff --git a/examples/tutorials/TodoApp/src/client/waspLogo.png b/examples/tutorials/TodoApp/src/client/waspLogo.png
deleted file mode 100644
index d39a9443a..000000000
Binary files a/examples/tutorials/TodoApp/src/client/waspLogo.png and /dev/null differ
diff --git a/examples/tutorials/TodoApp/src/server/actions.js b/examples/tutorials/TodoApp/src/server/actions.js
index 168028c2a..ac3d7f44b 100644
--- a/examples/tutorials/TodoApp/src/server/actions.js
+++ b/examples/tutorials/TodoApp/src/server/actions.js
@@ -1,21 +1,19 @@
import HttpError from '@wasp/core/HttpError.js'
-export const createTask = async ({ description }, context) => {
+export const createTask = async (args, context) => {
if (!context.user) { throw new HttpError(401) }
return context.entities.Task.create({
data: {
- description,
+ description: args.description,
user: { connect: { id: context.user.id } }
}
})
}
-export const updateTask = async ({ taskId, data }, context) => {
+export const updateTask = async (args, context) => {
if (!context.user) { throw new HttpError(401) }
return context.entities.Task.updateMany({
- where: { id: taskId, user: { id: context.user.id } },
- data: {
- isDone: data.isDone
- }
+ where: { id: args.taskId, user: { id: context.user.id } },
+ data: { isDone: args.data.isDone }
})
}
diff --git a/examples/tutorials/TodoApp/src/server/jsconfig.json b/examples/tutorials/TodoApp/src/server/jsconfig.json
deleted file mode 100644
index 9e996fc5d..000000000
--- a/examples/tutorials/TodoApp/src/server/jsconfig.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "compilerOptions": {
- // The following settings enable IDE support in user-provided source files.
- // Editing them might break features like import autocompletion and
- // definition lookup. Don't change them unless you know what you're doing.
- //
- // The relative path to the generated web app's root directory. This must be
- // set to define the "paths" option.
- "baseUrl": "../../.wasp/out/server/",
- "paths": {
- // Resolve all "@wasp" imports to the generated source code.
- "@wasp/*": [
- "src/*"
- ],
- // Resolve all non-relative imports to the correct node module. Source:
- // https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
- "*": [
- // Start by looking for the definiton inside the node modules root
- // directory...
- "node_modules/*",
- // ... If that fails, Try to find it inside definitely-typed type
- // definitions.
- "node_modules/@types/*"
- ]
- }
- }
-}
diff --git a/examples/tutorials/TodoApp/src/server/tsconfig.json b/examples/tutorials/TodoApp/src/server/tsconfig.json
new file mode 100644
index 000000000..70a79b44e
--- /dev/null
+++ b/examples/tutorials/TodoApp/src/server/tsconfig.json
@@ -0,0 +1,48 @@
+// =============================== IMPORTANT =================================
+//
+// This file is only used for Wasp IDE support. You can change it to configure
+// your IDE checks, but none of these options will affect the TypeScript
+// compiler. Proper TS compiler configuration in Wasp is coming soon :)
+{
+ "compilerOptions": {
+ // Allows default imports.
+ "esModuleInterop": true,
+ "allowJs": true,
+ "strict": true,
+ // Wasp needs the following settings enable IDE support in your source
+ // files. Editing them might break features like import autocompletion and
+ // definition lookup. Don't change them unless you know what you're doing.
+ //
+ // The relative path to the generated web app's root directory. This must be
+ // set to define the "paths" option.
+ "baseUrl": "../../.wasp/out/server/",
+ "paths": {
+ // Resolve all "@wasp" imports to the generated source code.
+ "@wasp/*": [
+ "src/*"
+ ],
+ // Resolve all non-relative imports to the correct node module. Source:
+ // https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
+ "*": [
+ // Start by looking for the definiton inside the node modules root
+ // directory...
+ "node_modules/*",
+ // ... If that fails, try to find it inside definitely-typed type
+ // definitions.
+ "node_modules/@types/*"
+ ]
+ },
+ // Correctly resolve types: https://www.typescriptlang.org/tsconfig#typeRoots
+ "typeRoots": [
+ "../../.wasp/out/server/node_modules/@types"
+ ],
+ // Since this TS config is used only for IDE support and not for
+ // compilation, the following directory doesn't exist. We need to specify
+ // it to prevent this error:
+ // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file
+ "outDir": "phantom",
+ },
+ "exclude": [
+ "phantom"
+ ],
+}
\ No newline at end of file
diff --git a/examples/tutorials/TodoApp/src/shared/jsconfig.json b/examples/tutorials/TodoApp/src/shared/tsconfig.json
similarity index 74%
rename from examples/tutorials/TodoApp/src/shared/jsconfig.json
rename to examples/tutorials/TodoApp/src/shared/tsconfig.json
index 0c4e7f7eb..20fcac843 100644
--- a/examples/tutorials/TodoApp/src/shared/jsconfig.json
+++ b/examples/tutorials/TodoApp/src/shared/tsconfig.json
@@ -1,12 +1,15 @@
{
"compilerOptions": {
+ // Enable default imports in TypeScript.
+ "esModuleInterop": true,
+ "allowJs": true,
// The following settings enable IDE support in user-provided source files.
// Editing them might break features like import autocompletion and
// definition lookup. Don't change them unless you know what you're doing.
//
// The relative path to the generated web app's root directory. This must be
// set to define the "paths" option.
- "baseUrl": "../../.wasp/out/server",
+ "baseUrl": "../../.wasp/out/server/",
"paths": {
// Resolve all non-relative imports to the correct node module. Source:
// https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
@@ -18,6 +21,8 @@
// definitions.
"node_modules/@types/*"
]
- }
+ },
+ // Correctly resolve types: https://www.typescriptlang.org/tsconfig#typeRoots
+ "typeRoots": ["../../.wasp/out/server/node_modules/@types"]
}
}
diff --git a/waspc/data/Cli/templates/new/src/client/MainPage.jsx b/waspc/data/Cli/templates/new/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/data/Cli/templates/new/src/client/MainPage.jsx
+++ b/waspc/data/Cli/templates/new/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums
index 8610cafb3..c790ebc40 100644
--- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums
+++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums
@@ -270,7 +270,7 @@
"file",
"web-app/src/ext-src/MainPage.jsx"
],
- "612bc8f76682b8753ffe94c81fb58968d60867071d412b4e931918d75ad89bf8"
+ "7244c106359f088fdcc0d4a76ee63277f1cea63cbe7aac5e5c39a17df693b1e2"
],
[
[
diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/src/ext-src/MainPage.jsx b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/src/ext-src/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/src/ext-src/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/src/ext-src/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/src/client/MainPage.jsx b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/src/client/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums
index 2cdc55180..ca6d309ad 100644
--- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums
+++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums
@@ -270,7 +270,7 @@
"file",
"web-app/src/ext-src/MainPage.jsx"
],
- "612bc8f76682b8753ffe94c81fb58968d60867071d412b4e931918d75ad89bf8"
+ "7244c106359f088fdcc0d4a76ee63277f1cea63cbe7aac5e5c39a17df693b1e2"
],
[
[
diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/src/ext-src/MainPage.jsx b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/src/ext-src/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/src/ext-src/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/src/ext-src/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/src/client/MainPage.jsx b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/src/client/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums
index 290c579a3..1bb93ffc8 100644
--- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums
+++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums
@@ -284,7 +284,7 @@
"file",
"web-app/src/ext-src/MainPage.jsx"
],
- "612bc8f76682b8753ffe94c81fb58968d60867071d412b4e931918d75ad89bf8"
+ "7244c106359f088fdcc0d4a76ee63277f1cea63cbe7aac5e5c39a17df693b1e2"
],
[
[
diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/src/ext-src/MainPage.jsx b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/src/ext-src/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/src/ext-src/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/src/ext-src/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/src/client/MainPage.jsx b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/src/client/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums
index 42d6c6349..e9b4e20fe 100644
--- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums
+++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums
@@ -270,7 +270,7 @@
"file",
"web-app/src/ext-src/MainPage.jsx"
],
- "612bc8f76682b8753ffe94c81fb58968d60867071d412b4e931918d75ad89bf8"
+ "7244c106359f088fdcc0d4a76ee63277f1cea63cbe7aac5e5c39a17df693b1e2"
],
[
[
diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/src/ext-src/MainPage.jsx b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/src/ext-src/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/src/ext-src/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/src/ext-src/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/src/client/MainPage.jsx b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/src/client/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/src/client/MainPage.jsx b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/src/client/MainPage.jsx
index b66643131..ef82ebeeb 100644
--- a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/src/client/MainPage.jsx
+++ b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/src/client/MainPage.jsx
@@ -1,4 +1,3 @@
-import React from 'react'
import waspLogo from './waspLogo.png'
import './Main.css'
diff --git a/web/docs/language/overview.md b/web/docs/language/overview.md
index 4a4a7fa6a..7c2e0e185 100644
--- a/web/docs/language/overview.md
+++ b/web/docs/language/overview.md
@@ -5,11 +5,11 @@ title: Overview
Wasp is a declarative language that recognizes web application-specific terms (e.g. *page* or *route*) as
words (types) of the language.
-The basic idea is that the higher-level overview of an app (e.g. pages, routes, database model, ...) is defined in `*.wasp` files (for now just one), while the specific parts (web components, back-end queries, ...) are implemented in specific non-wasp technologies (React, NodeJS, Prisma) and then referenced in the `*.wasp` files.
+The basic idea is that the higher-level overview of an app (e.g. pages, routes, database model, ...) is defined in `*.wasp` files (for now just one), while the specific parts (web components, back-end queries, ...) are implemented in specific non-Wasp technologies (React, NodeJS, Prisma) and then referenced in the `*.wasp` files.
Basic structure of a Wasp project is:
- `*.wasp` file
-- The `src/` folder -> Contains non-wasp code (JS, CSS, ...). You can structure it however you want, as long as you put it somewhere inside the correct subfolder:
+- The `src/` folder -> Contains non-Wasp code (JS, CSS, ...). You can structure it however you want, as long as you put it somewhere inside the correct subfolder:
- The `src/server` folder - Contains your server code (i.e., executed by Node JS).
- The `src/client` folder - Contains your client code (i.e., executed by JS in user's browsers).
- The `src/shared` folder - Contains the code you want to share between the server and the client (e.g., utility functions).
diff --git a/web/docs/tutorials/todo-app/auth.md b/web/docs/tutorials/todo-app/auth.md
index 40296cc0c..293568700 100644
--- a/web/docs/tutorials/todo-app/auth.md
+++ b/web/docs/tutorials/todo-app/auth.md
@@ -10,7 +10,7 @@ Let's define a Todo list (luckily we have an app for that now ;)) to get this do
- [ ] Add Wasp entity `User`.
- [ ] Add `auth` Wasp declaration.
- [ ] Add `Login` and `Signup` pages
-- [ ] Modify `src/client/MainPage.js` so that it requires authentication.
+- [ ] Modify `src/client/MainPage.jsx` so that it requires authentication.
- [ ] Add Prisma relation between `User` and `Task` entities.
- [ ] Modify our queries and actions so that they work only with the tasks belonging to the authenticated user.
- [ ] Add logout button.
@@ -68,8 +68,8 @@ during signup, check out the [lower-level auth API](/docs/language/features#lowe
Ok, that was easy!
To recap, so far we have defined:
-- `User` entity.
-- `app.auth` field, thanks to which Wasp gives us plenty of auth functionality.
+- The `User` entity.
+- The `app.auth` field, thanks to which Wasp gives us plenty of auth-related functionality.
## Adding Login and Signup pages
@@ -91,8 +91,7 @@ page LoginPage {
Great, Wasp now knows how to route these and where to find the pages. Now to the React code of the pages:
-```jsx title="src/client/LoginPage.js"
-import React from 'react'
+```jsx title="src/client/LoginPage.jsx"
import { Link } from 'react-router-dom'
import LoginForm from '@wasp/auth/forms/Login'
@@ -114,8 +113,7 @@ export default LoginPage
The Signup page is very similar to the login one:
-```jsx title="src/client/SignupPage.js"
-import React from 'react'
+```jsx title="src/client/SignupPage.jsx"
import { Link } from 'react-router-dom'
import SignupForm from '@wasp/auth/forms/Signup'
@@ -146,7 +144,7 @@ There is a specific Wasp feature that allows us to achieve this in a simple way:
// ...
page MainPage {
authRequired: true,
- component: import Main from "@client/MainPage.js"
+ component: import Main from "@client/MainPage"
}
```
@@ -155,21 +153,20 @@ If an unauthenticated user tries to access route `/` where our page `MainPage` i
Also, when `authRequired` is set to `true`, the React component of a page (specified by `component` property within `page`) will be provided `user` object as a prop. It can be accessed like this:
-```jsx {1} title="src/client/MainPage.js"
+```jsx {1} title="src/client/MainPage.jsx"
const MainPage = ({ user }) => {
- // do something with user
+ // Do something with the user
}
```
Ok, time to try out how this works!
-Now, we can again run
+Now, we can start the app again (if it's not still running):
```shell-session
wasp start
```
-Try going to `/` in our web app. It will now redirect you to `/login`, where you'll be asked to authenticate.
-Once you log in or sign up, you will be sent back to `/` and you will see the todo list.
+Try going to the main page (`/`) of our web app. It will now redirect you to `/login`, where you'll be asked to authenticate. Once you log in or sign up, you will be sent back to `/` and you will see the todo list.
Let's now see how things look in the database! Run:
```shell-session
@@ -262,7 +259,7 @@ Due to how Prisma works, we had to convert `update` to `updateMany` in `updateTa
Right, that should be it!
-Run
+Run (or just continue running):
```shell-session
wasp start
```
@@ -282,7 +279,7 @@ You will see that each user has its own tasks, just as we specified in our code!
## Logout button
Last, but not the least, let's add logout functionality:
-```jsx {2,10} title="src/client/MainPage.js"
+```jsx {2,10} title="src/client/MainPage.jsx"
// ...
import logout from '@wasp/auth/logout.js'
//...
diff --git a/web/docs/tutorials/todo-app/creating-new-project.md b/web/docs/tutorials/todo-app/creating-new-project.md
index a7660ac9e..f39099017 100644
--- a/web/docs/tutorials/todo-app/creating-new-project.md
+++ b/web/docs/tutorials/todo-app/creating-new-project.md
@@ -20,7 +20,7 @@ You have just run your app in the development mode!
:::
You will be seeing a lot of different output from the client, server and database setting themselves up.
-Once ready, a new tab should open in your browser at `http://localhost:3000`, with simple placeholder page:
+Once ready, a new tab should open in your browser at `http://localhost:3000`, with a simple placeholder page:
{
return
Hello world!
}
+
export default MainPage
```
-At this point, you should be seeing something like
+At this point, you should see something like this:
{
+const Clocks = () => {
const [time, setTime] = useState(new Date())
useEffect(() => {
@@ -46,10 +46,12 @@ export default () => {
)
}
+
+export default Clocks
```
And let's import it in our main React component.
-```jsx {2,11} title="src/client/MainPage.js"
+```jsx {2,11} title="src/client/MainPage.jsx"
// ...
import Clocks from './Clocks'
@@ -68,6 +70,6 @@ const MainPage = () => {
}
// ...
```
-As you can see, importing other files from `src/client` is completely normal, just use the relative path. The same goes for all files under `src/server`. You can't (and shouldn't) import files from `src/client` into `src/server` and vice versa. If you want to share code between the two runtimes, you can use a relative import to import anything from `src/shared` into both the client code and the server code.
+As you can see, importing other files from `src/client` is completely normal, just use the relative path. The same goes for all files under `src/server`. You can't (and shouldn't) import files from `src/client` into `src/server` and vice versa. If you want to share code between the two runtimes, you can use a relative import to import anything from `src/shared` into both the client code and the server code. The `src/shared` is especially handy for full-stack type definitions when using TypeScript.
That is it! We added a dependency and used it in our project.
diff --git a/web/docs/tutorials/todo-app/listing-tasks.md b/web/docs/tutorials/todo-app/listing-tasks.md
index 4fbe017fb..3eeeb63ac 100644
--- a/web/docs/tutorials/todo-app/listing-tasks.md
+++ b/web/docs/tutorials/todo-app/listing-tasks.md
@@ -14,7 +14,7 @@ Queries are here when we need to fetch/read something, while actions are here wh
We will start with writing a query, since we are just listing tasks and not modifying anything for now.
To list tasks, we will need two things:
-1. Wasp query that fetches all the tasks from the database.
+1. A Wasp query that fetches all the tasks from the database.
2. React logic that calls our query and displays its results.
## Wasp query
@@ -31,7 +31,7 @@ query getTasks {
// We specify that JS implementation of the query (which is an async JS function)
// can be found in `src/server/queries.js` as the named export `getTasks`.
// Use '@server' to reference files inside the src/server folder.
- fn: import { getTasks } from "@server/queries.js",
+ fn: import { getTasks } from "@server/queries",
// We tell Wasp that this query is doing something with entity `Task`. With that, Wasp will
// automatically refresh the results of this query when tasks change.
entities: [Task]
@@ -52,7 +52,7 @@ Query function parameters:
- `context`: `object`, additional stuff provided by Wasp.
-Since we declared in `main.wasp` that our query uses entity Task, Wasp injected a [Prisma client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/crud) for entity Task as `context.entities.Task` - we used it above to fetch all the tasks from the database.
+Since we declared in `main.wasp` that our query uses entity `Task`, Wasp injected a [Prisma client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/crud) for the `Task` entity as `context.entities.Task` - we used it above to fetch all the tasks from the database.
:::info
Queries and actions are NodeJS functions that are executed on the server. Therefore, we put them in the `src/server` folder.
@@ -62,9 +62,7 @@ Queries and actions are NodeJS functions that are executed on the server. Theref
We've just said that the queries we write are executed on the server, but Wasp will generate client-side query functions (taking care of the network and cache invalidation in the background). Let's finally use the query we've just created, `getTasks`, in our React component to list the tasks:
-```jsx {3-4,7-16,19-32} title="src/client/MainPage.js"
-import React from 'react'
-
+```jsx {1-2,5-14,17-32} title="src/client/MainPage.jsx"
import getTasks from '@wasp/queries/getTasks'
import { useQuery } from '@wasp/queries'
@@ -105,7 +103,7 @@ Most of this is just regular React, the only exception being two special `@wasp`
- `import getTasks from '@wasp/queries/getTasks'` - Gives us our freshly defined Wasp query.
- `import { useQuery } from '@wasp/queries'` - Gives us Wasp's [useQuery](language/features.md#the-usequery-hook) React hook which is actually just a thin wrapper over [react-query](https://github.com/tannerlinsley/react-query)'s [useQuery](https://react-query.tanstack.com/docs/guides/queries) hook, behaving very similarly while offering some extra integration with Wasp.
-While we could call query directly as `getTasks()`, calling it as `useQuery(getTasks)` gives us reactivity- the React component gets re-rendered if the result of the query changes.
+While we could directly call the query with `getTasks()`, calling it with `useQuery(getTasks)` gives us reactivity - the React component gets re-rendered if the result of the query changes.
With these changes, you should be seeing the text "No tasks" on the screen:
diff --git a/web/docs/tutorials/todo-app/the-end.md b/web/docs/tutorials/todo-app/the-end.md
index 114c42070..846c1edd0 100644
--- a/web/docs/tutorials/todo-app/the-end.md
+++ b/web/docs/tutorials/todo-app/the-end.md
@@ -19,14 +19,13 @@ If you are interested in what is Wasp actually generating in the background, you
We introduced Tailwind CSS support in our Beta version 0.7.0! 🎨
-If you want to style your app with sweet tailwind css classes, all you have to do is add a couple config files to your app. Check out [this guide](https://www.wasp-lang.dev/blog/2022/11/16/tailwind-feature-announcement)
-) to learn more!
+If you want to style your app with sweet tailwind css classes, all you have to do is add a couple config files to your app. Check out [this guide](https://www.wasp-lang.dev/blog/2022/11/16/tailwind-feature-announcement) to learn more!
## Where next?
Well, you could check [the "Language" section](language/overview.md) of the docs for more details on specific parts of Wasp.
-Or, you could try to build something on your own with Wasp!
+Or, you could use Wasp to build something of your own!
-If you find some features you would like to have are missing, or have any other kind of feedback, please write to us on [Discord](https://discord.gg/rzdnErX) or create an issue on [Github](https://github.com/wasp-lang/wasp), so we can learn which features to add/improve next.
+If you notice that some of the features you'd like to have are missing, or have any other kind of feedback, please write to us on [Discord](https://discord.gg/rzdnErX) or create an issue on [Github](https://github.com/wasp-lang/wasp), so we can learn which features to add/improve next.
Even better, if you would like to contribute or help building the feature, let us know!
You can find more details on contributing [here](contributing.md).
diff --git a/web/docs/tutorials/todo-app/updating-tasks.md b/web/docs/tutorials/todo-app/updating-tasks.md
index 1bf4d9f7f..a37f9eec6 100644
--- a/web/docs/tutorials/todo-app/updating-tasks.md
+++ b/web/docs/tutorials/todo-app/updating-tasks.md
@@ -19,7 +19,7 @@ We declare a Wasp action:
// ...
action updateTask {
- fn: import { updateTask } from "@server/actions.js",
+ fn: import { updateTask } from "@server/actions",
entities: [Task]
}
```
@@ -43,7 +43,7 @@ export const updateTask = async (args, context) => {
## React logic
And we update the React component:
-```jsx {2,7-16,23} title="src/client/MainPage.js"
+```jsx {2,7-16,23} title="src/client/MainPage.jsx"
// ...
import updateTask from '@wasp/actions/updateTask'
diff --git a/web/static/img/wasp-new-screenshot.png b/web/static/img/wasp-new-screenshot.png
index 2f6124942..cb33249d9 100644
Binary files a/web/static/img/wasp-new-screenshot.png and b/web/static/img/wasp-new-screenshot.png differ