# TypeScript function 傳入自定義字串 使用 enum: function ```jsx // 如果需要傳入自訂的字串 enum CARDTYPE { I = 'I', R = 'R', } function squareOf(idNumber: string, type: CARDTYPE): boolean { console.log(idNumber) return type === 'R' || false } squareOf('A123', CARDTYPE.I) ``` 使用 type ```typescript type CARDTYPE = 'I' | 'R' function squareOf(idNumber: string, type: CARDTYPE): boolean { console.log(idNumber) return type === 'R' || false } squareOf('A123',"") ``` 輸入 "" 時,會出現 select 面板唷 ![](https://i.imgur.com/Eu0837R.png)