Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Illegal return statement #3

Closed
cliffordfajardo opened this issue Feb 9, 2023 · 0 comments · Fixed by #5
Closed

SyntaxError: Illegal return statement #3

cliffordfajardo opened this issue Feb 9, 2023 · 0 comments · Fixed by #5

Comments

@cliffordfajardo
Copy link

cliffordfajardo commented Feb 9, 2023

What is the bug?

Attempted to run the small example code in the README file but got an error.

Machine Details

Node version 17.9.1
OS: Mac OS Ventura

Steps to reproduce

Create a new project (npm init then insteall @clock/core, copy and paste the first code block in this bug report and attempt to run it

node index.mjs

on the following file called index.mjs

import { TextPrompt, isCancel } from "@clack/core";

const p = new TextPrompt({
  render() {
    return `What's your name?\n${this.valueWithCursor}`;
  },
});

const name = await p.prompt();
if (isCancel(name)) {
  return;
}

fails with the following error:

~/Downloads/test-scripts/clack-cli-test node index.mjs
file:///Users/cfajardo/Downloads/test-scripts/clack-cli-test/index.mjs:11
  return;
  ^^^^^^

SyntaxError: Illegal return statement
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:117:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:361:14)
    at async link (node:internal/modules/esm/module_job:70:21)

It seems the problem is with the isCancel because this works fine:

// index.mjs`
import { TextPrompt, isCancel } from "@clack/core";

const p = new TextPrompt({
  render() {
    return `What's your name?\n${this.valueWithCursor}`;
  },
});

const name = await p.prompt();
//if (isCancel(name)) {
  //return;
//}
natemoo-re added a commit that referenced this issue Feb 9, 2023
@natemoo-re natemoo-re linked a pull request Feb 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant