Often I download files with funny extensions, like
.dat, etc. Is there some way I can make the default app for all files like these, as in files that the system does not already recognize, to be TextEdit?
macOS is a derivative of Unix, in which all things are represented as a text file, and which program is used to open those files is determined by a "mime type". On macOS mime type associations are stored inside of the corresponding .app file. For example, the data that describes a Microsoft Word Document's (.doc) attributes (i.e. what type of file it is, what the default icon is, etc.) is stored in Word.app>Contents>Info.plist.
The problem this creates is that in order to make all unknown mime types associate with Text Edit.app you would have to manually add their attributes to the Text Edit.app>Contents>Info.plist file, and any new file types you hadn't added would continue to go unrecognized, and would still have no default app to open them.
The benefit this has is that since all things in Unix are represented as text files, you can simply Right Click>Open With>Other...>Text Edit.app, and they will always open as a normal text file, regardless of what extension it has. This is of course less convenient than the solution you asked for, but I'm afraid it is, to my knowledge, the closest thing you will be able to achieve.
Edit: For example, lets say the file type is .foo, you can use
Get Info on file.foo, and under the Open With tab use the drop-down menu, and choose Other.... Select TextEdit.app in the Choose Application dialogue. After file.foo's default app has been set, click the Change All... button. From now on all files with the .foo extension will open in TextEdit by default. However, this method presents the same problem as editing the mime-type information directly, in that you will still have to do this for every unknown file type.
For TextEdit to show up in the Open With dialogue at all there has to be information about the file type in TextEdit's Info.plist file. When you open the Open With dialogue it reads "Fetching..." for a short moment. This is because the system is scanning the Info.plist files of all the apps it knows are installed (or rather, it is scanning the index of those files it made the first time each of those apps were run.) to see if any of them contain info about the type of file you clicked on. It then makes a link to each of the apps whose Info.plist files were found to contain that mime-type, which is the list in the Open With menu.
Unix systems do not have the ability to set all unrecognized file types to open with a certain app, because by its very nature this would include files with no extension at all. As previously mentioned in Unix all things are seen by the system as text files, meaning if you set all unknown file types to open with TextEdit.app this would include things like the system programmes stored in the
/sbin/ folders, and even certain hardware like the HDD. Now suddenly whenever you try to do anything involving system programmes that don't have an extension at best it just opens a TextEdit window full of gibberish, and at worst the system outright stops responding to any input (locks up), stops booting at all, and has to be reinstalled.
Yes. If you select one of the types and do 'get info', cmd-i, you can set default for that file type. At bottom of get info window is an option for which app to use to open that file. You can select textedit from pull down menu. Directly under that is a button that says 'Change All'. If you click that button, textedit will open all files with same extension. You'll have to do this for each different file type, in your case dat, npy, ...