cli icon indicating copy to clipboard operation
cli copied to clipboard

Formatter produce invalid component state

Open StarpTech opened this issue 6 years ago • 1 comments

Formatting this

$ {
  /* This component rely on https://github.com/mashpie/i18n-node */
  const { req, locale } = out.global;
  const { translationKey, translationParams, plural } = input;
  let message = "";

  if (req && typeof req.t === "function") {
    message = req.t(translationKey, translationParams);
  }
}

-- ${message}

results in

$ //* This component rely on https://github.com/mashpie/i18n-node */
const { req, locale } = out.global;
const { translationKey, translationParams, plural } = input;
let message = "";

if (req && typeof req.t === "function") {
  message = req.t(translationKey, translationParams);
}
-- ${message}

and throws

/home/deus/Repositories/test/node_modules/marko/src/compiler/CompileContext.js:559
                        throw new Error(
                        ^

Error: Invalid node returned from node factory for tag "if".
    at CompileContext.createNodeForEl (/home/deus/Repositories/test/node_modules/marko/src/compiler/CompileContext.js:559:31)
    at Normalizer.normalizeElement (/home/deus/Repositories/test/node_modules/marko/src/compiler/Normalizer.js:109:36)
    at Walker.exit [as _exit] (/home/deus/Repositories/test/node_modules/marko/src/compiler/Normalizer.js:72:50)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:134:25)
    at nodes.forEach.node (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:70:36)
    at ArrayContainer.forEach (/home/deus/Repositories/test/node_modules/marko/src/compiler/ast/ArrayContainer.js:18:26)
    at Walker._walkContainer (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:69:15)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:118:18)
    at TemplateRoot.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/ast/TemplateRoot.js:167:28)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:123:22)
App stopped unexpectedly

StarpTech avatar Mar 08 '19 14:03 StarpTech

This must be related to https://github.com/marko-js/htmljs-parser/pull/68

StarpTech avatar Mar 08 '19 15:03 StarpTech