svelte2tsx 0.4.10 → 0.4.11
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.d.ts +6 -2
- package/index.js +12 -12
- package/index.mjs +12 -12
- package/package.json +1 -1
- package/svelte-jsx.d.ts +1 -1
package/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function svelte2tsx(
|
|
|
55
55
|
}
|
|
56
56
|
): SvelteCompiledToTsx
|
|
57
57
|
|
|
58
|
-
export interface
|
|
58
|
+
export interface EmitDtsConfig {
|
|
59
59
|
/**
|
|
60
60
|
* Where to output the declaration files
|
|
61
61
|
*/
|
|
@@ -74,10 +74,14 @@ export interface EmitDtsConig {
|
|
|
74
74
|
libRoot?: string;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// to make typo fix non-breaking, continue to export the old name but mark it as deprecated
|
|
78
|
+
/**@deprecated*/
|
|
79
|
+
export interface EmitDtsConig extends EmitDtsConfig {} /* eslint-disable-line @typescript-eslint/no-empty-interface */
|
|
80
|
+
|
|
77
81
|
/**
|
|
78
82
|
* Searches for a jsconfig or tsconfig starting at `root` and emits d.ts files
|
|
79
83
|
* into `declarationDir` using the ambient file from `svelteShimsPath`.
|
|
80
84
|
* Note: Handwritten `d.ts` files are not copied over; TypeScript does not
|
|
81
85
|
* touch these files.
|
|
82
86
|
*/
|
|
83
|
-
export function emitDts(config:
|
|
87
|
+
export function emitDts(config: EmitDtsConfig): Promise<void>;
|
package/index.js
CHANGED
|
@@ -3767,9 +3767,6 @@ class ExportedNames {
|
|
|
3767
3767
|
`\n /**accessor*/\n set ${name}(_) {}`)
|
|
3768
3768
|
.join('');
|
|
3769
3769
|
}
|
|
3770
|
-
setUses$$Props() {
|
|
3771
|
-
this.uses$$Props = true;
|
|
3772
|
-
}
|
|
3773
3770
|
/**
|
|
3774
3771
|
* Marks a top level declaration as a possible export
|
|
3775
3772
|
* which could be exported through `export { .. }` later.
|
|
@@ -3866,6 +3863,9 @@ class ExportedNames {
|
|
|
3866
3863
|
'...__sveltets_1_ensureRightProps<Partial<$$Props>>({' +
|
|
3867
3864
|
this.createReturnElements(lets, false).join(',') +
|
|
3868
3865
|
'}), ...{} as unknown as $$Props, ...{' +
|
|
3866
|
+
// We add other exports of classes and functions here because
|
|
3867
|
+
// they need to appear in the props object in order to properly
|
|
3868
|
+
// type bind:xx but they are not needed to be part of $$Props
|
|
3869
3869
|
this.createReturnElements(others, false).join(', ') +
|
|
3870
3870
|
'} as {' +
|
|
3871
3871
|
this.createReturnElementsType(others).join(',') +
|
|
@@ -4861,7 +4861,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
4861
4861
|
uses$$SlotsInterface = true;
|
|
4862
4862
|
}
|
|
4863
4863
|
if (is$$PropsDeclaration(node)) {
|
|
4864
|
-
exportedNames.
|
|
4864
|
+
exportedNames.uses$$Props = true;
|
|
4865
4865
|
}
|
|
4866
4866
|
if (ts__namespace.isVariableStatement(node)) {
|
|
4867
4867
|
exportedNames.handleVariableStatement(node, parent);
|
|
@@ -5072,7 +5072,7 @@ function addComponentExport(params) {
|
|
|
5072
5072
|
addSimpleComponentExport(params);
|
|
5073
5073
|
}
|
|
5074
5074
|
}
|
|
5075
|
-
function addGenericsComponentExport({ strictEvents,
|
|
5075
|
+
function addGenericsComponentExport({ strictEvents, canHaveAnyProp, exportedNames, componentDocumentation, fileName, mode, usesAccessors, str, generics }) {
|
|
5076
5076
|
const genericsDef = generics.toDefinitionString();
|
|
5077
5077
|
const genericsRef = generics.toReferencesString();
|
|
5078
5078
|
const doc = componentDocumentation.getFormatted();
|
|
@@ -5083,7 +5083,7 @@ function addGenericsComponentExport({ strictEvents, uses$$propsOr$$restProps, ex
|
|
|
5083
5083
|
let statement = `
|
|
5084
5084
|
class __sveltets_Render${genericsDef} {
|
|
5085
5085
|
props() {
|
|
5086
|
-
return ${props(true,
|
|
5086
|
+
return ${props(true, canHaveAnyProp, exportedNames, `render${genericsRef}()`)}.props;
|
|
5087
5087
|
}
|
|
5088
5088
|
events() {
|
|
5089
5089
|
return ${events(strictEvents, `render${genericsRef}()`)}.events;
|
|
@@ -5112,8 +5112,8 @@ class __sveltets_Render${genericsDef} {
|
|
|
5112
5112
|
}
|
|
5113
5113
|
str.append(statement);
|
|
5114
5114
|
}
|
|
5115
|
-
function addSimpleComponentExport({ strictEvents, isTsFile,
|
|
5116
|
-
const propDef = props(isTsFile,
|
|
5115
|
+
function addSimpleComponentExport({ strictEvents, isTsFile, canHaveAnyProp, exportedNames, componentDocumentation, fileName, mode, usesAccessors, str }) {
|
|
5116
|
+
const propDef = props(isTsFile, canHaveAnyProp, exportedNames, events(strictEvents, 'render()'));
|
|
5117
5117
|
const doc = componentDocumentation.getFormatted();
|
|
5118
5118
|
const className = fileName && classNameFromFilename(fileName, mode !== 'dts');
|
|
5119
5119
|
let statement;
|
|
@@ -5151,13 +5151,13 @@ function addSimpleComponentExport({ strictEvents, isTsFile, uses$$propsOr$$restP
|
|
|
5151
5151
|
function events(strictEvents, renderStr) {
|
|
5152
5152
|
return strictEvents ? renderStr : `__sveltets_1_with_any_event(${renderStr})`;
|
|
5153
5153
|
}
|
|
5154
|
-
function props(isTsFile,
|
|
5154
|
+
function props(isTsFile, canHaveAnyProp, exportedNames, renderStr) {
|
|
5155
5155
|
if (isTsFile) {
|
|
5156
|
-
return
|
|
5156
|
+
return canHaveAnyProp ? `__sveltets_1_with_any(${renderStr})` : renderStr;
|
|
5157
5157
|
}
|
|
5158
5158
|
else {
|
|
5159
5159
|
const optionalProps = exportedNames.createOptionalPropsArray();
|
|
5160
|
-
const partial = `__sveltets_1_partial${
|
|
5160
|
+
const partial = `__sveltets_1_partial${canHaveAnyProp ? '_with_any' : ''}`;
|
|
5161
5161
|
return optionalProps.length > 0
|
|
5162
5162
|
? `${partial}([${optionalProps.join(',')}], ${renderStr})`
|
|
5163
5163
|
: `${partial}(${renderStr})`;
|
|
@@ -5518,7 +5518,7 @@ function svelte2tsx(svelte, options = {}) {
|
|
|
5518
5518
|
}
|
|
5519
5519
|
addComponentExport({
|
|
5520
5520
|
str,
|
|
5521
|
-
uses$$
|
|
5521
|
+
canHaveAnyProp: !exportedNames.uses$$Props && (uses$$props || uses$$restProps),
|
|
5522
5522
|
strictEvents: events.hasStrictEvents(),
|
|
5523
5523
|
isTsFile: options === null || options === void 0 ? void 0 : options.isTsFile,
|
|
5524
5524
|
exportedNames,
|
package/index.mjs
CHANGED
|
@@ -3737,9 +3737,6 @@ class ExportedNames {
|
|
|
3737
3737
|
`\n /**accessor*/\n set ${name}(_) {}`)
|
|
3738
3738
|
.join('');
|
|
3739
3739
|
}
|
|
3740
|
-
setUses$$Props() {
|
|
3741
|
-
this.uses$$Props = true;
|
|
3742
|
-
}
|
|
3743
3740
|
/**
|
|
3744
3741
|
* Marks a top level declaration as a possible export
|
|
3745
3742
|
* which could be exported through `export { .. }` later.
|
|
@@ -3836,6 +3833,9 @@ class ExportedNames {
|
|
|
3836
3833
|
'...__sveltets_1_ensureRightProps<Partial<$$Props>>({' +
|
|
3837
3834
|
this.createReturnElements(lets, false).join(',') +
|
|
3838
3835
|
'}), ...{} as unknown as $$Props, ...{' +
|
|
3836
|
+
// We add other exports of classes and functions here because
|
|
3837
|
+
// they need to appear in the props object in order to properly
|
|
3838
|
+
// type bind:xx but they are not needed to be part of $$Props
|
|
3839
3839
|
this.createReturnElements(others, false).join(', ') +
|
|
3840
3840
|
'} as {' +
|
|
3841
3841
|
this.createReturnElementsType(others).join(',') +
|
|
@@ -4831,7 +4831,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
4831
4831
|
uses$$SlotsInterface = true;
|
|
4832
4832
|
}
|
|
4833
4833
|
if (is$$PropsDeclaration(node)) {
|
|
4834
|
-
exportedNames.
|
|
4834
|
+
exportedNames.uses$$Props = true;
|
|
4835
4835
|
}
|
|
4836
4836
|
if (ts.isVariableStatement(node)) {
|
|
4837
4837
|
exportedNames.handleVariableStatement(node, parent);
|
|
@@ -5042,7 +5042,7 @@ function addComponentExport(params) {
|
|
|
5042
5042
|
addSimpleComponentExport(params);
|
|
5043
5043
|
}
|
|
5044
5044
|
}
|
|
5045
|
-
function addGenericsComponentExport({ strictEvents,
|
|
5045
|
+
function addGenericsComponentExport({ strictEvents, canHaveAnyProp, exportedNames, componentDocumentation, fileName, mode, usesAccessors, str, generics }) {
|
|
5046
5046
|
const genericsDef = generics.toDefinitionString();
|
|
5047
5047
|
const genericsRef = generics.toReferencesString();
|
|
5048
5048
|
const doc = componentDocumentation.getFormatted();
|
|
@@ -5053,7 +5053,7 @@ function addGenericsComponentExport({ strictEvents, uses$$propsOr$$restProps, ex
|
|
|
5053
5053
|
let statement = `
|
|
5054
5054
|
class __sveltets_Render${genericsDef} {
|
|
5055
5055
|
props() {
|
|
5056
|
-
return ${props(true,
|
|
5056
|
+
return ${props(true, canHaveAnyProp, exportedNames, `render${genericsRef}()`)}.props;
|
|
5057
5057
|
}
|
|
5058
5058
|
events() {
|
|
5059
5059
|
return ${events(strictEvents, `render${genericsRef}()`)}.events;
|
|
@@ -5082,8 +5082,8 @@ class __sveltets_Render${genericsDef} {
|
|
|
5082
5082
|
}
|
|
5083
5083
|
str.append(statement);
|
|
5084
5084
|
}
|
|
5085
|
-
function addSimpleComponentExport({ strictEvents, isTsFile,
|
|
5086
|
-
const propDef = props(isTsFile,
|
|
5085
|
+
function addSimpleComponentExport({ strictEvents, isTsFile, canHaveAnyProp, exportedNames, componentDocumentation, fileName, mode, usesAccessors, str }) {
|
|
5086
|
+
const propDef = props(isTsFile, canHaveAnyProp, exportedNames, events(strictEvents, 'render()'));
|
|
5087
5087
|
const doc = componentDocumentation.getFormatted();
|
|
5088
5088
|
const className = fileName && classNameFromFilename(fileName, mode !== 'dts');
|
|
5089
5089
|
let statement;
|
|
@@ -5121,13 +5121,13 @@ function addSimpleComponentExport({ strictEvents, isTsFile, uses$$propsOr$$restP
|
|
|
5121
5121
|
function events(strictEvents, renderStr) {
|
|
5122
5122
|
return strictEvents ? renderStr : `__sveltets_1_with_any_event(${renderStr})`;
|
|
5123
5123
|
}
|
|
5124
|
-
function props(isTsFile,
|
|
5124
|
+
function props(isTsFile, canHaveAnyProp, exportedNames, renderStr) {
|
|
5125
5125
|
if (isTsFile) {
|
|
5126
|
-
return
|
|
5126
|
+
return canHaveAnyProp ? `__sveltets_1_with_any(${renderStr})` : renderStr;
|
|
5127
5127
|
}
|
|
5128
5128
|
else {
|
|
5129
5129
|
const optionalProps = exportedNames.createOptionalPropsArray();
|
|
5130
|
-
const partial = `__sveltets_1_partial${
|
|
5130
|
+
const partial = `__sveltets_1_partial${canHaveAnyProp ? '_with_any' : ''}`;
|
|
5131
5131
|
return optionalProps.length > 0
|
|
5132
5132
|
? `${partial}([${optionalProps.join(',')}], ${renderStr})`
|
|
5133
5133
|
: `${partial}(${renderStr})`;
|
|
@@ -5488,7 +5488,7 @@ function svelte2tsx(svelte, options = {}) {
|
|
|
5488
5488
|
}
|
|
5489
5489
|
addComponentExport({
|
|
5490
5490
|
str,
|
|
5491
|
-
uses$$
|
|
5491
|
+
canHaveAnyProp: !exportedNames.uses$$Props && (uses$$props || uses$$restProps),
|
|
5492
5492
|
strictEvents: events.hasStrictEvents(),
|
|
5493
5493
|
isTsFile: options === null || options === void 0 ? void 0 : options.isTsFile,
|
|
5494
5494
|
exportedNames,
|
package/package.json
CHANGED
package/svelte-jsx.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ declare namespace svelte.JSX {
|
|
|
102
102
|
onreset?: FormEventHandler<T> | undefined;
|
|
103
103
|
onsubmit?: FormEventHandler<T> | undefined;
|
|
104
104
|
oninvalid?: EventHandler<Event, T> | undefined;
|
|
105
|
-
onbeforeinput?: EventHandler<
|
|
105
|
+
onbeforeinput?: EventHandler<InputEvent, T> | undefined;
|
|
106
106
|
|
|
107
107
|
// Image Events
|
|
108
108
|
onload?: EventHandler | undefined;
|