Repository: prettier/prettier (JavaScript)

Issue:
Prettier prints a trailing comma after type argument list even if the languages is `ts` in markdown
**Prettier 3.0.2**
[Playground link](https://prettier.io/playground/#N4Igxg9gdgLgprEAuEADdMDOAdKkqYwAExAvEQDwAqANAHwAUAlEaXUcAL4Dcu6quPhkwAPXPkIlWlWoxZsOnIahA0QEAA4wAltEzJQAQwBOxiAHcACiYT6UhgDbnDAT31qARscNgA1nBgAZUMAWzgAGW0oOGQAM0dMOE9vPwDAjR8ogHNkGGMAVySQRJDtXIKizGyHOABFfIh4OISigCtRQOq6hqakeIdEtQBHHrhLMw07EENMAFpouAATJdUQPMNtB2yAYQgQkMNkaYcHVaqoLJqAQRg87Q98+Es4Y0jo5oGigAsYEIcAdS+2ngmAyYDggVswO0ADdgS4jmBMO4QDDCgBJKDLWCBMDGbRaK5YwIwFw1D6DEAaMyJf7eDRHalwRLGGExNRRFkwcaGLIHClFDLGFlHA7GXyLCxQVbUqIwf7aRYwL7IAAcAAY1MY4CNtNqeXzDn0WmoYIYPAqlSqkAAmNT5RJUc12fqUuAhDxLZaLcKGC75XlwABiEGMB1u2SOhkeEBAnE4QA)
<!-- prettier-ignore -->
```sh
--parser markdown
```

**Input:**
<!-- prettier-ignore -->
````markdown
```ts
const t = <T,>() => {};
```

```tsx
const t = <T,>() => {}
```
````

**Output:**
<!-- prettier-ignore -->
````markdown
```ts
const t = <T,>() => {};
```

```tsx
const t = <T,>() => {}
```

````

The second codeblock prints a trailing comma and it's the correct behavior, however the first codeblock should remove the trailing comma

**Expected behavior:**
The first codeblock should not have a trailing comma


Hints:

Patch:
diff --git a/src/language-js/parse/typescript.js b/src/language-js/parse/typescript.js
--- a/src/language-js/parse/typescript.js
+++ b/src/language-js/parse/typescript.js
@@ -40,7 +40,7 @@ function createParseError(error) {
   });
 }
 
-// https://typescript-eslint.io/architecture/parser/#jsx
+// https://typescript-eslint.io/packages/parser/#jsx
 const isKnownFileType = (filepath) =>
   /\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filepath);
 
diff --git a/src/language-markdown/embed.js b/src/language-markdown/embed.js
--- a/src/language-markdown/embed.js
+++ b/src/language-markdown/embed.js
@@ -17,7 +17,14 @@ function embed(path, options) {
           Math.max(3, getMaxContinuousCount(node.value, styleUnit) + 1),
         );
         const newOptions = { parser };
-        if (node.lang === "tsx") {
+
+        // Override the filepath option.
+        // This is because whether the trailing comma of type parameters
+        // should be printed depends on whether it is `*.ts` or `*.tsx`.
+        // https://github.com/prettier/prettier/issues/15282
+        if (node.lang === "ts" || node.lang === "typescript") {
+          newOptions.filepath = "dummy.ts";
+        } else if (node.lang === "tsx") {
           newOptions.filepath = "dummy.tsx";
         }
 


Test patch:
diff --git a/tests/format/markdown/code/__snapshots__/jsfmt.spec.js.snap b/tests/format/markdown/code/__snapshots__/jsfmt.spec.js.snap
--- a/tests/format/markdown/code/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/format/markdown/code/__snapshots__/jsfmt.spec.js.snap
@@ -291,6 +291,33 @@ hello world
 ================================================================================
 `;
 
+exports[`ts-trailing-comma.md - {"proseWrap":"always"} format 1`] = `
+====================================options=====================================
+parsers: ["markdown"]
+printWidth: 80
+proseWrap: "always"
+                                                                                | printWidth
+=====================================input======================================
+\`\`\`ts
+const test = <T,>(value: T) => {};
+\`\`\`
+
+\`\`\`typescript
+const test = <T,>(value: T) => {};
+\`\`\`
+
+=====================================output=====================================
+\`\`\`ts
+const test = <T>(value: T) => {};
+\`\`\`
+
+\`\`\`typescript
+const test = <T>(value: T) => {};
+\`\`\`
+
+================================================================================
+`;
+
 exports[`tsx-trailing-comma.md - {"proseWrap":"always"} format 1`] = `
 ====================================options=====================================
 parsers: ["markdown"]
diff --git a/tests/format/markdown/code/ts-trailing-comma.md b/tests/format/markdown/code/ts-trailing-comma.md
new file mode 100644
--- /dev/null
+++ b/tests/format/markdown/code/ts-trailing-comma.md
@@ -0,0 +1,7 @@
+```ts
+const test = <T,>(value: T) => {};
+```
+
+```typescript
+const test = <T,>(value: T) => {};
+```