tiagosiebler / ftx-api

Node.js connector for the FTX.com & FTX.us APIs and WebSockets, with TypeScript & browser support.
https://www.npmjs.com/package/ftx-api
MIT License
123 stars 47 forks source link

🐛 use relative path instead of path alias #53

Closed d3c0d3dpt closed 2 years ago

d3c0d3dpt commented 2 years ago

Closes #

Summary

Fix a path issue on typeGuards.ts.

Using TypeScript to compile a project using ftx-api@1.1.0 will generate the following error:

> tsc

node_modules/ftx-api/lib/util/typeGuards.d.ts:1:31 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

1 import { WsEventTrades } from "src";
                                ~~~~~

Found 1 error.

This PR addresses that issue, allowing a successful compilation.

Local tests were performed by compiling the package and installing it (using npm i ../ftx-api/ftx-api-1.1.1.tgz) and checking if the the compilation was successful.

Checks

d3c0d3dpt commented 2 years ago

I'm glad to help!

Compiling the package as it was yielded no errors, so maybe it's some kind of TS configuration?

tiagosiebler commented 2 years ago

That's my first thought too. Could you share the tsconfig you were using? Perhaps the one in the project needs an adjustment as I don't want this kind of mistake to slip through again

d3c0d3dpt commented 2 years ago

Sure, here it goes:

{
    "compilerOptions": {
        "target": "es2019",
        "module": "commonjs",
        "moduleResolution": "node",

        "baseUrl": ".",
        "outDir": "build",

        "declaration": true,
        "esModuleInterop": true,
        "noImplicitAny": true,
        "sourceMap": false,

        "types": [
            "node"
        ]
    },

    "include": [
        "index.ts",

        "bin/**/*",
        "src/**/*",
        "types/**/*"
    ]
}
tiagosiebler commented 2 years ago

Still not sure why it errored for, but seems like it's the baseUrl option that's the culprit. While set, you can use non-relative paths - which in this case is not desirable. I've removed it and now it throws during build time if the path isn't relative.