-
Notifications
You must be signed in to change notification settings - Fork 27
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
Typescript definition generation for resources.Resources has a compilation error due to Fn::Transform #27
Comments
Hi @remcoabc and thanks for submitting this issue. Could you please provide your serverless.ts file :) ? |
import { AWS } from '@serverless/typescript';
import { helloWorld } from './functions';
const serverlessConfiguration: AWS = {
service: 'remco-stage',
frameworkVersion: '2',
plugins: [
'serverless-webpack',
'serverless-pseudo-parameters',
],
custom: {
webpack: {
webpackConfig: './webpack.config.js',
includeModules: true,
keepOutputDirectory: true,
},
},
provider: {
name: 'aws',
runtime: 'nodejs12.x',
apiGateway: {
shouldStartNameWithService: true,
},
},
functions: {
helloWorld,
},
};
module.exports = serverlessConfiguration; |
Thanks @remcoabc. Your service file looks perfectly fine. Could you share as well your node version and your package.json for better understanding (i'm particulary interested in your TypeScript version). Could you let me know as well your |
"dependencies": {
"@dazn/lambda-powertools-logger": "^1.28.1",
"@dazn/lambda-powertools-pattern-basic": "^1.28.1",
"aws-sdk": "^2.828.0",
"axios": "^0.21.1",
"dotenv": "^8.2.0",
"serverless-pseudo-parameters": "^2.5.0",
"source-map-support": "^0.5.10",
"ulid": "^2.3.0"
},
"devDependencies": {
"@aws-sdk/types": "^3.0.0",
"@serverless/typescript": "^2.23.0",
"@types/aws-lambda": "^8.10.17",
"@types/jest": "^26.0.18",
"@types/node": "^10.12.18",
"@types/serverless": "^1.72.5",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"eslint": "^7.17.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-plugin-import": "^2.22.1",
"fork-ts-checker-webpack-plugin": "^3.0.1",
"jest": "^26.6.3",
"serverless": "^2.15.0",
"serverless-appsync-plugin": "^1.4.0",
"serverless-export-env": "^1.4.0",
"serverless-iam-roles-per-function": "^3.0",
"serverless-manifest-plugin": "^1.0.7",
"serverless-webpack": "^5.2.0",
"ts-jest": "^26.4.4",
"ts-loader": "^5.3.3",
"ts-node": "^8.10.2",
"typescript": "^3.9.7",
"webpack": "^4.29.0",
"webpack-node-externals": "^1.7.2"
} I am using node version 12.20.1 |
Thanks @remcoabc, can you provide your
Can you confirm the above solution solves your problem ? |
I have the node_modules folder already ignored as you can see in my tsconfig.json: {
"compilerOptions": {
"lib": [
"es5",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020"
],
"removeComments": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"sourceMap": true,
"target": "es2017",
"outDir": "dist",
"allowSyntheticDefaultImports": true,
"module": "commonjs",
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": ["./**/*.ts", "./**/*.js"],
"exclude": [
"node_modules/**/*",
".serverless/**/*",
".webpack/**/*",
"_warmup/**/*",
".vscode/**/*",
"dist/**/*"
]
} |
I had the same issue. Updated the AWS.resources.Resources type with ( | ) to resolve it: Resources?: ({
"Fn::Transform"?: {
...
};
} | {
[k: string]: {
...
};
}); |
This will indeed work if I am able to change the files. Problem is that since I use it in my ci/cd pipeline it will be redownloaded. This means that every change I do to the src code of this library does not have any effect. It would be a solution if that is added in this repo but since the index.d.ts file is auto generated it needs to be fixed somewhere else I think. |
Agreed, it needs to be fixed somewhere upstream. Hopefully this hints at what we're seeing. Just a temporary option to keep typing instead of casting as any. functions: {
helloWorld,
} as any |
@grimm2x @remcoabc thanks to both of you for your insights.
|
how/where can i contribute on this issue? aksing because i stumbled upon #12 |
I've fixed type declarations and created PR #44 |
There currently is a PR ongoing in |
I'm still running into this issue on package.json{
"name": "webhooks-serverless",
"version": "1.0.0",
"description": "Serverless aws-nodejs-typescript template",
"main": "serverless.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": ">=14.15.0"
},
"dependencies": {
"@middy/core": "^1.5.2",
"@middy/http-json-body-parser": "^1.5.2",
"source-map-support": "^0.5.19"
},
"devDependencies": {
"@serverless/typescript": "^2.65.0",
"@types/aws-lambda": "^8.10.71",
"@types/node": "^14.14.25",
"json-schema-to-ts": "^1.5.0",
"serverless": "^2.23.0",
"serverless-webpack": "^5.3.5",
"ts-loader": "^8.0.15",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"tsconfig-paths-webpack-plugin": "^3.3.0",
"typescript": "^4.1.3",
"webpack": "^5.20.2",
"webpack-node-externals": "^2.5.2"
},
"author": "The serverless webpack authors (https://github.com/elastic-coders/serverless-webpack)",
"license": "MIT"
} tsconfig.json{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"lib": ["ESNext"],
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"sourceMap": true,
"target": "ES2020",
"outDir": "lib"
},
"include": ["src/**/*.ts", "serverless.ts"],
"exclude": [
"node_modules/**/*",
".serverless/**/*",
".webpack/**/*",
"_warmup/**/*",
".vscode/**/*"
],
"ts-node": {
"require": ["tsconfig-paths/register"]
}
} Error message
This error disappears if I add |
For my situation (listed below), I needed to apply both workarounds (i.e. both skipLibCheck and ignore node_modules) to fix this.
|
It seems as if this error is still present when running |
Until / ever this gets fixed another good workaround is to use with above workaround in your dependent projects |
Whenever I use the intended AWS type (as described in the readme) it throws the following compilation error:
TS2411: Property '"Fn::Transform"' of type '{ Name: string; Parameters?: { [k: string]: unknown; }; }' is not assignable to string index type '{ Type: string; Properties?: { [k: string]: unknown; }; CreationPolicy?: { [k: string]: unknown; }; DeletionPolicy?: string; DependsOn?: string[]; Metadata?: { [k: string]: unknown; }; UpdatePolicy?: { [k: string]: unknown; }; UpdateReplacePolicy?: string; Condition?: string; }'.
The text was updated successfully, but these errors were encountered: