flow-js-testing icon indicating copy to clipboard operation
flow-js-testing copied to clipboard

Add TypeScript support

Open janhesters opened this issue 3 years ago • 2 comments

Issue To Be Solved

Add support for TypeScript, so that autocomplete and other developer tooling works.

(Optional): Suggest A Solution

Solution 1: Rewrite in TypeScript

Pretty self explanatory. Would probably take weeks because TypeScript usually messes you up at edge cases. This would automatically generate type definitions when building to JavaScript.

Solution 2:

Create .d.ts file. This would have to be maintained "separately" if the code base stays in plain JavaScript. Separately means here that you might forget to update the .d.ts file and functions don't conform to it.


Comparison

Solution 1 (rewrite) is certainly more work than solution 2 (type declarations). TypeScript is widely used right now and many developers would consider it easier to contribute to the codebase after solution 1, if it was fully written in TypeScript - (which may or may not be objectively true).

(Optional): Context

Its not blocking anything, but it makes development a little harder because you always have to check out the docs and (depending on the strictness of your config) TypeScript constantly yells at you for missing types.

janhesters avatar Dec 12 '21 00:12 janhesters

Would love to see this implemented if possible! 😄

Running into an exact use case where our codebase is in typescript, but our testing suite for all things cadence needs to be run in js.

gambinish avatar Mar 08 '22 22:03 gambinish

@janhesters @gambinish

Type definitions are now added for the main API functions, and they can be installed with:

npm i --save-dev @types/onflow__flow-js-testing

adbario avatar Aug 16 '22 18:08 adbario