preprocess-loader icon indicating copy to clipboard operation
preprocess-loader copied to clipboard

Constant declaration

Open btzr-io opened this issue 5 years ago • 2 comments

How can I fix this error ?

// @if TARGET='web'
  const finalSource = useStream(stream);
  // @endif

  // @if TARGET='app'
  const finalSource = useFileStream(file);
  // @endif
 error  Parsing error: Identifier 'finalSource' has already been declared

btzr-io avatar May 08 '20 23:05 btzr-io

One possible way would be to do something like this:

let finalSource;

// @if TARGET='web'
finalSource = useStream(stream);
// @endif

// @if TARGET='app'
finalSource = useFileStream(file);
// @endif

scholtzm avatar May 11 '20 12:05 scholtzm

Thanks, that's what I did 👍

btzr-io avatar May 11 '20 14:05 btzr-io