How do I build the project with TypeScript?

#1

I’m trying to use blockstack with vanilla client-side TypeScript. When I first ‘npm install blockstack,’ I get the following 37 errors:

[email protected]:~/workbench/opendar/opendar/public/javascripts/typescript$ tsc
src/TodoRepository.ts:2:22 - error TS2307: Cannot find module 'Todo.js'.

2 import { Todo } from 'Todo.js';
                       ~~~~~~~~~

src/node_modules/blockstack/lib/auth/userSession.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/auth/userSession.d.ts:146:38 - error TS2580: Cannot findname 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

146     encryptContent(content: string | Buffer, options?: {
                                         ~~~~~~

src/node_modules/blockstack/lib/auth/userSession.d.ts:159:18 - error TS2580: Cannot findname 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

159     }): string | Buffer;
                     ~~~~~~

src/node_modules/blockstack/lib/auth/userSession.d.ts:169:45 - error TS2580: Cannot findname 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

169     putFile(path: string, content: string | Buffer, options?: import('../storage').PutFileOptions): Promise<string>;
                                                ~~~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:1:23 - error TS2688: Cannot find typedefinition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:2:16 - error TS7016: Could not find adeclaration file for module 'bn.js'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`

2 import BN from 'bn.js';
                 ~~~~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:29:75 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

29 export declare function encryptECIES(publicKey: string, content: string | Buffer): CipherObject;
                                                                             ~~~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:42:87 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

42 export declare function decryptECIES(privateKey: string, cipherObject: CipherObject):Buffer | string;
~~~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:54:73 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

54 export declare function signECDSA(privateKey: string, content: string | Buffer): {
                                                                           ~~~~~~

src/node_modules/blockstack/lib/encryption/ec.d.ts:67:69 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

67 export declare function verifyECDSA(content: string | ArrayBuffer | Buffer, publicKey: string, signature: string): boolean;
                                                                       ~~~~~~

src/node_modules/blockstack/lib/encryption/wallet.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/encryption/wallet.d.ts:10:84 - error TS2580: Cannot findname 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

10 export declare function encryptMnemonic(phrase: string, password: string): Promise<Buffer>;
                                                                                      ~~~~~~

src/node_modules/blockstack/lib/encryption/wallet.d.ts:19:57 - error TS2580: Cannot findname 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

19 export declare function decryptMnemonic(data: (string | Buffer), password: string): Promise<string>;
                                                           ~~~~~~

src/node_modules/blockstack/lib/keys.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/keys.d.ts:8:60 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

8 export declare function getEntropy(numberOfBytes: number): Buffer;
                                                             ~~~~~~

src/node_modules/blockstack/lib/network.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'bitcoinjs-lib'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bitcoinjs-lib/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/bitcoinjs-lib` if it exists or add a new declaration (.d.ts) file containing `declare module 'bitcoinjs-lib';`

1 import bitcoinjs from 'bitcoinjs-lib';
                        ~~~~~~~~~~~~~~~

src/node_modules/blockstack/lib/network.d.ts:2:16 - error TS7016: Could not find a declaration file for module 'bn.js'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`

2 import BN from 'bn.js';
                 ~~~~~~~

src/node_modules/blockstack/lib/operations/signers.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'bitcoinjs-lib'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bitcoinjs-lib/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/bitcoinjs-lib` if it exists or add a new declaration (.d.ts) file containing `declare module 'bitcoinjs-lib';`

1 import bitcoinjs from 'bitcoinjs-lib';
                        ~~~~~~~~~~~~~~~

src/node_modules/blockstack/lib/operations/skeletons.d.ts:1:21 - error TS7016: Could notfind a declaration file for module 'bitcoinjs-lib'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bitcoinjs-lib/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/bitcoinjs-lib` if it exists or add a new declaration (.d.ts) file containing `declare module 'bitcoinjs-lib';`

1 import bitcoin from 'bitcoinjs-lib';
                      ~~~~~~~~~~~~~~~

src/node_modules/blockstack/lib/operations/skeletons.d.ts:2:16 - error TS7016: Could notfind a declaration file for module 'bn.js'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`

2 import BN from 'bn.js';
                 ~~~~~~~

src/node_modules/blockstack/lib/operations/txbuild.d.ts:1:16 - error TS7016: Could not find a declaration file for module 'bn.js'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bn.js/lib/bn.js' implicitly has an 'any' type.
  Try `npm install @types/bn.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'bn.js';`

