Code Monkey home page Code Monkey logo

types-js's Introduction

Starknet types JS/TS

🐺 Starknet TypeScript types 🚀

GitHub Workflow Status Project license Pull Requests welcome

Shared TypeScript type definitions for Starknet projects

Installation

npm i @starknet-io/types-js

Types

  // type import
  import type { SomeApiType } from '@starknet-io/types-js'
  // or entire namespace import
  import { API } from '@starknet-io/types-js'
  // type import
  import type { SomeWalletApiType } from '@starknet-io/types-js'
  // or entire namespace import
  import { WALLET_API } from '@starknet-io/types-js'
  • /src/wallet-api/typedData.ts

Versioning (pending SPEC PR merge)

(MAJOR.MINOR) Version of this package should follow starknet-spec semantic versioning. PATCH version can diverge based on bug-fixes ex. Starknet types v0.7.x <-> Starknet Spec v0.7.x

Devs Build

npm run build

Devs Testing

npm run lint

License

This repository is licensed under the MIT License, see LICENSE for more information.

types-js's People

Contributors

lukasaric avatar semantic-release-bot avatar tabaktoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

types-js's Issues

BUG : problem of library import

Describe the bug
When using this lib in ts-node, I have a compilation message error :

TSError: ⨯ Unable to compile TypeScript:
src/tmp/26.testSepolia.ts:12:28 - error TS1479: 
The current file is a CommonJS module whose imports will produce 'require' calls; 
however, the referenced file is an ECMAScript module and cannot be imported with 'require'. 
Consider writing a dynamic 'import("starknet-types")' call instead.
  To convert this file to an ECMAScript module, change its file extension to '.mts', 
or add the field `"type": "module"` to '/home/edmond/Documents/starknet/starknet.js-workshop-typescript/package.json'.

12 import { WALLET_API } from "starknet-types";
                              ~~~~~~~~~~~~~~~~

To Reproduce

  • create a TS script, including :
import { WALLET_API } from "starknet-types";
  • using this package.json :
{
  "name": "starknet-js-typescript",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest",
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "starknet": "6.9.0",
    "starknet-merkle-tree": "^1.0.2",
    "starknet-types": "^0.7.2",
  },
  "devDependencies": {
    "ts-node": "^10.9.2",
    "typescript": "^5.3.3"
  }
}
  • and this tsconfig.json :
{
  "compilerOptions": {
    "target":"ES2022",
    "lib": [
      "es2022",
      "dom"
    ],
    "outDir": "./out",
    "rootDir": "./src",
    "incremental": true,
    "module": "Node16",
    "moduleResolution": "Node16",
    "resolveJsonModule": true,
    "strict": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "isolatedModules": true,
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}
  • try to compile
ts-node ./script.ts

Expected behavior
Use of this library with my project config, without compilation error.

Screenshots
N/A

Desktop (please complete the following information):

  • Browser & version [e.g. chrome, safari, webworker] : any
  • Node version [e.g. 16.0.1] : [email protected]
  • library version : 0.7.2

Additional context
I am using this project config for a long time, without any problem on many libraries, except this one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.