Skip to content

Commit a7fab93

Browse files
author
figma-bot
committed
Code Connect v1.1.3
1 parent bc4caf4 commit a7fab93

File tree

67 files changed

+158
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+158
-349
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Code Connect v1.1.3 (11th September 2024)
2+
3+
## Fixed
4+
5+
### HTML
6+
- Fixed an issue where `imports` was incorrectly not included in the TypeScript interface
7+
- Added a note in the [documentation](docs/html.md) that HTML support requires `moduleResolution: "NodeNext"`
8+
9+
### React
10+
- Fixed an issue where `imports` was incorrectly not included in the TypeScript interface (fixes https://github.com/figma/code-connect/issues/159)
11+
112
# Code Connect v1.1.2 (10th September 2024)
213

314
## Fixed

cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@figma/code-connect",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "A tool for connecting your design system components in code with your design system in Figma",
55
"keywords": [],
66
"author": "Figma",
@@ -36,7 +36,7 @@
3636
},
3737
"scripts": {
3838
"dev": "tsx src/cli.ts",
39-
"build": "tsc",
39+
"build": "rm -rf dist && npm run typecheck && tsc",
4040
"build:web": "pnpm build",
4141
"build:webpack": "webpack --mode production",
4242
"test": "npm run test:no-coverage -- --coverage",
@@ -57,7 +57,7 @@
5757
"bundle:cli:mac:arm64": "npm run bundle:cli -- -o bundle-cli/figma-mac-arm64 --target node18-mac-arm64",
5858
"bundle:cli:win": "npm run bundle:cli -- -o bundle-cli/figma-win --target node18-win-x64",
5959
"publish:npm": "npm install && npm run build && npm run bundle:npm-readme:prepare && npm publish --access public; npm run bundle:npm-readme:restore",
60-
"typecheck": "tsc --noEmit"
60+
"typecheck": "tsc --noEmit -p tsconfig-typecheck.json"
6161
},
6262
"devDependencies": {
6363
"@types/cross-spawn": "^6.0.6",

cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/ReactApiComponent.figmadoc.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import figma from '../../..'
1+
import figma from '../../../../../react/index_react'
22

33
import { ReactApiComponent } from './ReactApiComponent'
44

cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/StorybookComponent.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { StoryParameters } from '../../..'
1+
import { StoryParameters } from '../../../../../react/index_react'
22
import { StorybookComponent } from './StorybookComponent'
3+
import React from 'react'
34

45
export default {
56
title: 'StorybookComponent',

cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/StorybookComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ReactNode } from 'react'
2+
import React from 'react'
23

34
interface Props {
45
disabled: boolean

cli/src/connect/__test__/e2e/e2e_parse_command_react.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default figma.tsx\`<ReactApiComponent />\``,
4646
figmaNode: 'https://figma.com/test',
4747
source:
4848
'https://github.com/figma/code-connect/blob/main/cli/src/connect/__test__/e2e/e2e_parse_command/react_storybook/StorybookComponent.tsx',
49-
sourceLocation: { line: 7 },
49+
sourceLocation: { line: 8 },
5050
templateData: { imports: [] },
5151
component: 'StorybookComponent',
5252
label: 'Storybook',

cli/src/connect/__test__/template_rendering_utils.ts

Lines changed: 0 additions & 248 deletions
This file was deleted.

cli/src/connect/api.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ export interface FigmaConnectLink {
127127
url: string
128128
}
129129

130-
export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
130+
// ExampleFnReturnT is the return type of an example function.
131+
// ExtraExampleT allows us to pass in an extra type to the `example` property,
132+
// so that in Storybook, we can use strings to refer to non-hoisted functions
133+
export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown, ExtraExampleT = never> {
131134
/**
132135
* Restricts this figma connect to any variants that fullfill the given filter.
133136
* The filter is a map of Figma variant names to values. Example:
@@ -140,7 +143,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
140143

141144
/**
142145
* Prop mappings for the connected component. This is used to map the values of the component's props
143-
* to the values that are used in Figma, using helper functions like `Figma.boolean`. For example:
146+
* to the values that are used in Figma, using helper functions like `figma.boolean`. For example:
144147
* ```ts
145148
* props: {
146149
* disabled: figma.boolean('Disabled'),
@@ -160,7 +163,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
160163
* @param props
161164
* @returns
162165
*/
163-
example?: (props: T) => ExampleFnReturnT
166+
example?: ((props: T) => ExampleFnReturnT) | ExtraExampleT
164167

165168
/**
166169
* A list of links that will display in Figma along with the examples
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import figma, { html } from '../../../index_html'
2+
3+
figma.connect('ui/button', {
4+
example: () => html`<my-button>Click me</my-button>`,
5+
imports: ['import "@ui/Button"'],
6+
})

cli/src/html/__test__/parser/parser.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,16 @@ describe('HTML Parser', () => {
6565
async () => await testParse('RegularFunctionExampleWithExtraCode.figma.ts'),
6666
).rejects.toThrow('Expected only a tagged template literal as the body of the render function')
6767
})
68+
69+
it('handles imports', async () => {
70+
const result = await testParse('CustomImports.figma.ts', [])
71+
72+
expect(result).toMatchObject([
73+
{
74+
templateData: {
75+
imports: ['import "@ui/Button"'],
76+
},
77+
},
78+
])
79+
})
6880
})

0 commit comments

Comments
 (0)