Skip to content

Commit 97fa9ba

Browse files
author
Robert Jackson
committed
Allow svelte flag to in logical expr in an if statement.
1 parent ce71a5c commit 97fa9ba

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

fixtures/development-svelte-builds/expectation6.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ if (DEPRECATED_PARTIALS) {
1212
}
1313

1414
if (DEPRECATED_PARTIALS && someOtherThing()) {
15+
throw new Error('You indicated you don\'t have any deprecations, however you are relying on DEPRECATED_PARTIALS.');
16+
1517
doStuff();
1618
}
1719

fixtures/development-svelte-builds/expectation7.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (DEPRECATED_PARTIALS) {
1212
}
1313

1414
if (DEPRECATED_PARTIALS && someOtherThing()) {
15+
throw new Error("You indicated you don't have any deprecations, however you are relying on DEPRECATED_PARTIALS.");
1516
doStuff();
1617
}
1718

src/utils/macros.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ module.exports = class Macros {
101101
// in debug builds add an error after a conditional (to ensure if the
102102
// specific branch is taken, an error is thrown)
103103
if (envFlags.DEBUG && svelteMap[source][flag] === false) {
104-
if (p.parentPath.isIfStatement()) {
105-
let consequent = p.parentPath.get('consequent');
104+
let parentIfStatement = p.find(p => p.isIfStatement());
105+
if (parentIfStatement) {
106+
let consequent = parentIfStatement.get('consequent');
106107
consequent.unshiftContainer(
107108
'body',
108109
t.throwStatement(

0 commit comments

Comments
 (0)