@@ -174,17 +174,19 @@ export const getSchema = (
174174 }
175175 }
176176
177+ // Boolean is internally represented by TypeScript as the union `true | false`,
178+ // so it must be detected before the primitive-literal-union check below; otherwise
179+ // `boolean` (and `true | false`) would incorrectly surface as a select.
180+ if ( isBoolean ( parameterType ) ) {
181+ return { input : "boolean" , ...combinedSuggestions } ;
182+ }
183+
177184 // Check primitive literal union first (e.g., "a" | "b" | "c") or a single
178185 // string/number literal (e.g., "GET"). A bare literal has only one allowed
179186 // value, so it should still surface as a select rather than a free-form text/number input.
180187 if ( isPrimitiveLiteralUnion ( parameterType ) || isStringOrNumberLiteral ( parameterType ) ) {
181188 return { input : "select" , ...combinedSuggestions } ;
182189 }
183-
184- // Check individual primitive types
185- if ( isBoolean ( parameterType ) ) {
186- return { input : "boolean" , ...combinedSuggestions } ;
187- }
188190 if ( isNumber ( parameterType ) ) {
189191 return { input : "number" , ...combinedSuggestions } ;
190192 }
@@ -288,10 +290,28 @@ export const getSchema = (
288290 * @returns True if the type is a boolean or boolean literal, false otherwise
289291 */
290292function isBoolean ( type : ts . Type ) : boolean {
291- return (
293+ if (
292294 ( type . flags & ts . TypeFlags . Boolean ) !== 0 ||
293295 ( type . flags & ts . TypeFlags . BooleanLiteral ) !== 0
294- ) ;
296+ ) {
297+ return true ;
298+ }
299+ // A union whose only non-nullish members are boolean literals (e.g. `true | false`,
300+ // or `boolean | undefined` after TS expands boolean to its constituents) is still a boolean.
301+ if ( type . isUnion ( ) ) {
302+ const nonNullish = type . types . filter (
303+ ( t ) => ( t . flags & ( ts . TypeFlags . Undefined | ts . TypeFlags . Null ) ) === 0
304+ ) ;
305+ return (
306+ nonNullish . length > 0 &&
307+ nonNullish . every (
308+ ( t ) =>
309+ ( t . flags & ts . TypeFlags . Boolean ) !== 0 ||
310+ ( t . flags & ts . TypeFlags . BooleanLiteral ) !== 0
311+ )
312+ ) ;
313+ }
314+ return false ;
295315}
296316
297317/**
0 commit comments