svelte2tsx 0.7.11 → 0.7.12
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 +7 -4
- package/index.mjs +7 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3246,7 +3246,7 @@ function convertHtmlxToJsx(str, ast, onWalk = null, onLeave = null, options = {
|
|
|
3246
3246
|
estreeTypedParent.type === 'InlineComponent'
|
|
3247
3247
|
? element
|
|
3248
3248
|
: undefined);
|
|
3249
|
-
if (
|
|
3249
|
+
if (parent === ast) {
|
|
3250
3250
|
// root snippet -> move to instance script
|
|
3251
3251
|
rootSnippets.push([node.start, node.end]);
|
|
3252
3252
|
}
|
|
@@ -6051,7 +6051,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6051
6051
|
}
|
|
6052
6052
|
};
|
|
6053
6053
|
const walk = (node, parent) => {
|
|
6054
|
-
var _a;
|
|
6054
|
+
var _a, _b, _c;
|
|
6055
6055
|
const onLeaveCallbacks = [];
|
|
6056
6056
|
generics.addIfIsGeneric(node);
|
|
6057
6057
|
if (is$$EventsDeclaration(node)) {
|
|
@@ -6094,7 +6094,10 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6094
6094
|
if (ts.isVariableDeclaration(node)) {
|
|
6095
6095
|
events.checkIfIsStringLiteralDeclaration(node);
|
|
6096
6096
|
events.checkIfDeclarationInstantiatedEventDispatcher(node);
|
|
6097
|
-
|
|
6097
|
+
// Only top level declarations can be stores
|
|
6098
|
+
if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) === tsAst) {
|
|
6099
|
+
implicitStoreValues.addVariableDeclaration(node);
|
|
6100
|
+
}
|
|
6098
6101
|
}
|
|
6099
6102
|
if (ts.isCallExpression(node)) {
|
|
6100
6103
|
events.checkIfCallExpressionIsDispatch(node);
|
|
@@ -6139,7 +6142,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6139
6142
|
// Defensively call function (checking for undefined) because it got added only recently (TS 4.0)
|
|
6140
6143
|
// and therefore might break people using older TS versions
|
|
6141
6144
|
// Don't transform in ts mode because <type>value type assertions are valid in this case
|
|
6142
|
-
if (mode !== 'ts' && ((
|
|
6145
|
+
if (mode !== 'ts' && ((_c = ts.isTypeAssertionExpression) === null || _c === void 0 ? void 0 : _c.call(ts, node))) {
|
|
6143
6146
|
handleTypeAssertion(str, node, astOffset);
|
|
6144
6147
|
}
|
|
6145
6148
|
//to save a bunch of condition checks on each node, we recurse into processChild which skips all the checks for top level items
|
package/index.mjs
CHANGED
|
@@ -3226,7 +3226,7 @@ function convertHtmlxToJsx(str, ast, onWalk = null, onLeave = null, options = {
|
|
|
3226
3226
|
estreeTypedParent.type === 'InlineComponent'
|
|
3227
3227
|
? element
|
|
3228
3228
|
: undefined);
|
|
3229
|
-
if (
|
|
3229
|
+
if (parent === ast) {
|
|
3230
3230
|
// root snippet -> move to instance script
|
|
3231
3231
|
rootSnippets.push([node.start, node.end]);
|
|
3232
3232
|
}
|
|
@@ -6031,7 +6031,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6031
6031
|
}
|
|
6032
6032
|
};
|
|
6033
6033
|
const walk = (node, parent) => {
|
|
6034
|
-
var _a;
|
|
6034
|
+
var _a, _b, _c;
|
|
6035
6035
|
const onLeaveCallbacks = [];
|
|
6036
6036
|
generics.addIfIsGeneric(node);
|
|
6037
6037
|
if (is$$EventsDeclaration(node)) {
|
|
@@ -6074,7 +6074,10 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6074
6074
|
if (ts.isVariableDeclaration(node)) {
|
|
6075
6075
|
events.checkIfIsStringLiteralDeclaration(node);
|
|
6076
6076
|
events.checkIfDeclarationInstantiatedEventDispatcher(node);
|
|
6077
|
-
|
|
6077
|
+
// Only top level declarations can be stores
|
|
6078
|
+
if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) === tsAst) {
|
|
6079
|
+
implicitStoreValues.addVariableDeclaration(node);
|
|
6080
|
+
}
|
|
6078
6081
|
}
|
|
6079
6082
|
if (ts.isCallExpression(node)) {
|
|
6080
6083
|
events.checkIfCallExpressionIsDispatch(node);
|
|
@@ -6119,7 +6122,7 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
|
|
|
6119
6122
|
// Defensively call function (checking for undefined) because it got added only recently (TS 4.0)
|
|
6120
6123
|
// and therefore might break people using older TS versions
|
|
6121
6124
|
// Don't transform in ts mode because <type>value type assertions are valid in this case
|
|
6122
|
-
if (mode !== 'ts' && ((
|
|
6125
|
+
if (mode !== 'ts' && ((_c = ts.isTypeAssertionExpression) === null || _c === void 0 ? void 0 : _c.call(ts, node))) {
|
|
6123
6126
|
handleTypeAssertion(str, node, astOffset);
|
|
6124
6127
|
}
|
|
6125
6128
|
//to save a bunch of condition checks on each node, we recurse into processChild which skips all the checks for top level items
|