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

Failed to parse static properties from plugin #26320

Closed
ItsmeMing opened this issue Mar 17, 2024 · 1 comment
Closed

Failed to parse static properties from plugin #26320

ItsmeMing opened this issue Mar 17, 2024 · 1 comment

Comments

@ItsmeMing
Copy link

ItsmeMing commented Mar 17, 2024

Environment

  • Operating System: Windows_NT
  • Node Version: v18.12.0
  • Nuxt Version: 3.11.0
  • CLI Version: 3.10.1
  • Nitro Version: 2.9.4
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: app, runtimeConfig, devtools, css, imports, modules, pinia, tailwindcss, primevue, googleFonts, vite
  • Runtime Modules: @pinia/nuxt@0.5.1, @nuxtjs/tailwindcss@6.11.4, nuxt-primevue@0.3.1, @nuxtjs/i18n@8.2.0, @nuxtjs/google-fonts@3.2.0, nuxt-icon@0.6.9, @vueuse/nuxt@10.9.0, @nuxt/image@1.4.0
  • Build Modules: -

Reproduction

plugins/axios.ts

import { default as Axios } from 'axios';
import type { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import type { BaseResponse } from '~/@types';

export default defineNuxtPlugin((nuxtApp) => {
  const axios = Axios.create({ baseURL: nuxtApp.$config.public.BASE_URL });
  const toastService = useToastService();
  const token = useCookie(`${nuxtApp.$config.public.APP_NAME}_token`);

  axios.interceptors.request.use((config: InternalAxiosRequestConfig) => {
    if (token) {
      config.headers.Authorization = `Bearer ${token.value}`;
    }
    return config;
  });

  axios.interceptors.response.use(
    <T>(response: AxiosResponse) => {
      let res: Promise<never> | AxiosResponse<BaseResponse<T>>;
      switch (response.data.status_code) {
        case 401:
          token.value = null;
          res = Promise.reject(response);
          location.reload();
          break;
        case 403:
          res = Promise.reject(response);
          break;
        case 422:
          res = Promise.reject(response);
          break;
        case 500:
          res = response;
          break;
        default:
          res = response;
          break;
      }
      return res;
    },
    (error: AxiosError) => {
      toastService.add({ severity: 'error', summary: 'ERROR', detail: error.message, life: 5000 });
      return Promise.reject(error.message);
    }
  );

  return {
    provide: {
      axios
    }
  };
});

Describe the bug

Got this warning after upgrading nuxt to 3.11.0:

Failed to parse static properties from plugin plugins/axios.ts. Transform failed with 2 errors:                                                                                   2:59:23 AM
<stdin>:19:34: ERROR: The character ">" is not valid inside a JSX element
<stdin>:20:10: ERROR: Expected "}" but found "res"

  <stdin>:19:34: ERROR: The character ">" is not valid inside a JSX element
  <stdin>:20:10: ERROR: Expected "}" but found "res"
  at failureErrorWithLog (node_modules\esbuild\lib\main.js:1651:15)
  at node_modules\esbuild\lib\main.js:849:29
  at responseCallbacks.<computed> (node_modules\esbuild\lib\main.js:704:9)
  at handleIncomingPacket (node_modules\esbuild\lib\main.js:764:9)
  at Socket.readFromStdout (node_modules\esbuild\lib\main.js:680:7)
  at Socket.emit (node:events:513:28)
  at addChunk (node:internal/streams/readable:324:12)
  at readableAddChunk (node:internal/streams/readable:297:9)
  at Readable.push (node:internal/streams/readable:234:10)
  at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

Warning is gone when i delete generic types. Plugin is still working btw.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

resolved in #26314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants