choosing a file by extension rather than type

I know you can make a system prompt for opening a certain type of file, like:

set directory to POSIX path of ( choose file of type (“public.image”) with prompt …

But instead of filtering for files by type, can I use file extensions instead? It sounds pretty straightforward but I haven’t found the answer in my poking around the AS dictionary.

Hi. Finder can filter by name:

tell application "Finder" to (my (choose folder)'s files whose its name ends with ".pdf" or its name ends with ".jpg") as alias list

choose file both accepts and heeds extensions on my Mojave system:

set directory to POSIX path of (choose file of type {"pdf", "scpt", "txt", "png"} with prompt "Choose one of the chooseable files:")

Hmm, so it does. I attempted to use the period, which breaks the functionality and may be the same mistake the OP made.

Great solutions all, but let me complicate things further: this script is to prompt the user to open a file with a custom extension. Underneath, the file type is supposed to really be TEXT, but for some reason not all of them are recognized as such when I use “of type {“TEXT”}”.

That’s why I was hoping the bypass the filetype completely and only look at the custom file extension since that’s unique to any doc created by this app.

(To clarify: older versions of the app stuck to making these .abcd files of type TEXT, but the newer version didn’t. That’s why I was thinking to just look at that .abcd file extension which is always present.)