Repository navigation
fix(code-connect): type-check figma templates so bob build passes - #155
Merged
Merged
Conversation
`npm ci` runs `prepare` -> `bob build`, which type-checks the whole project.
The Code Connect templates import the virtual `figma` module but its types
were never registered, so main failed with TS2307 in 30 files (verify job,
run 45841920148).
- register `@figma/code-connect/figma-types-no-require` in tsconfig.json
(no-require variant: the project ships @types/node, whose NodeRequire would
otherwise be shadowed by the figma global `require` declaration)
- add code-connect/template-helpers.ts and route layer lookups through it:
the v2 template API returns `ErrorHandle` instead of throwing, so
`instance.findText('X').textContent` no longer type-checks and would break
the whole snippet on a missing layer
- align the tsconfig snippet in docs/code-connect-guide.md with the real config
HasanGocmen
approved these changes
Nov 27, 2026
|
🎉 This PR is included in version 2.67.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
main(after #154) kırık: verify job'ı daha "Install dependencies" adımında patlıyor — run 45841920148. Sonraki tüm adımlarskipped.npm ci→prepare→bob buildprojedeki tüm dosyaları tip kontrol ediyor. Code Connect template'leriimport figma from 'figma'yapıyor amafigmasanal modülünün tipleritsconfig.json'a hiç eklenmemişti.Fix
tsconfig.json:@figma/code-connect/figma-types-no-requireregister edildi. Taban configtypes: ["react-native", "jest"]verdiği için liste override edilirken ikisi de korundu.-no-requirevaryantı seçildi: projede@types/nodevar,figma-types'ın globalrequiretanımıNodeRequire'ı eziyor.code-connect/template-helpers.ts(yeni): tipler eklenince ortaya çıkan 28 gerçek hata için. Figma v2 template API'si katman bulunamadığında throw etmek yerineErrorHandledöndürüyor, dolayısıylainstance.findText('X').textContentartık tip geçmiyor ve eksik katmanda tüm snippet'i kırardı.findText/getEnumhelper'ları narrowing yapıp boş değere düşüyor; 15 dosyadaki 28 çağrı bunlara taşındı.docs/code-connect-guide.md: tsconfig örneği gerçek konfigle hizalandı + helper kuralı not edildi.Davranış değişikliği yok: üretilen Codé Connect çıktısı aynı, sadece eksik katman durumunda patlamak yerine degrade ediyor.
Verification (local)
npm ci(prepare: storybook-generate + bob build + husky)npm run lint(eslint +tsc --noEmit+ prettier)npm run icons:checknpm run testfigma connect parse --exit-on-unreadable-filespackage-lock.json