diff --git a/Data/Text.hs b/Data/Text.hs
index 8b32b02c5370da56e1489317152c7a4c87b66862..972a8e097a5569122c64585e8170372d4db5069a 100644
--- a/Data/Text.hs
+++ b/Data/Text.hs
@@ -430,7 +430,9 @@ instance Data Text where
 -- @since 1.2.4.0
 instance TH.Lift Text where
   lift = TH.appE (TH.varE 'pack) . TH.stringE . unpack
-#if MIN_VERSION_template_haskell(2,16,0)
+#if MIN_VERSION_template_haskell(2,17,0)
+  liftTyped = TH.unsafeCodeCoerce . TH.lift
+#elif MIN_VERSION_template_haskell(2,16,0)
   liftTyped = TH.unsafeTExpCoerce . TH.lift
 #endif
 
diff --git a/Data/Text/Lazy.hs b/Data/Text/Lazy.hs
index be893c4cd960ffcb9b87e51984de184e754c1b8c..e1aa130962cd48ecd2003bb481ec47ee9c96593c 100644
--- a/Data/Text/Lazy.hs
+++ b/Data/Text/Lazy.hs
@@ -415,7 +415,9 @@ instance Data Text where
 -- @since 1.2.4.0
 instance TH.Lift Text where
   lift = TH.appE (TH.varE 'pack) . TH.stringE . unpack
-#if MIN_VERSION_template_haskell(2,16,0)
+#if MIN_VERSION_template_haskell(2,17,0)
+  liftTyped = TH.unsafeCodeCoerce . TH.lift
+#elif MIN_VERSION_template_haskell(2,16,0)
   liftTyped = TH.unsafeTExpCoerce . TH.lift
 #endif