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

TypeScript support #55

Open
Splicer97 opened this issue Nov 10, 2022 · 3 comments
Open

TypeScript support #55

Splicer97 opened this issue Nov 10, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed low priority

Comments

@Splicer97
Copy link

How about implement typescript support for your package?

@TheGreatRefrigerator
Copy link
Collaborator

Would be awesome, but currently not in our scope, as i don't have any experience with it, yet...
Feel free to contribute with a PR though!

@TheGreatRefrigerator TheGreatRefrigerator added enhancement New feature or request help wanted Extra attention is needed labels Nov 14, 2022
@Basile001
Copy link

Basile001 commented Dec 16, 2022

Hello,

I use a AWS lambda with a runtime Node.js 14. I tried to import openrouteservice-js.

But when I try to run my code the following error appears :

{
    "errorType": "TypeError",
    "errorMessage": "o is not a function",
    "stack": [
        "TypeError: o is not a function",....
}

Here what I've done:

mylambda.ts :

import Openrouteservice from "openrouteservice-js";

.....
exports.generateGpxHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => {
    const { httpMethod, body, headers } = event;
....

// the line causing error
    const directionsService = new Openrouteservice.Directions({ api_key: OPENROUTE_API_KEY });
.............

}

I declare a types.d.ts file :

declare module "openrouteservice-js";

in my package.json :


"dependencies": {
        "aws-sdk": "^2.1238.0",
        "@aws-sdk/client-dynamodb": "3.194.0",
        "@aws-sdk/lib-dynamodb": "3.194.0",
        "jwt-decode": "3.1.2",
        "uuid": "9.0.0",
        "openrouteservice-js": "0.2.0"
    },

my tsconfig.json:


{
  "compilerOptions": {
    "target": "ES6",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "preserveConstEnums": true,
    "outDir": "./bin",
    "sourceMap": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}

I also use a webpack.conf.js file similar to my open source project:

https://github.com/Basile001/another-aws-example/blob/master/back/webpack.config.js

I don't understand why my lambda return this error, I miss something but I don't know what it is ?

I tried the require way instead of the import way but the result is the same, or to mess up with my tsconfig file but nothing change.

Thank you for the help in advance.

Kind regards,

Basile

@didierdemaeyer
Copy link

Perhaps this can be used to generate the TypeScript declaration file(s).

https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed low priority
Projects
None yet
Development

No branches or pull requests

4 participants