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

I found a few possible errors, one which is breaking for me #117

Open
ADRFranklin opened this issue Dec 22, 2023 · 3 comments
Open

I found a few possible errors, one which is breaking for me #117

ADRFranklin opened this issue Dec 22, 2023 · 3 comments

Comments

@ADRFranklin
Copy link

So I ignored a few of the issues since, this project is still early, and they were only type issues that I could work around, but with version 0.3.0 another issue has cropped up that breaks things for me.

So the major issue that breaks things for me now, is the fact then after updating to 0.3.0 I am presented with

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './errors' is not defined by "exports" in /workspace/node_modules/@nahkies/typescript-koa-runtime/package.json

and the small but workaround issues that I have found since day one of using this, is also related in a way to the above, but not caused by it.

Cannot find module '@nahkies/typescript-koa-runtime/server' or its corresponding type declarations.ts(2307)
Cannot find module '@nahkies/typescript-koa-runtime/zod' or its corresponding type declarations.ts(2307)

it seems the runtime has no issues with these paths, but typescript does, and adding /src/ after @nahkies/typescript-koa-runtime path fixes the typescript issues, so it's just a simple path rewrite that needs to happen for the typescript types.

One last possible issue that I think you overlooked was you are linking joi definitions for zod.

It's possible one or more of these issues are related to my setup, so do let me know, thanks.

@ADRFranklin
Copy link
Author

Okay, ignore the first issue, I had updated the runtime, but yarn apparently didn't do it properly, just removed and reinstalled the packages and that fixed the issue.

mnahkies added a commit that referenced this issue Jan 5, 2024
mnahkies added a commit that referenced this issue Jan 5, 2024
(note: the public API between `joi` and `zod` parts of the runtime
should be identical, so this should effectively be a noop)

relates #117
@mnahkies
Copy link
Owner

mnahkies commented Jan 5, 2024

Raised #119 to address the .d.ts issue, though it should be a red herring as by design the public API to the zod and joi portions of the runtime is expected to be identical.

For the:

Cannot find module '@nahkies/typescript-koa-runtime/server' or its corresponding type declarations.ts(2307)
Cannot find module '@nahkies/typescript-koa-runtime/zod' or its corresponding type declarations.ts(2307)

It would be helpful to see your tsconfig.json and the typescript version - my best guess is it will be caused by the moduleResolution parameter (docs). I'm fairly certain it needs to be:

"moduleResolution": "Node16",

and would recommend using https://github.com/tsconfig/bases/tree/main#node-20-tsconfigjson or equivalent as a base configuration which sets this by default

@ADRFranklin
Copy link
Author

ADRFranklin commented Jan 5, 2024

{
  "compilerOptions": {
    /* Base Options */
    "esModuleInterop": true,
    "skipLibCheck": true,
    "target": "esnext",
    // "verbatimModuleSyntax": false,
    "allowJs": true,
    "resolveJsonModule": true,
    "moduleDetection": "force",
    /* Strictness */
    "strict": true,
    "noUncheckedIndexedAccess": true,
    /* If transpiling with Typescript */
    "moduleResolution": "node",
    "module": "commonjs",
    "outDir": "dist",
    "sourceMap": true,
    "lib": [
      "es2022"
    ],
    /* Others */
    "checkJs": false,
    "noEmitOnError": true,
    "rootDir": ".",
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true,
    "strictNullChecks": true,
    "pretty": true,
    "noEmit": false,
    "declarationMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "preserveConstEnums": true,
    "importHelpers": true,
    "noErrorTruncation": true,
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ],
      "@nahkies/typescript-koa-runtime/*": [
        "../../node_modules/@nahkies/typescript-koa-runtime/dist/*"
      ],
    },
    "typeRoots": [
      "../../node_modules/@types",
      "./src/types",
    ],
    "types": [],
  },
  "exclude": [
    "node_modules",
    "dist",
    "tests"
  ],
  "include": [
    "./src/**/*"
  ]
}

typescript version: 4.9

I've added a types workaround for your package, which fixed the issues in this, but as requested here is my tsconfig.json file. I can't remember what I based this tsconfig off, but it was a year ago.

I'll take a look at the config you posted.

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

2 participants