Migrate to typescript, vite and vitest#28
Migrate to typescript, vite and vitest#28AntonOfTheWoods wants to merge 1 commit intonk2028:mainfrom
Conversation
Signed-off-by: Anton Melser <anton.melser@outlook.com>
graphemecluster
left a comment
There was a problem hiding this comment.
Thanks for the contribution. We will review them further later.
| ['“', '「'], | ||
| ['”', '」'], | ||
| ['‘', '『'], | ||
| ['’', '』'], | ||
| ['"', '「'], | ||
| ['"', '」'], | ||
| [''', '『'], | ||
| [''', '』'], | ||
| ]; | ||
| const converter = OpenCC.ConverterFactory( | ||
| OpenCC.Locale.from.cn, // Simplified Chinese (Mainland China) => OpenCC standard | ||
| OpenCC.Locale.to.tw.concat([customDict]) // OpenCC standard => Traditional Chinese (Taiwan) with custom words | ||
| ); | ||
| console.log(converter('悟空道:“师父又来了。怎么叫做‘水中捞月’?”')); | ||
| console.log(converter('悟空道:"师父又来了。怎么叫做'水中捞月'?"')); | ||
| // output: 悟空道:「師父又來了。怎麼叫做『水中撈月』?」 | ||
| ``` | ||
|
|
||
| This will get the same result with an extra convertion. | ||
|
|
||
| ```javascript | ||
| const customDict = [ | ||
| ['“', '「'], | ||
| ['”', '」'], | ||
| ['‘', '『'], | ||
| ['’', '』'], | ||
| ['"', '「'], | ||
| ['"', '」'], | ||
| [''', '『'], | ||
| [''', '』'], | ||
| ]; | ||
| const converter = OpenCC.ConverterFactory( | ||
| OpenCC.Locale.from.cn, // Simplified Chinese (Mainland China) => OpenCC standard | ||
| OpenCC.Locale.to.tw, // OpenCC standard => Traditional Chinese (Taiwan) | ||
| [customDict] // Traditional Chinese (Taiwan) => custom words | ||
| ); | ||
| console.log(converter('悟空道:“师父又来了。怎么叫做‘水中捞月’?”')); | ||
| console.log(converter('悟空道:"师父又来了。怎么叫做'水中捞月'?"')); |
There was a problem hiding this comment.
What happened to these lines? ''' is definitely incorrect JavaScript.
There was a problem hiding this comment.
One thing VSCode's agent mode is completely useless at is quotes - it simply doesn't consider them to be different!
There was a problem hiding this comment.
The original example considered a scenario found in some web novels, where punctuation conventions differ between CN and TW. Therefore, it provided a way for users to customize replacement terms.
In addition, if you map " to both 「 and 」, as in lines 115 and 116, the latter will override the former.
So I don't understand the purpose of this change.
There was a problem hiding this comment.
Sorry, please ignore this precise change for the moment. As I mentioned above, this was a broken automated change that I didn't fix. This is just a draft PR to get "in principle" feedback as to whether a migration to TS might get merged. Some people hate TS, and would never accept it... So I didn't want to waste time perfecting something that would never be accepted...
There was a problem hiding this comment.
I hope my previous comment didn’t make you feel uncomfortable. I personally have no opinion on whether to use TypeScript; I'm only responding regarding this specific file.
There was a problem hiding this comment.
I don't think this file is useful on its own without further descriptions
|
Would you also like to work on the CI workflows? |
Sure. Basically, if you think it is worth migrating to typescript, I'll put in quite a bit of effort, including CI. This was just a first pass that I wanted to touch base on - there is some cruft from the automated translation that needs to be cleaned/fixed. I'm busy with other stuff for the next few days but will circle back soon, as long as you are interested in the basic principle of migrating to TS. |
|
I personally love TypeScript very much! But let me seek other members’ opinions first. |
I have been experimenting with VSCode's new Agent Mode... I realise there is not a huge benefit to this as the current code works where it should, but it might make it easier/more appearing to add functionality.