On MS-DOS set the type-id aka partition id to id on partition number. The id is a value between 0x01 and 0xff, e.g. the ID for Linux is 0x83. A list with some IDs is available at https://en.wikipedia.org/wiki/Partition_type.
On GPT set the type-uuid to uuid on partition number. E.g. the UUID for Linux is 0fc63daf-8483-4772-8e79-3d69d8477de4. A list with some UUIDs is availabe at https://en.wikipedia.org/wiki/GUID_Partition_Table.