You don't even need to annotate things with types!
> square(x) = x * x
> @code_typed square(2.0)
CodeInfo(
1 1 ─ %1 = Base.mul_float(%%x, %%x)::Float64
└── return %1
) => Float64
> @code_typed square(2)
CodeInfo(
1 1 ─ %1 = Base.mul_int(%%x, %%x)::Int64
└── return %1
) => Int64
Functions specialize automatically to the arguments you pass in.