figma / plugin-typings

Typings for the Figma Plugin API
MIT License
190 stars 44 forks source link

Cannot redeclare block-scoped variable #281

Closed jkevingutierrez closed 4 months ago

jkevingutierrez commented 6 months ago

I'm getting a couple of issues when I run tsc using this package:

Cannot augment module 'console' with value exports because it resolves to a non-module entity.

Cannot redeclare block-scoped variable 'fetch'.

image
Roystbeef commented 6 months ago

@jkevingutierrez would you be able to share your tsconfig.json?

I think you'll want something like:

{
  "compilerOptions": {
    "lib": ["ESNext"], // Explicitly don't include DOM since the plugin code is running in Figma's JS runtime and not the browser directly
    "types": ["@figma/plugin-typings"]
  }
}
jkevingutierrez commented 6 months ago

Yep, I have something similar.

This is my tsconfig.json

{
  "compilerOptions": {
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "declaration": true,
    "forceConsistentCasingInFileNames": true,
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "pretty": true,
    "sourceMap": true,
    "strict": true,
    "target": "es2018",
    "baseUrl": "./",
    "moduleResolution": "node",
    "module": "ESNext",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "outDir": "dist",
    "typeRoots": [
      "./node_modules/@types",
      "./node_modules/@figma"
    ]
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "./src/**/*.ts",
    "./*.ts"
  ]
}
Roystbeef commented 6 months ago

@jkevingutierrez Updating your tsconfig to:

{
  "compilerOptions": {
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "declaration": true,
    "forceConsistentCasingInFileNames": true,
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "pretty": true,
    "sourceMap": true,
    "strict": true,
    "target": "es2018",
    "baseUrl": "./",
    "moduleResolution": "node",
    "module": "ESNext",
    "lib": ["esnext"],
    "outDir": "dist",
    "typeRoots": [
      "./node_modules/@types",
      "./node_modules/@figma"
    ]
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "./src/**/*.ts",
    "./*.ts"
  ]
}

should resolve the issue! LMK if it works!

Roystbeef commented 4 months ago

I'm going to close this due to inactivity. @jkevingutierrez please feel free to re-open this or create a new issue if the above didn't work