@@ -126,10 +126,20 @@ export const getSchema = (
126126 functions : FunctionDefinition [ ] ,
127127 suggestions : boolean = true
128128) : Schema => {
129+
130+ if ( ( parameterType . flags & ts . TypeFlags . TypeParameter ) !== 0 ) {
131+ const decl = parameterType . symbol ?. declarations ?. [ 0 ]
132+ if ( decl && ts . isTypeParameterDeclaration ( decl ) && decl . constraint ) {
133+ // getTypeFromTypeNode statt getBaseConstraintOfType → aliasSymbol bleibt erhalten
134+ const constraintType = checker . getTypeFromTypeNode ( decl . constraint )
135+ return getSchema ( checker , node , constraintType , functionDeclarations , functions , suggestions )
136+ }
137+ }
138+
129139 // Collect all available suggestions for this parameter
130140 const combinedSuggestions = suggestions ? {
131141 suggestions : [
132- ...getValues ( parameterType ) ,
142+ ...getValues ( parameterType , checker ) ,
133143 ...( node ? getReferences (
134144 checker ,
135145 node ,
@@ -151,6 +161,19 @@ export const getSchema = (
151161 ] ,
152162 } : { } ;
153163
164+ // Strip undefined from unions (e.g. string | undefined → string).
165+ // Suggestions are collected above from the original type (preserving aliasSymbol literals),
166+ // the base schema is determined from the stripped type, then both are merged.
167+ if ( parameterType . isUnion ( ) ) {
168+ const nonUndefined = parameterType . types . filter (
169+ ( t ) => ( t . flags & ts . TypeFlags . Undefined ) === 0
170+ )
171+ if ( nonUndefined . length === 1 ) {
172+ const baseSchema = getSchema ( checker , node , nonUndefined [ 0 ] , functionDeclarations , functions , false )
173+ return { ...baseSchema , ...combinedSuggestions }
174+ }
175+ }
176+
154177 // Check individual primitive types
155178 if ( isBoolean ( parameterType ) ) {
156179 return { input : "boolean" , ...combinedSuggestions } ;
0 commit comments