Our pure JavaScript Scheduler component


Post by wfitch »

When extending any of the models and declaring a property, I'm getting a TS error: Scheduler/Appointment.ts: TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript.
If you have already enabled that plugin (or '@babel/preset-typescript'), make sure that it runs before any plugin related to additional class features:

My babel.config.js:

module.exports = {
  presets: [
    "@babel/preset-env",
    "@babel/preset-typescript"
  ],
  plugins: [
    ["@babel/plugin-transform-typescript", {allowDeclareFields: true}],
    "@babel/plugin-proposal-class-properties"
  ]
}

Any help would be appreciated.


Post by tasnim »

Hi,

Hard to suggest a fix without reproducing it locally, But you can still try the steps described below

  1. Make sure you have the TypeScript preset installed for Babel. Run the following command:
    npm install --save-dev @babel/preset-typescript
  2. Update babel.config.js
    module.exports = {
      presets: [
        "@babel/preset-env",
        "@babel/preset-typescript"
      ],
      plugins: [
        ["@babel/plugin-proposal-class-properties", { loose: true }]
      ]
    };
  3. After that remove node_modules folder and then run npm i

If that doesn't help, please share a runnable test case with us so that we can debug the issue for you.


Post by wfitch »

Didn't work, unfortunately. Here is my tsconfig:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "baseUrl": "./src",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "typeRoots": ["./typings"],
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/config.js"],
  "exclude": ["node_modules"]
}

Post by tasnim »

Hi,

Thanks for sharing the tsconfig file but it's really hard to say what's wrong without debugging the issue. Could you please share a runnable test app with us so we can reproduce it locally and debug the issue for you? A runnable test case will make the assistance much faster.


Post by wfitch »

Is there an alternative to using declare in class properties and getting it to work with Scheduler Pro? This is a real pain to deal with.


Post by wfitch »

I resolved this by migrating from CRA to vite.


Post by mats »

Thanks for sharing!


Post Reply