Comments (5)
Workaround:
set migrations_directory: './dist',
in truffle.js
add this to package.json scripts
"build:truffle": "truffle compile",
"build:contracts": "typechain --target truffle './build/contracts/*.json'",
"build:ts": "tsc --declaration",
"build": "npm run build:truffle && npm run build:contracts && npm run build:ts",
and run npm run build && truffle migrate
I use this tsconfig file
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "ES2017",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"skipLibCheck": true,
"paths": {
"*": ["node_modules/*", "types/*"]
}
},
"exclude": ["dist/**/*"]
}
from truffle-typechain-example.
My fix PR was merged in the latest truffle beta
from truffle-typechain-example.
While I can now select .ts files, it freaks out on imports
import { MigrationsContract } from '../types/truffle-contracts/index';
const Migrations: MigrationsContract = artifacts.require('./Migrations.sol');
const migration: Truffle.Migration = async (deployer: Truffle.Deployer) => {
await deployer.deploy(Migrations);
};
module.exports = migration;
// because of https://stackoverflow.com/questions/40900791/cannot-redeclare-block-scoped-variable-in-unrelated-files
export {};
Without the MigrationsContract
the artifacts.require returns an 'any' which does not help me at all in making my migrations strongly typed.
from truffle-typechain-example.
Using jsdoc comments might be a decent work around for now. You can still import the generated typings.
Example:
import {
ConvertLibContract,
MetaCoinContract
} from "../types/truffle-contracts";
/**
* @type {ConvertLibContract}
*/
var ConvertLib = artifacts.require("./ConvertLib.sol");
/**
* @type {MetaCoinContract}
*/
var MetaCoin = artifacts.require("./MetaCoin.sol");
from truffle-typechain-example.
The problem with:
var ConvertLib = artifacts.require("./ConvertLib.sol");
is that you need to use artifact name like this instead:
var ConvertLib = artifacts.require("ConvertLib");
But anyway, I can't get it to work as files don't seem to be transpiled on the fly... I am not sure why. @roderik any ideas?
from truffle-typechain-example.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from truffle-typechain-example.