ä»äºã§å¿æ®ºããæ°å³ã®ããä¹ ã ã®æ´æ°ã
playwright-ruby-clientã«ãããªããåæ¸ããã£ã¦issueãé£ãã§ããã
å人çã«ã¯GitHub Copilotã«ã©ã£ã·ã浸ãã£ã¦ãã¦ããRubyã ã£ããã¹ã¤ã«åãããããï¼ãã£ã¦èããªãã ãã©ãplaywright-ruby-clientã«é¢ãã¦ã¯ã¦ã¼ã¶ã触ãã³ã¼ãã¯å ¨é¨èªåçæãã¦ããã®ã§ãã³ã¼ãçæã¹ã¯ãªããã«ã¡ããã£ã¨è¿½è¨ãããæã§åå®ç¾©æ¸ããªãã¦ãRBSãèªåçæã§ããããããªããï¼ã¨è©¦ãã¦ã¿ãã
ã©ãããç¶æ ã«ããªãã¨ãããªãã
RBSã"使ã"å´ã¤ã¾ããã©ã¤ãã©ãªã使ã£ã¦ã³ã¼ããæ¸ãå´ã®è©±ã¯ãããã¨ããããã§ã¦ããããGemãéçºãã¦ãã人ã¯ä½ãããã°ããã®ãï¼ã¨ããã®ã¯ãããªã«æ å ±ããªãã
å¯ä¸ããã®è¨äºâãã¾ãã«ãããç´¹ä»ãã¦ããã
çµè«ããè¨ãã¨ãã©ã¤ãã©ãªã®éçºè
ããããªãã¨ãããªããã¨ã¯è³æ¥µåç´ã§ã sig/your_library.rbs
ã®ãã¡ã¤ã«ãå梱ããã ã ã
. âââ CODE_OF_CONDUCT.md âââ Gemfile âââ Gemfile.lock âââ LICENSE.txt âââ README.md âââ Rakefile âââ bin â  âââ console â  âââ setup âââ lib â  âââ playwright â  âââ playwright.rb â  âââ playwright_api âââ pkg âââ playwright.gemspec âââ sig ââ ããã追å â  âââ playwright.rbs âââ spec
ã©ããªåå®ç¾©ãæ¸ããªãã¨ãããªãã®ã
åå®ç¾©ã¯ãããªãæ¸ãã¨è¨ããã¦æè¦ã§æ¸ãããã®ã§ã¯ãªããã¾ãã¯TypeProfã§éå½¢ãä½æããã
typeprof lib/playwright_api/*.rb -I lib/playwright -o sig/_playwright.rbs
ããã ãã§å²ã¨ããã£ã½ãåå®ç¾©ã¯ä½ãããã
ãã¨ã¯ã sig/_playwright.rbsãåèã«ã sig/playwright.rbs
ãé å¼µã£ã¦ä½ãã
ããã«ãããTypeProfã«é£ããã¦ã¿ã¦ãæ¸ããåå®ç¾©ã«ãã¹ãç¡ããã確èªããã
typeprof sig/playwright.rbs lib/playwright_api/*.rb -I lib/playwright -o sig/_playwright.rbs
rbs validateãªã©ãããããtypeprofã ãã§ãçµæ§ãããã
ããããªã¨ãã©ãæ¸ãã°ããã®ï¼ãã£ã¦çåã¯ãï¼å²ããâã®è¨äºãã¿ã¦è§£æ±ºã§ãããpockeããç¥è¨äºã§ãã
TypeProfã® "unhandled exception" åé¡
TypeProfã«é£ãããrbsãã¡ã¤ã«ã«ä¸åãããã¨ã "unhandled exception" ã£ã¦ããã¨ã©ã¼ãåºã¦ï¼åããã£ãã
playwright-ruby-clientã®åæ å ±ããã£ã½ãRBSãèªåçæã§ãããã©ãTypeProgã«é£ãããã¨unhandled exceptionã«ãªããª... pic.twitter.com/Xgafi3rqX7
— Yusuke Iwaki (@yi01imagination) 2023å¹´1æ15æ¥
çµè«ã以ä¸ã®ï¼ã¤ããããã©ããã§ããã
- ãã©ã¡ã¼ã¿åã "type" ã ã¨ãã¡
- ArrayãHashã¯
Array[untyped]
Hash[untyped, untyped]
ã£ã¦æ¸ããªãã¨ãã¡
åãæ¸ãã¦ã¿ãçµæ...
RBSããµãã¼ããã¦ããã£ã¦ç±å¼ãã¦ããRubyMineãã¤ã³ã¹ãã¼ã«ãã¦ã対å¿åå¾ã®åããã¿ã¦ã¿ãã
ãã¨ãã¨ããããªæããã»ã¨ãã©ä½ãè£å®ãå¹ããªãããããªãVSCodeãSublime Textã§ååãã£ã¦ãããã
対å¿å¾ã¯ãããªæãããã³ã¼ãè£å®ã»ããããåæ¸ããã£ã¦è¨ã人éã«ã¨ã£ã¦ã¯ã¾ãå¬ãããã ãããªã¨ããçµæã
ã§ãGitHub Copilotã¯ãã£ã¨ãããã...
åãæ¸ãæ¸ããªãã«ããããããCopilotã¯ãã®ã¬ãã«ã§è£å®ãã¬ã³ã¬ã³ãã¦ããâ
- ã©ã¡ããã¨ããã¨èªåã®ã©ã¤ãã©ãªã®ãµã³ãã«ã³ã¼ããä¸ã®ä¸ã«ãã³ãã³åºãã¦ããã»ãããCopilotã«ããè£å®ç²¾åº¦ãä¸ãã£ã¦ãã¦ã¼ã¶ã«ã¨ã£ã¦ã¯ããããããã§ã¯ï¼
- ã¾ã 人æ°ã®ãªãã©ã¤ãã©ãªã«éã£ã¦ã¯RBSæ¸ããã»ãããããã
ã¨ããææã«è½ã¡çãã
ã¾ã¨ã
Gemãèªåã§ä½ã£ã¦ã人㯠sig/your_library.rbs
ã足ãã ãã§ãåæ¸ããã«ã¯çããããã
è足: ãåæ¸ããã¨è¨ã£ãããã«ã¯è²¬ä»»ãï¼
GitHub Copilotã«ã©ã£ã·ããªèº«ã¨ãã¦ã¯ãããªãã¨ãªãã³ã¼ãã®è£å®å¹ãã¦ã»ãããããããããã®ã¬ãã«ã§ãåãæ¸ããã¨ããã®ã¯Rubyã«ããã¦ã¯æ£ãããªãã¨æãã
Add type signatures (RBS) · Issue #239 · YusukeIwaki/playwright-ruby-client · GitHub
ãã®æã®issueãæ¾ãæããã®ã¯ãèãããã£ããã¨ãã¦ã¯ãããããã£ããã®ã®ããåæ¸ããã£ã¦äººã«è¨ãããã«ã¯ãã£ããè°è«ããã£ã¼ãããã¯ãã¦ããï¼ã£ã¦ã®ãæ¬é³ã