Closed SoYoung210 closed 2 years ago
See #90
I looked at the linked issues, and if I change it to "lib": ["es6"],
type error occurs in the react render code.
import React from 'react';
import ReactDOM from 'react-dom';
function App() {
return <div>hello</div>;
}
/*
Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
*/
ReactDOM.render(<App />, document.getElementById('figma-react-template'));
Anyway, this is a duplicate issue, so I'm closing this issue!
You can avoid this issue this way https://github.com/figma/plugin-typings/issues/90#issuecomment-969392520
Thanks!
and it works. 😄
/// <reference types="@figma/plugin-typings/plugin-api" />
declare global {
const figma: PluginAPI
const __html__: string
const __uiFiles__: {
[key: string]: string
}
}
export { }
tsconfig.json
{
"typeRoots": [
"src/customTypings",
"node_modules/@types"
],
}
Description
When using figma plugin typing with typescript, an error occurs due to duplicate global type declaration.
Reproduce
tsconfig.json
, alsofigma.d.ts
in rootpnpm build
(or justpnpm build:type
)Q1. Why are these types declared global in figma plugin? It was added from https://github.com/figma/plugin-typings/pull/52, isn't it necessary to configure
DOM
lib to extend intsconfig.json
?must extends
DOM
cause of react(in my project)Q2. If keep the current type declaration, how can I bypass the type error in the reproduction repo?