Closed dfernandez79 closed 3 months ago
Hey @dfernandez79 -- thank you for your suggestion! I chatted with the rest of the team about this change.
Ideally, we agree that being able to do import type {Variable} from "@figma/plugin-typings";
is much better developer experience than what we currently have so far. However, we are a bit concerned that it might be a breaking change, and we're hesitant to take on something with that sort of maintenance complexity.
However! If you'd like to write up a README change with additional instructions, we'd be happy to consider it 🙂
The README instructions indicate that you should use
typeRoots
to access the Figma plugin types because they are part of the host environment.However, file paths are problematic when the project is in a monorepo because the
@figma
directory insidenode_modules
may be hoisted. Since TypeScript 5.1, the lookup upward is disabled: https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/#explicit-typeroots-disables-upward-walks-for-node_modules-typesAn alternative is to use
types
and specify the global packages. However, using@figma/plugin-typings
alone will not work as theplugin-api
types are referenced but not exported. Library users should also add@figma/plugin-typings/plugin-api
totypes
if they want this option.I understand the reason for the global types, and it's necessary for global objects like
figma
or__uiFiles__
.However, for the plugin API, the DX is much better if users can do the following:
The benefits are:
typeRoots
ortypes
to use the type.If that is not an option, additional instructions in the README file could be helpful. (I can volunteer to do a first pass for that).