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

"error is of type unknown" #205

Closed
ftjfo opened this issue Apr 27, 2023 · 3 comments · Fixed by webrpc/gen-typescript#8
Closed

"error is of type unknown" #205

ftjfo opened this issue Apr 27, 2023 · 3 comments · Fixed by webrpc/gen-typescript#8
Assignees

Comments

@ftjfo
Copy link

ftjfo commented Apr 27, 2023

const buildResponse = (res: Response): Promise<any> => {
  return res.text().then(text => {
    let data
    try {
      data = JSON.parse(text)
    } catch(error) {
      throw WebrpcBadResponseError.new({
        status: res.status,
        cause: `JSON.parse(): ${error.message || ''}: response text: ${text}`},
      )
    }
    if (!res.ok) {
      const code: number = (typeof data.code === 'number') ? data.code : 0
      throw (webrpcErrorByCode[code] || WebrpcError).new(data)
    }
    return data
  })
}

I get an "error is of type unknown" from the generated code. Guess this is just a "type error", and might not affect execution.
For your information, I am running the v0.11.0 release.

@VojtechVitek
Copy link
Contributor

VojtechVitek commented Jun 5, 2023

@ftjfo Can you please provide more information?

Do you run v0.11.0 server and v0.11.0 client too? What server target do you use?
Can you share more details about the error you're getting (console.error() or JSON.stringify()) and when you're getting it?

@ftjfo
Copy link
Author

ftjfo commented Jun 6, 2023

// Code generated by [email protected] with typescript generator. DO NOT EDIT.

The error seems to come from the TypeScript program:
[{
	"resource": "/xxx/src/services/programx.gen.ts",
	"owner": "typescript",
	"code": "18046",
	"severity": 8,
	"message": "'error' is of type 'unknown'.",
	"source": "ts",
	"startLineNumber": 597,
	"startColumn": 33,
	"endLineNumber": 597,
	"endColumn": 38
}]

I seem to run Typescript 4.6.2 with this config:

{
  "compilerOptions": {
    "allowJs": true,
    // `baseUrl` must be placed on the extending configuration in devland, or paths won't be recognized
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    // Needed to address https://github.com/quasarframework/app-extension-typescript/issues/36
    "noEmit": true,
    "resolveJsonModule": true,
    // Avoid cross-os errors due to inconsistent file casing
    "forceConsistentCasingInFileNames": true,
    "sourceMap": true,
    "strict": true,
    "target": "esnext",
    "isolatedModules": true,
    "useDefineForClassFields": true,
    // Fix Volar issue https://github.com/johnsoncodehk/volar/issues/1153
    "jsx": "preserve",
    "lib": ["esnext", "dom"],
    "paths": {
      "src/*": ["src/*"],
      "app/*": ["*"],
      "components/*": ["src/components/*"],
      "layouts/*": ["src/layouts/*"],
      "pages/*": ["src/pages/*"],
      "assets/*": ["src/assets/*"],
      "boot/*": ["src/boot/*"],
      "stores/*": ["src/stores/*"]
    }
  },
  // Needed to avoid files copied into 'dist' folder (e.g. a `.d.ts` file inside `src-ssr` folder)
  // to be evaluated by TS when their original files has been updated
  "exclude": ["dist", ".quasar", "node_modules"]
}

image

Hope this is of help. This is not a critical error as I see it, just a small violation of the Typescript parser perhaps?

@VojtechVitek
Copy link
Contributor

Thanks. I didn't see this error locally.

@kolberg-dev mind help me find a fix for this error?

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

Successfully merging a pull request may close this issue.

3 participants