You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			71 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
| // import { missingCaseError } from './missingCaseError';
 | |
| 
 | |
| type OldColor =
 | |
|   | 'amber'
 | |
|   | 'blue'
 | |
|   | 'blue_grey'
 | |
|   | 'cyan'
 | |
|   | 'deep_orange'
 | |
|   | 'deep_purple'
 | |
|   | 'green'
 | |
|   | 'grey'
 | |
|   | 'indigo'
 | |
|   | 'light_blue'
 | |
|   | 'light_green'
 | |
|   | 'orange'
 | |
|   | 'pink'
 | |
|   | 'purple'
 | |
|   | 'red'
 | |
|   | 'teal';
 | |
| 
 | |
| type NewColor =
 | |
|   | 'blue'
 | |
|   | 'cyan'
 | |
|   | 'deep_orange'
 | |
|   | 'grey'
 | |
|   | 'green'
 | |
|   | 'indigo'
 | |
|   | 'pink'
 | |
|   | 'purple'
 | |
|   | 'red'
 | |
|   | 'teal';
 | |
| 
 | |
| export function migrateColor(color: OldColor): NewColor {
 | |
|   switch (color) {
 | |
|     // These colors no longer exist
 | |
|     case 'amber':
 | |
|     case 'orange':
 | |
|       return 'red';
 | |
| 
 | |
|     case 'blue_grey':
 | |
|     case 'light_blue':
 | |
|       return 'blue';
 | |
| 
 | |
|     case 'deep_purple':
 | |
|       return 'purple';
 | |
| 
 | |
|     case 'light_green':
 | |
|       return 'teal';
 | |
| 
 | |
|     // These can stay as they are
 | |
|     case 'blue':
 | |
|     case 'cyan':
 | |
|     case 'deep_orange':
 | |
|     case 'green':
 | |
|     case 'grey':
 | |
|     case 'indigo':
 | |
|     case 'pink':
 | |
|     case 'purple':
 | |
|     case 'red':
 | |
|     case 'teal':
 | |
|       return color;
 | |
| 
 | |
|     // Can uncomment this to ensure that we've covered all potential cases
 | |
|     // default:
 | |
|     //   throw missingCaseError(color);
 | |
| 
 | |
|     default:
 | |
|       return 'grey';
 | |
|   }
 | |
| }
 |