1 import BN from 'bn.js';
                 ~~~~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:2:23 - error TS7016: Could not find a declaration file for module 'bitcoinjs-lib'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bitcoinjs-lib/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/bitcoinjs-lib` if it exists or add a new declaration (.d.ts) file containing `declare module 'bitcoinjs-lib';`

2 import bitcoinjs from 'bitcoinjs-lib';
                        ~~~~~~~~~~~~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:14:39 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

14 export declare function hash160(buff: Buffer): Buffer;
                                         ~~~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:14:48 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

14 export declare function hash160(buff: Buffer): Buffer;
                                                  ~~~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:19:39 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

19 export declare function hash128(buff: Buffer): Buffer;
                                         ~~~~~~

src/node_modules/blockstack/lib/operations/utils.d.ts:19:48 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

19 export declare function hash128(buff: Buffer): Buffer;
                                                  ~~~~~~

src/node_modules/blockstack/lib/public.d.ts:10:29 - error TS7016: Could not find a declaration file for module 'jsontokens'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/jsontokens/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/jsontokens` if it exists or add a new declaration (.d.ts) filecontaining `declare module 'jsontokens';`

10 export { decodeToken } from 'jsontokens';
                               ~~~~~~~~~~~~

src/node_modules/blockstack/lib/storage/index.d.ts:1:23 - error TS2688: Cannot find typedefinition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/storage/index.d.ts:51:58 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

51 export declare function encryptContent(content: string | Buffer, options?: {
                                                            ~~~~~~

src/node_modules/blockstack/lib/storage/index.d.ts:69:36 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

69 }, caller?: UserSession): string | Buffer;
                                      ~~~~~~

src/node_modules/blockstack/lib/storage/index.d.ts:126:65 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

126 export declare function putFile(path: string, content: string | Buffer, options?: PutFileOptions, caller?: UserSession): Promise<string>;
                                                                    ~~~~~~

src/node_modules/blockstack/lib/utils.d.ts:1:24 - error TS7016: Could not find a declaration file for module 'bitcoinjs-lib'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bitcoinjs-lib/src/index.js' implicitly has an 'any' type.
  Try `npm install @types/bitcoinjs-lib` if it exists or add a new declaration (.d.ts) file containing `declare module 'bitcoinjs-lib';`

1 import { ECPair } from 'bitcoinjs-lib';
                         ~~~~~~~~~~~~~~~

src/node_modules/blockstack/lib/wallet.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

src/node_modules/blockstack/lib/wallet.d.ts:2:23 - error TS7016: Could not find a declaration file for module 'bip32'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/src/node_modules/bip32/index.js' implicitly has an 'any' type.
  Try `npm install @types/bip32` if it exists or add a new declaration (.d.ts) file containing `declare module 'bip32';`

2 import { BIP32 } from 'bip32';
                        ~~~~~~~

src/node_modules/blockstack/lib/wallet.d.ts:32:33 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node`.

32     static fromSeedBuffer(seed: Buffer): BlockstackWallet;
                                   ~~~~~~


Found 37 errors.

[email protected]:~/workbench/opendar/opendar/public/javascripts/typescript$ 

After installing each dependency, I still get the following 9 errors:

[email protected]:~/workbench/opendar/opendar/public/javascripts/typescript$ tsc
node_modules/blockstack/lib/encryption/ec.d.ts:2:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bn.js/index"' has no default export.

2 import BN from 'bn.js';
         ~~

node_modules/blockstack/lib/network.d.ts:1:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bitcoinjs-lib/index"' has no default export.

1 import bitcoinjs from 'bitcoinjs-lib';
         ~~~~~~~~~

node_modules/blockstack/lib/network.d.ts:2:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bn.js/index"' hasno default export.

2 import BN from 'bn.js';
         ~~

node_modules/blockstack/lib/operations/signers.d.ts:1:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bitcoinjs-lib/index"' has no default export.

1 import bitcoinjs from 'bitcoinjs-lib';
         ~~~~~~~~~

node_modules/blockstack/lib/operations/skeletons.d.ts:1:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bitcoinjs-lib/index"' has no default export.

1 import bitcoin from 'bitcoinjs-lib';
         ~~~~~~~

node_modules/blockstack/lib/operations/skeletons.d.ts:2:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bn.js/index"' has no default export.

2 import BN from 'bn.js';
         ~~

node_modules/blockstack/lib/operations/txbuild.d.ts:1:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bn.js/index"' has no default export.

1 import BN from 'bn.js';
         ~~

node_modules/blockstack/lib/operations/utils.d.ts:2:8 - error TS1192: Module '"/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/@types/bitcoinjs-lib/index"' has no default export.

2 import bitcoinjs from 'bitcoinjs-lib';
         ~~~~~~~~~

node_modules/blockstack/lib/public.d.ts:10:29 - error TS7016: Could not find a declaration file for module 'jsontokens'. '/home/eleanor/workbench/opendar/opendar/public/javascripts/typescript/node_modules/jsontokens/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/jsontokens` if it exists or add a new declaration (.d.ts) filecontaining `declare module 'jsontokens';`

10 export { decodeToken } from 'jsontokens';
                               ~~~~~~~~~~~~


Found 9 errors.

[email protected]:~/workbench/opendar/opendar/public/javascripts/typescript$

How does one build a TypeScript project with blockstack?Preformatted text

1 Like