@@ -143,6 +143,36 @@ export type MyError = Error;
143143
144144 expect ( dep ) . toBe ( "import {\n schema$Value\n} from '../models';\n" ) ;
145145 } ) ;
146+
147+ // Regression for #3695: an aliased import is referenced by its alias only
148+ // (rendered `name as alias`), so a bare occurrence of the pre-alias name in
149+ // generated code (e.g. a path param `z` colliding with `z as zod`) must not
150+ // pull the dependency in.
151+ it ( 'does not add an aliased import when only its pre-alias name appears' , ( ) => {
152+ const dep = addDependency ( {
153+ implementation : 'export const getUrl = (z: string) => `/${z}`;' ,
154+ dependency : 'zod' ,
155+ projectName : undefined ,
156+ hasSchemaDir : true ,
157+ isAllowSyntheticDefaultImports : true ,
158+ exports : [ { name : 'z' , alias : 'zod' , values : true } ] ,
159+ } ) ;
160+
161+ expect ( dep ) . toBeUndefined ( ) ;
162+ } ) ;
163+
164+ it ( 'adds an aliased import when its alias appears' , ( ) => {
165+ const dep = addDependency ( {
166+ implementation : 'const schema = zod.string();' ,
167+ dependency : 'zod' ,
168+ projectName : undefined ,
169+ hasSchemaDir : true ,
170+ isAllowSyntheticDefaultImports : true ,
171+ exports : [ { name : 'z' , alias : 'zod' , values : true } ] ,
172+ } ) ;
173+
174+ expect ( dep ) . toBe ( "import {\n z as zod\n} from 'zod';\n" ) ;
175+ } ) ;
146176 } ) ;
147177
148178 // `oneMore` is set only by the tags-split writer (split-tags-mode.ts),
0 commit comments