Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts: when starting a new anchor project, the workspace type is missing #1153

Closed
paul-schaaf opened this issue Dec 16, 2021 · 6 comments
Closed
Labels
bug Something isn't working ts

Comments

@paul-schaaf
Copy link
Contributor

After running

anchor init hello-world

In tests/hello-anchor.ts:

Property 'workspace' does not exist on type 'typeof import("/Users/paul/Coding/solana/forks/hello-anchor/node_modules/@project-serum/anchor/dist/cjs/index")'.ts(2339)

The js object does exist because my tests are running fine. It's just the type that is missing

@paul-schaaf paul-schaaf added bug Something isn't working ts labels Dec 16, 2021
@lucasnad27
Copy link

I've ran into this issue as well, running v0.19.0

@nicechute
Copy link

nicechute commented Dec 20, 2021

Stuck on this too, running js tests fixes for now

@ton11797
Copy link

Workaround
change
import * as anchor from '@project-serum/anchor';
to
const anchor = require("@project-serum/anchor");

@janlegner
Copy link

Also Wallet is missing. It is caused by recent changes with

if (!isBrowser) {
  exports.workspace = require("./workspace.js").default;
  exports.Wallet = require("./nodewallet.js").default;
}

The workaround with require is not good enough as the type is then any. Of course, another workaround would be to add custom declaration files. But also maybe this could work: #1182. What do you think?

@ron-liu
Copy link

ron-liu commented Dec 29, 2021

We hit this problem too, hope can be released soon.

@paul-schaaf
Copy link
Contributor Author

fixed by #1137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ts
Projects
None yet
Development

No branches or pull requests

6 participants