sstur / nbit

A zero-dependency, strongly-typed web framework for Bun, Node and Cloudflare workers
66 stars 4 forks source link

Property 'request' of exported class expression may not be private or protected.ts(4094) #15

Closed svnty closed 9 months ago

svnty commented 10 months ago

Screen Shot 2023-12-13 at 7 17 06 pm

What am I doing wrong?

Screen Shot 2023-12-13 at 7 17 50 pm

sstur commented 10 months ago

This is strange, I've not seen this one before. And your code looks fine. What version of TS are you on? Ensure you're using the same version in VS Code and in the codebase. At the terminal you can run cat node_modules/typescript/package.json | grep version and in VS code click on the curly braces near the word "TypeScript" in the status bar.

image

If you have a minimal reproducible example that I can run on my side, that would help.

sstur commented 10 months ago

Oh, also could you paste the contents of your tsconfig file?

According to this issue, it might be related to having "declaration emit enabled" in your config.

anonymous classes can't have private or protected members if declaration emit is enabled

svnty commented 10 months ago

"version": "5.3.3",

My source code is available here https://github.com/medicamina/api/tree/main

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "esnext",
    "target": "esnext",
    "moduleResolution": "bundler",
    "moduleDetection": "force",
    "allowImportingTsExtensions": true,
    "noEmit": true,
    "composite": true,
    "strict": true,
    "downlevelIteration": true,
    "skipLibCheck": true,
    "jsx": "react-jsx",
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "allowJs": true,
    "types": [
      "bun-types" // add Bun global
    ]
  }
}
svnty commented 10 months ago

What's strange is that the code compiles and runs without errors or warnings, it's just VS code complaining about types

svnty commented 9 months ago

I fixed it

The troublemaker Screen Shot 2024-01-02 at 9 00 13 pm

The new problem Screen Shot 2024-01-02 at 9 05 37 pm

VS Code's fix Screen Shot 2024-01-02 at 9 05 43 pm

Source code https://github.com/svnty/nbit/blob/main/packages/core/src/core/CustomRequest.ts