Skip to content

Commit

Permalink
Add standalone types (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymichael authored Sep 16, 2024
1 parent 7a052fc commit 74dd3c8
Show file tree
Hide file tree
Showing 3 changed files with 599 additions and 2 deletions.
59 changes: 58 additions & 1 deletion test-usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ rm -rf test-artifacts
mkdir -p test-artifacts
pushd test-artifacts

echo "Running test 1 (include types in typeRoots so all types are available ambiently)"
mkdir test-1
pushd test-1

cat > package.json << EOF
{}
EOF
Expand Down Expand Up @@ -176,7 +180,60 @@ EOF

npm install typescript
npm install @figma/plugin-typings
npm install ../
npm install ../../
npx tsc --noEmit

popd

echo "Running test 2 (import and use types selectively)"
mkdir test-2
pushd test-2

cat > package.json << EOF
{}
EOF

cat > tsconfig.json << EOF
{
"compilerOptions": {
"moduleResolution": "bundler",
"target": "es6",
"lib": ["es6"],
"strict": true,
"typeRoots": []
}
}
EOF

cat > code.ts << EOF
/**
* Test file to test widget-api-standalone.d.ts
*/
import type {
WidgetJSX,
FrameProps,
WidgetPropertyMenuItem,
} from '@figma/widget-typings/widget-api-standalone'
const item: WidgetPropertyMenuItem = {
itemType: 'action',
tooltip: 'Test',
propertyName: 'test',
}
const frameProps: FrameProps = {
width: 100,
height: 100,
}
// @ts-expect-error No ambient types
type FigmaDeclarativeNodeAlias = FigmaDeclarativeNode
type VectorAlias = WidgetJSX.Vector
EOF

npm install typescript
npm install @figma/plugin-typings
npm install ../../
npx tsc --noEmit

popd
Loading

0 comments on commit 74dd3c8

Please sign in to comment.