question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript/Flow support

See original GitHub issue

After having used this tool for a bit, I’m starting to really miss the type-safety I’m used to on other projects.

I definitely think the default should be vanilla JS, since it’s much more familiar and lower-friction, but I wonder if it’d be worth setting it up to transpile Typescript or Flow? I think ideally, the user experience wouldn’t change at all, except for it processing .ts files as well as .js.

(I’ve actually never used Typescript, I’ve used Flow extensively… but TS is much more popular than Flow, so it probably makes more sense to focus on that)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
neefrehmancommented, Jun 27, 2020

I’ve just been looking into integrating TypeScript with canvas-sketch in a React project of mine. I’ve created a Wrapper component and have documented the types myself for now based on the documentation: https://gist.github.com/neefrehman/eb94d76e3bfd7e562d9f01fbebb97e19

Having access to up-to-date typings for the library would be super useful, would there be a simple way to generate and publish them to @types/canvas-sketch?

0reactions
henckellbachcommented, Jul 6, 2020

@mattdesl I tried my hand at typing the basics (RendererObjects & SketchManager excluded): https://github.com/mattdesl/canvas-sketch/pull/103

Usage example:

const canvasSketch = require('canvas-sketch');
import { SketchFunction, SettingsObject } from 'canvas-sketch';

const settings: SettingsObject = {
  duration: 5,
  animate: true,
  dimensions: [512, 512],
};

const sketch: SketchFunction = () => {
  return ({ context, width, height }) => {
    context.fillStyle = 'orange';
    context.fillRect(0, 0, width, height);
  };
};

canvasSketch(sketch, settings);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flow: A Static Type Checker for JavaScript
And Flow can help you understand the code you wrote six months ago. ... Using data flow analysis, Flow infers types and tracks...
Read more >
Support for TypeScript definition files · Issue #7 · facebook/flow
Flow supports modules organized following the CommonJS / Node.js specification.
Read more >
Typescript vs Flow. Which static type checker should you use ...
Both Flow and TypeScript have support from IDEs like Visual Studio Code and Sublime. This means that developers get functionality like ...
Read more >
TypeScript VS Flow: Type Checking Front End JavaScript
TypeScript VS Flow: Syntax, IDE support, framework support, and roadmaps. JavaScript is a dynamically typed programming language.
Read more >
Comparing statically typed JavaScript implementations
In this post, we'll compare three of the most popular ways of imposing static typing on JavaScript: TypeScript, Flow, and PropTypes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found