Repository: sveltejs/kit (js)

Issue:
svelte-package removes type="application/ld+json" from script tags
### Describe the bug

Running `svelte-package` removes `type="application/ld+json"` from script tags even with `preserve: ['ld+json']` using:
```
<svelte:head>
  {@html `<script type="application/ld+json" >${JSON.stringify(jsonLd)}</script>`}
</svelte:head>
```
is compiled to:
```
<svelte:head>
  {@html `<script >${JSON.stringify(jsonLd)}</script>`}
</svelte:head>
```

### Reproduction

https://github.com/TeemuKoivisto/svelte-package-removes-jsonld-type

### Logs

_No response_

### System Info

```shell
System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 75.28 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 105.0.5195.125
    Firefox: 104.0.1
    Safari: 15.6.1
  npmPackages:
    @sveltejs/kit: ^1.0.0-next.484 => 1.0.0-next.484 
    @sveltejs/package: ^1.0.0-next.3 => 1.0.0-next.3 
    svelte: ^3.50.1 => 3.50.1 
    vite: ^3.1.1 => 3.1.1
```


### Severity

serious, but I can work around it

### Additional Information

_No response_

Pull request description:
[fix] don't strip type="application/.." tags
Fixes #6862

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [x] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


Patch:
diff --git a/.changeset/cyan-pianos-bake.md b/.changeset/cyan-pianos-bake.md
new file mode 100644
index 000000000..7991f006d
--- /dev/null
+++ b/.changeset/cyan-pianos-bake.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/package': patch
+---
+
+[fix] don't strip `type="application/.."` tags
diff --git a/.changeset/fair-tables-peel.md b/.changeset/fair-tables-peel.md
new file mode 100644
index 000000000..02989f3ae
--- /dev/null
+++ b/.changeset/fair-tables-peel.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] handle jsdoc without tags while generating proxy types
diff --git a/.changeset/pre.json b/.changeset/pre.json
index 4364234fa..1dfbec7e7 100644
--- a/.changeset/pre.json
+++ b/.changeset/pre.json
@@ -104,6 +104,7 @@
     "breezy-mayflies-yawn",
     "breezy-olives-battle",
     "breezy-onions-remember",
+    "breezy-pots-wave",
     "breezy-sheep-dress",
     "breezy-students-refuse",
     "breezy-timers-tan",
@@ -133,6 +134,7 @@
     "chatty-ducks-shop",
     "chatty-impalas-smash",
     "chatty-mangos-raise",
+    "chatty-moose-love",
     "chatty-pumas-shake",
     "chatty-steaks-yell",
     "chilled-bees-develop",
@@ -549,6 +551,7 @@
     "lemon-taxis-juggle",
     "lemon-timers-deliver",
     "lemon-ways-doubt",
+    "light-eagles-call",
     "light-kangaroos-tie",
     "light-keys-mix",
     "light-kings-beam",
diff --git a/packages/create-svelte/CHANGELOG.md b/packages/create-svelte/CHANGELOG.md
index 0661b076d..39629f296 100644
--- a/packages/create-svelte/CHANGELOG.md
+++ b/packages/create-svelte/CHANGELOG.md
@@ -1,5 +1,11 @@
 # create-svelte
 
