Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serverless Bundle linting errors with 3.x #261

Open
bbbco opened this issue Oct 10, 2023 · 5 comments
Open

Serverless Bundle linting errors with 3.x #261

bbbco opened this issue Oct 10, 2023 · 5 comments

Comments

@bbbco
Copy link

bbbco commented Oct 10, 2023

Describe the bug
Serverless Bundle is now throwing linting errors (presumably via eslint) for the new 3.x syntax:

ERROR in src/functions/foo/handler.ts:33:25
TS2554: Expected 0 arguments, but got 1.
    31 |  */
    32 | export async function foo(): Promise<Foo[]> {
  > 33 |     const eta = new Eta({
       |                         ^
  > 34 |         views: path.join(__dirname, '../../templates'),
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 35 |     });

ERROR in src/functions/foo/handler.ts:36:26
TS2339: Property 'render' does not exist on type 'Eta'.
    34 |         views: path.join(__dirname, '../../templates'),
    35 |     });
  > 36 |     const fooQuery = eta.render('foo.eta', { foo: process.env.FOO });
       |                          ^^^^^^
       |

It seems that the linter is expecting the Eta object to be called the way it was in 2.x

Package & Environment Details

  • Node 16
  • Serverless
  • Serverless Bundle
@nebrelbug
Copy link
Collaborator

Weird. What version do you have installed? Make sure that you don't have @types/eta installed.

@bbbco
Copy link
Author

bbbco commented Oct 10, 2023

        "eta": "^3.1.1",

I don't have @types/eta installed. My VSCode intelisense detects the new format just fine and thinks its valid code. It's only after I run npx serverless webpack that the compilation errors appear.

@bbbco
Copy link
Author

bbbco commented Oct 10, 2023

Here's my package dependencies:

    "dependencies": {
        "@aws-sdk/client-s3": "^3.425.0",
        "@aws-sdk/client-secrets-manager": "^3.347.1",
        "@middy/core": "^3.4.0",
        "@middy/http-json-body-parser": "^3.4.0",
        "eta": "^3.1.1",
        "fast-xml-parser": "^4.3.0",
        "proxy-agent": "^6.3.0",
        "semver": "^7.5.4",
        "snowflake-sdk": "^1.8.0"
    },
    "devDependencies": {
        "@serverless/typescript": "^3.0.0",
        "@smithy/util-stream": "^2.0.14",
        "@types/aws-lambda": "^8.10.71",
        "@types/jest": "^29.5.0",
        "@types/node": "^14.14.25",
        "@types/snowflake-sdk": "^1.6.12",
        "@typescript-eslint/eslint-plugin": "^6.7",
        "@typescript-eslint/parser": "^6.7",
        "aws-sdk-client-mock": "^3.0.0",
        "eslint": "^8.51.0",
        "eslint-config-prettier": "^8.8.0",
        "eslint-plugin-jest": "^27.2.1",
        "eslint-plugin-prettier": "^4.2.1",
        "eslint-plugin-unused-imports": "^2.0.0",
        "husky": "^8.0.3",
        "jest": "^29.5.0",
        "json-schema-to-ts": "^1.5.0",
        "prettier": "^2.8.7",
        "serverless": "^3.0.0",
        "serverless-bundle": "^6.0.0",
        "serverless-offline": "^12.0.4",
        "serverless-plugin-aws-alerts": "^1.7.5",
        "snyk": "^1.1154.0",
        "ts-jest": "^29.1.0",
        "ts-node": "^10.4.0",
        "tsconfig-paths": "^3.9.0",
        "typescript": "^4.3.5"
    }
}

@nebrelbug
Copy link
Collaborator

@bbbco I don't think this is an issue with Eta -- I'd recommend opening an issue in serverless.

@tternes
Copy link

tternes commented Nov 4, 2023

I was running into this same issue and eventually tracked it down to ts-node using typescript 4.x.x. When I moved my project to typescript 5.x, things worked as documented.

Since your package file includes typescript 4.3.5, it's possible that's what you're running in to here. Since I see ts-node in your package file too, you can check to see what it's using with the -vv flag:

$ npx ts-node -vv          
ts-node v10.9.1
node v18.18.2
compiler v5.2.2

This might be worth noting in the docs, @nebrelbug. It was an easy fix once I understood the issue, but it took a while to track down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants