diff --git a/ts/package.json b/ts/package.json index 55fe04261..c78d73277 100644 --- a/ts/package.json +++ b/ts/package.json @@ -45,7 +45,7 @@ "svelte": "^3.25.0", "svelte-check": "^1.0.61", "svelte-preprocess": "^4.6.9", - "svelte2tsx": "^0.1.133", + "svelte2tsx": "^0.4.6", "tmp": "^0.2.1", "tslib": "^2.0.3", "typescript": "^4.4.0", diff --git a/ts/svelte/svelte.ts b/ts/svelte/svelte.ts index 324461aa0..958544446 100644 --- a/ts/svelte/svelte.ts +++ b/ts/svelte/svelte.ts @@ -2,10 +2,10 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // languageServerHost taken from MIT sources - see below. -const fs = require("fs"); -const worker = require("@bazel/worker"); -const svelte2tsx = require("svelte2tsx"); -const preprocess = require("svelte-preprocess"); +import * as fs from "fs"; +import * as worker from "@bazel/worker"; +import { svelte2tsx } from "svelte2tsx"; +import preprocess from "svelte-preprocess"; import { basename } from "path"; import * as ts from "typescript"; import * as svelte from "svelte/compiler.js"; @@ -132,13 +132,10 @@ async function writeDts(tsPath, dtsPath, tsLibs) { function writeTs(svelteSource, sveltePath, tsPath): void { let tsSource = svelte2tsx(svelteSource, { filename: sveltePath, - strictMode: true, isTsFile: true, + mode: "dts", }); let codeLines = tsSource.code.split("\n"); - // replace the "///" with a line - // turning off checking, as we'll use svelte-check for that - codeLines[0] = "// @ts-nocheck"; updateFileContent(tsPath, codeLines.join("\n")); } @@ -164,10 +161,11 @@ async function writeJs( ], }, }); - preprocessOptions.filename = inputFilename; try { - const processed = await svelte.preprocess(source, preprocessOptions); + const processed = await svelte.preprocess(source, preprocessOptions, { + filename: inputFilename, + }); const result = svelte.compile(processed.toString!(), { format: "esm", css: false, diff --git a/ts/yarn.lock b/ts/yarn.lock index c0e984a50..bf382404e 100644 --- a/ts/yarn.lock +++ b/ts/yarn.lock @@ -4306,10 +4306,10 @@ svelte-preprocess@^4.0.0, svelte-preprocess@^4.6.9: sorcery "^0.10.0" strip-indent "^3.0.0" -svelte2tsx@^0.1.133: - version "0.1.193" - resolved "https://registry.yarnpkg.com/svelte2tsx/-/svelte2tsx-0.1.193.tgz#16fe594898ef455e4f715ac317d219c9c757656b" - integrity sha512-vzy4YQNYDnoqp2iZPnJy7kpPAY6y121L0HKrSBjU/IWW7DQ6T7RMJed2VVHFmVYm0zAGYMDl9urPc6R4DDUyhg== +svelte2tsx@^0.4.6: + version "0.4.6" + resolved "https://registry.yarnpkg.com/svelte2tsx/-/svelte2tsx-0.4.6.tgz#3435064962c910c0a075b4a1c04e91eaf568f5e5" + integrity sha512-flljgh/MbJDijo6Z1HhCfyzdRgn1Nd7QTuuxk9Oq5CzyBXZl/NJYh4otZZwUHnx5poy8k7Oxr2CBE3IBh89tmQ== dependencies: dedent-js "^1.0.1" pascal-case "^3.1.1"