MCPcopy
hub / github.com/tailwindlabs/tailwindcss / convert

Function convert

packages/@tailwindcss-upgrade/src/utils/args.ts:110–129  ·  view source on GitHub ↗
(value: string | boolean, type: T)

Source from the content-addressed store, hash-verified

108// this is coming from `mri`'s parse function'), to the correct type based on
109// the `type` of the argument.
110function convert<T extends keyof Types>(value: string | boolean, type: T) {
111 switch (type) {
112 case 'string':
113 return convertString(value)
114 case 'boolean':
115 return convertBoolean(value)
116 case 'number':
117 return convertNumber(value)
118 case 'boolean | string':
119 return convertBoolean(value) ?? convertString(value)
120 case 'number | string':
121 return convertNumber(value) ?? convertString(value)
122 case 'boolean | number':
123 return convertBoolean(value) ?? convertNumber(value)
124 case 'boolean | number | string':
125 return convertBoolean(value) ?? convertNumber(value) ?? convertString(value)
126 default:
127 throw new Error(`Unhandled type: ${type}`)
128 }
129}
130
131function convertBoolean(value: ArgumentType) {
132 if (value === true || value === false) {

Callers 1

argsFunction · 0.70

Calls 3

convertStringFunction · 0.70
convertBooleanFunction · 0.70
convertNumberFunction · 0.70

Tested by

no test coverage detected