polkadot-js / api

Promise and RxJS APIs around Polkadot and Substrate based chains via RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata.
Apache License 2.0
1.07k stars 354 forks source link

Getting build errors on TS on polka dot api module #2768

Closed viraj124 closed 4 years ago

viraj124 commented 4 years ago

Hi, I am getting compilation errors with running yarn build, error info below

node_modules/@polkadot/api-derive/democracy/types.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/api-derive/democracy/types.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/api-derive/democracy/types.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/api-derive/staking/types.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/api-derive/staking/types.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/api-derive/staking/types.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/api-derive/type/HeaderExtended.d.ts:10:5 - error TS1127: Invalid character.

10     #private;

node_modules/@polkadot/api-derive/type/SignedBlockExtended.d.ts:10:5 - error TS1127: Invalid character.

10     #private;

node_modules/@polkadot/api-derive/types.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/api-derive/types.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/api-derive/types.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/api/base/Decorate.d.ts:14:5 - error TS1127: Invalid character.

14     #private;

node_modules/@polkadot/api/base/Events.d.ts:3:5 - error TS1127: Invalid character.

3     #private;

node_modules/@polkadot/api/base/Init.d.ts:5:5 - error TS1127: Invalid character.

5     #private;

node_modules/@polkadot/api/promise/Api.d.ts:93:5 - error TS1127: Invalid character.

93     #private;

node_modules/@polkadot/api/promise/Combinator.d.ts:8:5 - error TS1127: Invalid character.

8     #private;

node_modules/@polkadot/api/rx/Api.d.ts:107:5 - error TS1127: Invalid character.

107     #private;

node_modules/@polkadot/api/types/base.d.ts:1:13 - error TS1005: '=' expected.

1 import type { Observable } from 'rxjs';
              ~

node_modules/@polkadot/api/types/base.d.ts:1:33 - error TS1005: ';' expected.

1 import type { Observable } from 'rxjs';
                                  ~~~~~~

node_modules/@polkadot/api/types/index.d.ts:2:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/api/types/index.d.ts:2:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/api/types/index.d.ts:2:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/keyring/keyring.d.ts:21:5 - error TS1127: Invalid character.

21     #private;

node_modules/@polkadot/metadata/Metadata/MetadataVersioned.d.ts:11:5 - error TS1127: Invalid character.

11     #private;

node_modules/@polkadot/rpc-core/index.d.ts:28:5 - error TS1127: Invalid character.

28     #private;

node_modules/@polkadot/rpc-provider/http/index.d.ts:23:5 - error TS1127: Invalid character.

23     #private;

node_modules/@polkadot/rpc-provider/ws/Provider.d.ts:27:5 - error TS1127: Invalid character.

27     #private;

node_modules/@polkadot/types/codec/AbstractInt.d.ts:12:5 - error TS1127: Invalid character.

12     #private;

node_modules/@polkadot/types/codec/BTreeSet.d.ts:4:5 - error TS1127: Invalid character.

4     #private;

node_modules/@polkadot/types/codec/Compact.d.ts:20:5 - error TS1127: Invalid character.

20     #private;

node_modules/@polkadot/types/codec/Enum.d.ts:13:5 - error TS1127: Invalid character.

13     #private;

node_modules/@polkadot/types/codec/Map.d.ts:4:5 - error TS1127: Invalid character.

4     #private;

node_modules/@polkadot/types/codec/Option.d.ts:12:5 - error TS1127: Invalid character.

12     #private;

node_modules/@polkadot/types/codec/Set.d.ts:12:5 - error TS1127: Invalid character.

12     #private;

node_modules/@polkadot/types/codec/Struct.d.ts:23:5 - error TS1127: Invalid character.

23     #private;

node_modules/@polkadot/types/create/registry.d.ts:5:5 - error TS1127: Invalid character.

5     #private;

node_modules/@polkadot/types/generic/Event.d.ts:14:5 - error TS1127: Invalid character.

14     #private;

node_modules/@polkadot/types/primitive/Text.d.ts:12:5 - error TS1127: Invalid character.

12     #private;

node_modules/@polkadot/types/types/index.d.ts:10:1 - error TS1128: Declaration or statement expected.

10 export type { Observable } from 'rxjs';
   ~~~~~~

node_modules/@polkadot/types/types/index.d.ts:10:13 - error TS1005: ';' expected.

10 export type { Observable } from 'rxjs';
               ~

node_modules/@polkadot/types/types/index.d.ts:10:33 - error TS1005: ';' expected.

10 export type { Observable } from 'rxjs';
                                   ~~~~~~

node_modules/@polkadot/types/types/interfaces.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/types/types/interfaces.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/types/types/interfaces.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/types/types/registry.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/types/types/registry.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/types/types/registry.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/util-crypto/key/DeriveJunction.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/util-crypto/key/DeriveJunction.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/util-crypto/key/DeriveJunction.d.ts:1:21 - error TS1005: ';' expected.

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

node_modules/@polkadot/util-crypto/key/DeriveJunction.d.ts:3:5 - error TS1127: Invalid character.

3     #private;

node_modules/@polkadot/util/types.d.ts:1:13 - error TS1005: '=' expected.

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

node_modules/@polkadot/util/types.d.ts:1:16 - error TS1005: ';' expected.

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

node_modules/@polkadot/util/types.d.ts:1:21 - error TS1005: ';' expected.

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

node js version => v12.6.0 @polkadot/api => 2.3.1 The issue happens with running yarn build on my TS Project

jacogr commented 4 years ago

This is related to the following settings in tsconfig under compilerOptions -

At this point there is not override that i know of that will fix it unless using those flags. (There has been some unsuccessful attempts to get it working without)

jacogr commented 4 years ago

I see you have a #private error as well - those were introduced in TS 3.8, it won't compile on earlier versions. https://www.typescriptlang.org/docs/handbook/classes.html#ecmascript-private-fields

viraj124 commented 4 years ago

This is related to the following settings in tsconfig under compilerOptions -

  • "allowSyntheticDefaultImports": true,
  • "esModuleInterop": true,

At this point there is not override that i know of that will fix it unless using those flags. (There has been some unsuccessful attempts to get it working without)

@jacogr let try without these once

viraj124 commented 4 years ago

doesn't work looks like I need to upgrade TS version right ?

jacogr commented 4 years ago

You will need at least 3.8, before that it at least #private (as per the link to TS) is not supported.

jacogr commented 4 years ago

Closing, assuming resolved.

polkadot-js-bot commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.