MenuTroubleshooting / My TypeScript did not run because of a type error

Docs / Troubleshooting

My TypeScript did not run because of a type error

With “Don’t run with type errors” on, a TypeScript Snippet with a type error prints the error instead of running.

On this page

Why it did not run

You turned on Settings → Running → Don’t run with type errors. With it on, JSpark checks a TypeScript Snippet before each Run. If it finds a type error, nothing runs:

  • The console prints each error on its own line, such as Line 5: Type 'string' is not assignable to type 'number'.
  • The footer says Didn’t run.
  • The error is underlined in the editor.
The type error is printed in the console, and the footer says Didn’t run.

The setting is off by default. It never holds a JavaScript Snippet. In a Vue or Svelte component, it counts only when the component’s script is TypeScript (lang="ts").

Run as you type still runs. Each time, the Run prints the errors again, until the code has none.

Fix the error

  1. Click the error in the console. The cursor goes to that line.
  2. Fix the code. Hover the underline to read the error there too.
  3. Press ⌘↵ or Ctrl+Enter, or wait for Run as you type.

When the code has no type errors, it runs as usual.

Or run with type errors

To run code that has type errors, turn the setting off:

  1. Open Settings with ⌘, or Ctrl+,.
  2. Go to Running.
  3. Turn off Don’t run with type errors.

Type errors are then underlined, and the code runs anyway. The change applies to the next Run in every open tab. See JavaScript and TypeScript.

The pictures show JSpark on a Mac. On Windows, the window looks a little different and uses Ctrl for ⌘, but everything works the same way.

Esc

Type to search every docs page.