typescript-svelte-plugin 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,9 +26,10 @@ function decorateCompletions(ls, logger) {
|
|
|
26
26
|
const routesFolder = 'src/routes'; // TODO somehow get access to kit.files.routes in here
|
|
27
27
|
const relativeFileName = (_b = fileName.split(routesFolder)[1]) === null || _b === void 0 ? void 0 : _b.slice(1);
|
|
28
28
|
if (relativeFileName) {
|
|
29
|
+
const relativePath = (0, path_1.dirname)(relativeFileName) === '.' ? '' : `${(0, path_1.dirname)(relativeFileName)}/`;
|
|
29
30
|
const modifiedSource = $typeImport.source.split('.svelte-kit/types')[0] +
|
|
30
31
|
// note the missing .d.ts at the end - TS wants it that way for some reason
|
|
31
|
-
`.svelte-kit/types/${routesFolder}/${
|
|
32
|
+
`.svelte-kit/types/${routesFolder}/${relativePath}$types`;
|
|
32
33
|
completions.entries.push({
|
|
33
34
|
...$typeImport,
|
|
34
35
|
// Ensure it's sorted above the other imports
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.decorateUpdateImports = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const utils_1 = require("../utils");
|
|
5
9
|
function decorateUpdateImports(ls, snapshotManager, logger) {
|
|
6
10
|
const getEditsForFileRename = ls.getEditsForFileRename;
|
|
7
11
|
ls.getEditsForFileRename = (oldFilePath, newFilePath, formatOptions, preferences) => {
|
|
8
12
|
const renameLocations = getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences);
|
|
9
|
-
// If a file move/rename of a TS/JS file results a Svelte file change,
|
|
10
|
-
// the Svelte extension will notice that, too, and adjusts the same imports.
|
|
11
|
-
// This results in duplicate adjustments or race conditions with conflicting text spans
|
|
12
|
-
// which can break imports in some cases.
|
|
13
|
-
// Therefore don't do any updates of Svelte files and and also no updates of mixed TS files
|
|
14
|
-
// and let the Svelte extension handle that.
|
|
15
13
|
return renameLocations === null || renameLocations === void 0 ? void 0 : renameLocations.filter((renameLocation) => {
|
|
14
|
+
// If a file move/rename of a TS/JS file results a Svelte file change,
|
|
15
|
+
// the Svelte extension will notice that, too, and adjusts the same imports.
|
|
16
|
+
// This results in duplicate adjustments or race conditions with conflicting text spans
|
|
17
|
+
// which can break imports in some cases.
|
|
18
|
+
// Therefore don't do any updates of Svelte files and and also no updates of mixed TS files
|
|
19
|
+
// and let the Svelte extension handle that.
|
|
16
20
|
return (!(0, utils_1.isSvelteFilePath)(renameLocation.fileName) &&
|
|
17
21
|
!renameLocation.textChanges.some((change) => change.newText.endsWith('.svelte')));
|
|
22
|
+
}).map((renameLocation) => {
|
|
23
|
+
if (path_1.default.basename(renameLocation.fileName).startsWith('+')) {
|
|
24
|
+
// Filter out changes to './$type' imports for Kit route files,
|
|
25
|
+
// you'll likely want these to stay as-is
|
|
26
|
+
renameLocation.textChanges = renameLocation.textChanges.filter((change) => {
|
|
27
|
+
return !change.newText.includes('.svelte-kit/types/');
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return renameLocation;
|
|
18
31
|
});
|
|
19
32
|
};
|
|
20
33
|
}
|