New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-svelte-plugin

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-svelte-plugin - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

67

dist/src/language-service/completions.js

@@ -10,2 +10,3 @@ "use strict";

ls.getCompletionsAtPosition = (fileName, position, options) => {
var _a, _b, _c, _d;
const completions = getCompletionsAtPosition(fileName, position, options);

@@ -15,2 +16,36 @@ if (!completions) {

}
// Add ./$types imports for SvelteKit since TypeScript is bad at it
if ((0, path_1.basename)(fileName).startsWith('+')) {
const $typeImports = new Map();
for (const c of completions.entries) {
if (((_a = c.source) === null || _a === void 0 ? void 0 : _a.includes('.svelte-kit/types')) && c.data) {
$typeImports.set(c.name, c);
}
}
for (const $typeImport of $typeImports.values()) {
// resolve path from FileName to svelte-kit/types
// src/routes/foo/+page.svelte -> .svelte-kit/types/foo/$types.d.ts
const routesFolder = 'src/routes'; // TODO somehow get access to kit.files.routes in here
const relativeFileName = (_b = fileName.split(routesFolder)[1]) === null || _b === void 0 ? void 0 : _b.slice(1);
if (relativeFileName) {
const modifiedSource = $typeImport.source.split('.svelte-kit/types')[0] +
// note the missing .d.ts at the end - TS wants it that way for some reason
`.svelte-kit/types/${routesFolder}/${(0, path_1.dirname)(relativeFileName)}/$types`;
completions.entries.push({
...$typeImport,
// Ensure it's sorted above the other imports
sortText: !isNaN(Number($typeImport.sortText))
? String(Number($typeImport.sortText) - 1)
: $typeImport.sortText,
source: modifiedSource,
data: {
...$typeImport.data,
fileName: (_c = $typeImport.data.fileName) === null || _c === void 0 ? void 0 : _c.replace($typeImport.source, modifiedSource),
moduleSpecifier: (_d = $typeImport.data.moduleSpecifier) === null || _d === void 0 ? void 0 : _d.replace($typeImport.source, modifiedSource),
__is_sveltekit$typeImport: true
}
});
}
}
}
return {

@@ -32,32 +67,8 @@ ...completions,

ls.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, data) => {
var _a, _b, _c, _d;
let is$typeImport = false;
const originalSource = source;
const originalData = data ? { ...data } : undefined;
if ((0, path_1.basename)(fileName).startsWith('+') && (source === null || source === void 0 ? void 0 : source.includes('.svelte-kit/types'))) {
// resolve path from FileName to svelte-kit/types
// src/routes/foo/+page.svelte -> .svelte-kit/types/foo/$types.d.ts
const routesFolder = 'src/routes'; // TODO somehow get access to kit.files.routes in here
const relativeFileName = (_a = fileName.split(routesFolder)[1]) === null || _a === void 0 ? void 0 : _a.slice(1);
if (relativeFileName) {
is$typeImport = true;
source =
source.split('.svelte-kit/types')[0] +
// note the missing .d.ts at the end - TS wants it that way for some reason
`.svelte-kit/types/${routesFolder}/${(0, path_1.dirname)(relativeFileName)}/$types`;
if (data) {
data.fileName = (_b = data.fileName) === null || _b === void 0 ? void 0 : _b.replace(originalSource, source);
data.moduleSpecifier = (_c = data.moduleSpecifier) === null || _c === void 0 ? void 0 : _c.replace(originalSource, source);
}
}
}
let details = getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data);
if (!details && is$typeImport) {
// Try again
is$typeImport = false;
details = getCompletionEntryDetails(fileName, position, entryName, formatOptions, originalSource, preferences, originalData);
}
var _a;
const is$typeImport = data.__is_sveltekit$typeImport;
const details = getCompletionEntryDetails(fileName, position, entryName, formatOptions, source, preferences, data);
if (details) {
if (is$typeImport) {
details.codeActions = (_d = details.codeActions) === null || _d === void 0 ? void 0 : _d.map((codeAction) => {
details.codeActions = (_a = details.codeActions) === null || _a === void 0 ? void 0 : _a.map((codeAction) => {
codeAction.description = adjustPath(codeAction.description);

@@ -64,0 +75,0 @@ codeAction.changes = codeAction.changes.map((change) => {

{
"name": "typescript-svelte-plugin",
"version": "0.3.7",
"version": "0.3.8",
"description": "A TypeScript Plugin providing Svelte intellisense",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc