svelte2tsx 0.5.18 → 0.5.20

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.
package/index.js CHANGED
@@ -1144,7 +1144,7 @@ function extractTag(htmlx, tag, useNewTransformation) {
1144
1144
  let content = match[4];
1145
1145
  if (!content) {
1146
1146
  if (useNewTransformation) {
1147
- // Keep tag and transform it properly by removing it
1147
+ // Keep tag and transform it like a regular element
1148
1148
  content = '';
1149
1149
  }
1150
1150
  else {
@@ -7111,7 +7111,9 @@ function processSvelteTemplate(str, options) {
7111
7111
  }
7112
7112
  // resolve scripts
7113
7113
  const { scriptTag, moduleScriptTag } = scripts.getTopLevelScriptTags();
7114
- scripts.blankOtherScriptTags(str);
7114
+ if (options.mode !== 'ts') {
7115
+ scripts.blankOtherScriptTags(str);
7116
+ }
7115
7117
  //resolve stores
7116
7118
  const resolvedStores = stores.getStoreNames();
7117
7119
  return {
package/index.mjs CHANGED
@@ -1114,7 +1114,7 @@ function extractTag(htmlx, tag, useNewTransformation) {
1114
1114
  let content = match[4];
1115
1115
  if (!content) {
1116
1116
  if (useNewTransformation) {
1117
- // Keep tag and transform it properly by removing it
1117
+ // Keep tag and transform it like a regular element
1118
1118
  content = '';
1119
1119
  }
1120
1120
  else {
@@ -7081,7 +7081,9 @@ function processSvelteTemplate(str, options) {
7081
7081
  }
7082
7082
  // resolve scripts
7083
7083
  const { scriptTag, moduleScriptTag } = scripts.getTopLevelScriptTags();
7084
- scripts.blankOtherScriptTags(str);
7084
+ if (options.mode !== 'ts') {
7085
+ scripts.blankOtherScriptTags(str);
7086
+ }
7085
7087
  //resolve stores
7086
7088
  const resolvedStores = stores.getStoreNames();
7087
7089
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte2tsx",
3
- "version": "0.5.18",
3
+ "version": "0.5.20",
4
4
  "description": "Convert Svelte components to TSX for type checking",
5
5
  "author": "David Pershouse",
6
6
  "license": "MIT",
package/svelte-jsx.d.ts CHANGED
@@ -67,6 +67,7 @@ declare namespace svelteHTML {
67
67
  // over those manually defined in the old, taking precendence over the defaults, to make sth like this possible
68
68
  // https://github.com/sveltejs/language-tools/issues/1352#issuecomment-1248627516
69
69
  Omit<
70
+ // TODO once old transformation is out and JSX.IntrinsicElements is empty, we need an additional "does this Property exist on JSX.IntrinsicElements" check
70
71
  Omit<import('./svelte-html-do-not-use').SvelteHTMLElements[Property], keyof EventsWithColon<svelte.JSX.IntrinsicElements[Property & string]>> & EventsWithColon<svelte.JSX.IntrinsicElements[Property & string]>,
71
72
  keyof Override
72
73
  > & Override;
@@ -1397,6 +1398,12 @@ declare namespace svelte.JSX {
1397
1398
  svelteoptions: { [name: string]: any };
1398
1399
  sveltehead: { [name: string]: any };
1399
1400
  svelteelement: { 'this': string | undefined | null; } & HTMLProps<any> & SVGProps<any> & SapperAnchorProps & SvelteKitAnchorProps;
1401
+ // Needed due to backwards compatibility type which hits these
1402
+ 'svelte:window': HTMLProps<Window> & SvelteWindowProps;
1403
+ 'svelte:body': HTMLProps<HTMLElement>;
1404
+ 'svelte:fragment': { slot?: string; };
1405
+ 'svelte:options': { [name: string]: any };
1406
+ 'svelte:head': { [name: string]: any };
1400
1407
 
1401
1408
  [name: string]: { [name: string]: any };
1402
1409
  }
package/svelte-shims.d.ts CHANGED
@@ -36,7 +36,7 @@ declare class Svelte2TsxComponent<
36
36
  * Causes the callback function to be called whenever the component dispatches an event.
37
37
  * A function is returned that will remove the event listener when called.
38
38
  */
39
- $on<K extends keyof Events & string>(event: K, handler: (e: Events[K]) => any): () => void;
39
+ $on<K extends keyof Events & string>(event: K, handler: ((e: Events[K]) => any) | null | undefined): () => void;
40
40
  /**
41
41
  * Removes a component from the DOM and triggers any `onDestroy` handlers.
42
42
  */
@@ -292,7 +292,7 @@ declare type ATypedSvelteComponent = {
292
292
  */
293
293
  $$slot_def: any;
294
294
 
295
- $on(event: string, handler: (e: any) => any): () => void;
295
+ $on(event: string, handler: ((e: any) => any) | null | undefined): () => void;
296
296
  }
297
297
  /**
298
298
  * Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT