From 7c09e3964b94ea6ce0f63e19aeeb281195def58a Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Fri, 28 Jul 2023 10:33:04 +0200 Subject: [PATCH] Updates LSP templates (#1375) --- waspc/data/lsp/templates/ts/action.fn.ts | 4 +++- waspc/data/lsp/templates/ts/query.fn.ts | 4 +++- waspc/waspc.cabal | 6 +++--- waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/waspc/data/lsp/templates/ts/action.fn.ts b/waspc/data/lsp/templates/ts/action.fn.ts index ae6813ff8..337b1428e 100644 --- a/waspc/data/lsp/templates/ts/action.fn.ts +++ b/waspc/data/lsp/templates/ts/action.fn.ts @@ -1,6 +1,8 @@ import { {{upperDeclName}} } from '@wasp/actions/types' -{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}} = async (args, context) => { +type {{upperDeclName}}Payload = void +type {{upperDeclName}}Result = void +{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<{{upperDeclName}}Payload, {{upperDeclName}}Result> = async (args, context) => { // Implementation goes here } diff --git a/waspc/data/lsp/templates/ts/query.fn.ts b/waspc/data/lsp/templates/ts/query.fn.ts index e32f2df74..852c11c0e 100644 --- a/waspc/data/lsp/templates/ts/query.fn.ts +++ b/waspc/data/lsp/templates/ts/query.fn.ts @@ -1,6 +1,8 @@ import { {{upperDeclName}} } from '@wasp/queries/types' -{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}} = async (args, context) => { +type {{upperDeclName}}Payload = void +type {{upperDeclName}}Result = void +{{#named?}}export {{/named?}}const {{name}}: {{upperDeclName}}<{{upperDeclName}}Payload, {{upperDeclName}}Result> = async (args, context) => { // Implementation goes here } diff --git a/waspc/waspc.cabal b/waspc/waspc.cabal index 88fa364e9..576ad49e3 100644 --- a/waspc/waspc.cabal +++ b/waspc/waspc.cabal @@ -53,9 +53,9 @@ data-files: Cli/templates/basic/.wasproot Cli/templates/basic/src/.waspignore Cli/templates/basic/main.wasp - lsp/templates/**/*.js - lsp/templates/**/*.ts - lsp/templates/**/*.jsx + Lsp/templates/**/*.js + Lsp/templates/**/*.ts + Lsp/templates/**/*.jsx packages/deploy/dist/**/*.js packages/deploy/package.json packages/deploy/package-lock.json diff --git a/waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs b/waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs index d6192004d..6149b8dcb 100644 --- a/waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs +++ b/waspc/waspls/src/Wasp/LSP/Commands/ScaffoldTsSymbol.hs @@ -8,7 +8,7 @@ module Wasp.LSP.Commands.ScaffoldTsSymbol -- name to end of a particular file. -- -- Mustache templates are used to write the code for the new function. - -- @templateForRequest@ chooses a template in @data/lsp/template/ts@ based + -- @templateForRequest@ chooses a template in @data/Lsp/template/ts@ based -- on the location of the external import and the extension of the file that -- the function will be appended to. -- @@ -192,7 +192,7 @@ hasTemplateForArgs Args {..} = case P.fileExtension $ SP.toPathAbsFile filepath Just ext -> isRight $ templateFileFor pathToExtImport ext -- | @getTemplateFor pathToExtImport extension@ finds the mustache template in --- @data/lsp/templates/ts@ and compiles it. +-- @data/Lsp/templates/ts@ and compiles it. getTemplateFor :: MonadIO m => ExprPath -> String -> m (Either String Mustache.Template) getTemplateFor exprPath ext = runExceptT $ do templatesDir <- liftIO getTemplatesDir @@ -225,7 +225,7 @@ data Template type TemplateFile = SP.Path' (SP.Rel TemplatesDir) (SP.File Template) templatesDirInDataDir :: SP.Path' (SP.Rel Wasp.Data.DataDir) (SP.Dir TemplatesDir) -templatesDirInDataDir = [SP.reldir|lsp/templates/ts|] +templatesDirInDataDir = [SP.reldir|Lsp/templates/ts|] getTemplatesDir :: IO (SP.Path' SP.Abs (SP.Dir TemplatesDir)) getTemplatesDir = (SP. templatesDirInDataDir) <$> Wasp.Data.getAbsDataDirPath