+## 2.0.0-next.178
+
+### Patch Changes
+
+- [fix] prettier not formatting svelte files ([#6866](https://github.com/sveltejs/kit/pull/6866))
+
 ## 2.0.0-next.177
 
 ### Patch Changes
diff --git a/packages/create-svelte/package.json b/packages/create-svelte/package.json
index d60f0e978..e52cc1d40 100644
--- a/packages/create-svelte/package.json
+++ b/packages/create-svelte/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "create-svelte",
-	"version": "2.0.0-next.177",
+	"version": "2.0.0-next.178",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md
index 42fda8991..7b8e26355 100644
--- a/packages/kit/CHANGELOG.md
+++ b/packages/kit/CHANGELOG.md
@@ -1,5 +1,13 @@
 # @sveltejs/kit
 
+## 1.0.0-next.485
+
+### Patch Changes
+
+- fix to ActionData type generation ([#6869](https://github.com/sveltejs/kit/pull/6869))
+
+* The return type of cookies.get is string|undefined #6865 ([#6867](https://github.com/sveltejs/kit/pull/6867))
+
 ## 1.0.0-next.484
 
 ### Patch Changes
diff --git a/packages/kit/package.json b/packages/kit/package.json
index 6f1d3a064..8fdaa7aa4 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/kit",
-	"version": "1.0.0-next.484",
+	"version": "1.0.0-next.485",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js
index a61a1808c..5204a8de5 100644
--- a/packages/kit/src/core/sync/write_types/index.js
+++ b/packages/kit/src/core/sync/write_types/index.js
@@ -489,7 +489,7 @@ export function tweak_types(content, is_server) {
 			if (node.jsDoc) {
 				// @ts-ignore
 				for (const comment of node.jsDoc) {
-					for (const tag of comment.tags) {
+					for (const tag of comment.tags ?? []) {
 						if (ts.isJSDocTypeTag(tag)) {
 							const is_fn =
 								ts.isFunctionDeclaration(value) ||
diff --git a/packages/kit/src/core/sync/write_types/index.spec.js b/packages/kit/src/core/sync/write_types/index.spec.js
index db0bcdf9f..26257a7bf 100644
--- a/packages/kit/src/core/sync/write_types/index.spec.js
+++ b/packages/kit/src/core/sync/write_types/index.spec.js
@@ -138,6 +138,33 @@ test('Rewrites types for a TypeScript module without param', () => {
 	);
 });
 
+test('Rewrites types for a TypeScript module without param and jsdoc without types', () => {
+	const source = `
+		/** test */
+		export const load: Get = () => {
+			return {
+				a: 1
+			};
+		};
+	`;
+
+	const rewritten = tweak_types(source, false);
+
+	assert.equal(rewritten?.exports, ['load']);
+	assert.equal(
+		rewritten?.code,
+		`// @ts-nocheck
+
+		/** test */
+		export const load = () => {
+			return {
+				a: 1
+			};
+		};
+	;null as any as Get;`
+	);
+});
+
 test('Rewrites types for a JavaScript module with `function`', () => {
 	const source = `
 		/** @type {import('./$types').Get} */
diff --git a/packages/package/src/utils.js b/packages/package/src/utils.js
index 97c3b03db..0b263857b 100644
--- a/packages/package/src/utils.js
+++ b/packages/package/src/utils.js
@@ -49,7 +49,11 @@ export function resolve_lib_alias(file, content, config) {
  */
 export function strip_lang_tags(content) {
 	return content
-		.replace(/(<!--[^]*?-->)|(<script[^>]*?)\s(?:type|lang)=(["']).*?\3/g, '$1$2')
+		.replace(
+			/(<!--[^]*?-->)|(<script[^>]*?)\s(?:type|lang)=(["'])(.*?)\3/g,
+			// things like application/ld+json should be kept as-is. Preprocessed languages are "ts" etc
+			(match, s1, s2, _, s4) => (s4.startsWith('application/') ? match : (s1 ?? '') + (s2 ?? ''))
+		)
 		.replace(/(<!--[^]*?-->)|(<style[^>]*?)\s(?:type|lang)=(["']).*?\3/g, '$1$2');
 }
 


Test patch:
diff --git a/packages/package/test/fixtures/typescript/expected/Plain.svelte b/packages/package/test/fixtures/typescript/expected/Plain.svelte
index b49daed30..29329add3 100644
--- a/packages/package/test/fixtures/typescript/expected/Plain.svelte
+++ b/packages/package/test/fixtures/typescript/expected/Plain.svelte
@@ -2,3 +2,7 @@
 	/** @type {import('./foo').Foo} */
 	export let foo;
 </script>
+
+<svelte:head>
+  <script type="application/ld+json">{JSON.stringify(jsonLd)}</script>
+</svelte:head>
diff --git a/packages/package/test/fixtures/typescript/src/lib/Plain.svelte b/packages/package/test/fixtures/typescript/src/lib/Plain.svelte
index b49daed30..29329add3 100644
--- a/packages/package/test/fixtures/typescript/src/lib/Plain.svelte
+++ b/packages/package/test/fixtures/typescript/src/lib/Plain.svelte
@@ -2,3 +2,7 @@
 	/** @type {import('./foo').Foo} */
 	export let foo;
 </script>
+
+<svelte:head>
+  <script type="application/ld+json">{JSON.stringify(jsonLd)}</script>
+</svelte:head>
diff --git a/packages/package/test/fixtures/typescript/svelte.config.js b/packages/package/test/fixtures/typescript/svelte.config.js
index 6bd253bdf..8e74287e5 100644
--- a/packages/package/test/fixtures/typescript/svelte.config.js
+++ b/packages/package/test/fixtures/typescript/svelte.config.js
@@ -1,5 +1,7 @@
 import preprocess from 'svelte-preprocess';
 
 export default {
-	preprocess: preprocess()
+	preprocess: preprocess({
+		preserve: ['ld+json']
+	})
 };