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

npx tsc error #371

Closed
arch0x opened this issue Oct 16, 2019 · 6 comments
Closed

npx tsc error #371

arch0x opened this issue Oct 16, 2019 · 6 comments

Comments

@arch0x
Copy link

arch0x commented Oct 16, 2019

I run npx tsc in docker (FROM node:12.12.0) and gave the following error:

Step 9/11 : RUN npx tsc
 ---> Running in faa6b0c40395
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(2,23): error TS2688: Cannot find type definition file for './types/ckb_rpc'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(13,53): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(14,66): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(15,54): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(16,57): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(18,56): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(19,74): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(27,28): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(28,28): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(29,26): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(30,28): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(31,32): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(32,27): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(33,30): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(34,29): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(35,36): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(36,26): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(37,40): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(38,34): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(39,28): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(40,30): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(41,26): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(42,31): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(43,24): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(44,32): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(46,19): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(52,26): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(53,41): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(59,43): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(60,49): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(67,26): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(68,48): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(69,50): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(70,40): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(71,39): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(72,41): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(73,42): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(74,46): error TS2503: Cannot find namespace 'CKB_RPC'.
node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts(75,52): error TS2503: Cannot find namespace 'CKB_RPC'.
The command '/bin/sh -c npx tsc' returned a non-zero code: 2
...

This problem does not appear on my Apple computer.I suspect that it is the case of the folder name in sdk, please see the figure below:
image

@Keith-CY
Copy link
Member

Could you please post the docker configuration here? Thx.

And please try npx lerna run tsc in the docker instead of npx tsc directly

@arch0x
Copy link
Author

arch0x commented Oct 17, 2019

FROM node:12.12.0

WORKDIR /app

RUN yarn global add pm2

COPY package.json ./
COPY yarn.lock ./
RUN yarn

COPY . .
RUN yarn postinstall
RUN npx tsc

EXPOSE 8080
CMD ["pm2-runtime", "ecosystem.config.js"]

@arch0x
Copy link
Author

arch0x commented Oct 17, 2019

I have fixed it because https://github.com/nervosnetwork/ckb-sdk-js/tree/develop/packages/ckb-sdk-rpc/types/CKB_RPC This folder name is in uppercase letters.

I solved it with the patch below:

diff --git a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts
index 3c012c7..17a45f1 100644
--- a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts
+++ b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/index.d.ts
@@ -1,5 +1,5 @@
 /// <reference types="@nervosnetwork/ckb-types" />
-/// <reference types="./types/CKB_RPC" />
+/// <reference types="./types/ckb_rpc" />
 import DefaultRPC from './defaultRPC';
 import { DebugLevel } from './enum';
 import Method from './method';
diff --git a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/paramsFormatter.d.ts b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/paramsFormatter.d.ts
index 2018f44..f5eba99 100644
--- a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/paramsFormatter.d.ts
+++ b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/paramsFormatter.d.ts
@@ -1,5 +1,5 @@
 /// <reference types="@nervosnetwork/ckb-types" />
-/// <reference types="./types/CKB_RPC" />
+/// <reference types="./types/ckb_rpc" />
 declare const formatter: {
     toOptional: (format?: Function | undefined) => (arg: any) => any;
     toHash: (hash: string) => string;
diff --git a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/resultFormatter.d.ts b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/resultFormatter.d.ts
index ad34e36..26fafc2 100644
--- a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/resultFormatter.d.ts
+++ b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/resultFormatter.d.ts
@@ -1,4 +1,4 @@
-/// <reference types="./types/CKB_RPC" />
+/// <reference types="./types/ckb_rpc" />
 /// <reference types="@nervosnetwork/ckb-types" />
 declare const formatter: {
     toNumber: (number: string) => string;
diff --git a/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/types/ckb_rpc/index.d.ts b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/types/ckb_rpc/index.d.ts
new file mode 100644
index 0000000..428e784
--- /dev/null
+++ b/node_modules/@nervosnetwork/ckb-sdk-rpc/lib/types/ckb_rpc/index.d.ts
@@ -0,0 +1,211 @@
+/**
+ * @see https://github.com/nervosnetwork/ckb/blob/develop/util/jsonrpc-types/src/blockchain.rs
+ */
+
+/* eslint-disable camelcase */
+declare module CKB_RPC {
+    export type ProposalShortId = CKBComponents.ProposalShortId
+    export type Number = CKBComponents.Number
+    export type UInt32 = CKBComponents.UInt32
+    export type Count = CKBComponents.Count
+    export type Hash256 = CKBComponents.Hash256
+    export type Version = CKBComponents.Version
+    export type Capacity = CKBComponents.Capacity
+    export type Witness = CKBComponents.Witness
+    export type Bytes = CKBComponents.Bytes
+    export type Index = CKBComponents.Index
+    export type Since = CKBComponents.Since
+    export type Timestamp = CKBComponents.Timestamp
+    export type BlockNumber = CKBComponents.BlockNumber
+    export type EpochInHeader = string
+    export type Difficulty = CKBComponents.Difficulty
+    export type Cycles = CKBComponents.Cycles
+    export type Size = CKBComponents.Size
+  
+    export type TransactionStatus = CKBComponents.TransactionStatus
+  
+    export type ScriptHashType = 'data' | 'type'
+  
+    export type DepType = 'code' | 'dep_group'
+  
+    export interface Script {
+      args: Bytes
+      code_hash: Hash256
+      hash_type: ScriptHashType
+    }
+  
+    export interface OutPoint {
+      tx_hash: Hash256
+      index: Index
+    }
+  
+    export interface CellInput {
+      previous_output: OutPoint | null
+      since: Since
+    }
+  
+    export interface CellOutput {
+      capacity: Capacity
+      lock: Script
+      type?: Script | null
+    }
+  
+    export type Cell = CellOutput
+  
+    export interface LiveCell {
+      data?: {
+        content: CKBComponents.Hash
+        hash: Hash256
+      }
+      output: CellOutput
+    }
+  
+    export interface CellDep {
+      out_point: OutPoint | null
+      dep_type: DepType
+    }
+  
+    export interface CellIncludingOutPoint {
+      block_hash: Hash256
+      capacity: Capacity
+      lock: Script
+      out_point: OutPoint | null
+    }
+  
+    export interface RawTransaction {
+      version: Version
+      cell_deps: CellDep[]
+      header_deps: Hash256[]
+      inputs: CellInput[]
+      outputs: CellOutput[]
+      witnesses: Witness[]
+      outputs_data: Bytes[]
+    }
+  
+    export interface Transaction extends RawTransaction {
+      hash: Hash256
+    }
+  
+    export interface TransactionWithStatus {
+      transaction: Transaction
+      tx_status: {
+        block_hash: Hash256 | null
+        status: TransactionStatus
+      }
+    }
+  
+    export interface TransactionPoint {
+      block_number: BlockNumber
+      index: Index
+      tx_hash: Hash256
+    }
+  
+    export interface TransactionByLockHash {
+      consumed_by: null | TransactionPoint
+      created_by: TransactionPoint
+    }
+    export type TransactionsByLockHash = TransactionByLockHash[]
+  
+    export interface LiveCellByLockHash {
+      cell_output: CellOutput
+      created_by: TransactionPoint
+    }
+    export type LiveCellsByLockHash = LiveCellByLockHash[]
+  
+    export interface Header {
+      compact_target: CKBComponents.Hash
+      dao: CKBComponents.DAO
+      epoch: EpochInHeader
+      hash: Hash256
+      number: BlockNumber
+      parent_hash: Hash256
+      proposals_hash: Hash256
+      nonce: CKBComponents.Nonce
+      timestamp: Timestamp
+      transactions_root: Hash256
+      uncles_hash: Hash256
+      version: Version
+    }
+  
+    export interface UncleBlock {
+      header: Header
+      proposals: ProposalShortId[]
+    }
+  
+    export interface Block {
+      header: Header
+      uncles: UncleBlock[]
+      transactions: Transaction[]
+      proposals: ProposalShortId[]
+    }
+  
+    export interface AlertMessage {
+      id: string
+      priority: string
+      notice_until: Timestamp
+      message: string
+    }
+  
+    export interface BlockchainInfo {
+      is_initial_block_download: boolean
+      epoch: string
+      difficulty: string
+      median_time: string
+      chain: string
+      alerts: AlertMessage[]
+    }
+  
+    export interface NodeInfo {
+      addresses: { address: string; score: string }[]
+      node_id: string
+      is_outbound: boolean | null
+      version: string
+    }
+  
+    export interface PeersState {
+      last_updated: string
+      blocks_in_flight: string
+      peer: string
+    }
+  
+    export interface TxPoolInfo {
+      orphan: Count
+      pending: Count
+      proposed: Count
+      last_txs_updated_at: Timestamp
+      total_tx_cycles: Cycles
+      total_tx_size: Size
+    }
+  
+    export interface Epoch {
+      compact_target: CKBComponents.Hash
+      length: string
+      number: string
+      start_number: string
+    }
+  
+    export interface LockHashIndexState {
+      block_hash: Hash256
+      block_number: BlockNumber
+      lock_hash: Hash256
+    }
+  
+    export type LockHashIndexStates = LockHashIndexState[]
+  
+    export interface BannedAddress {
+      address: string
+      ban_reason: string
+      ban_until: Timestamp
+      created_at: Timestamp
+    }
+    export type BannedAddresses = BannedAddress[]
+  
+    export interface CellbaseOutputCapacityDetails {
+      primary: string
+      proposal_reward: string
+      secondary: string
+      total: string
+      tx_fee: string
+    }
+  }
+  /* eslint-enable camelcase */

@arch0x
Copy link
Author

arch0x commented Oct 17, 2019

I remember, ckb-sdk-rpc this package does not contain the ./types/CKB_RPC directory, I downloaded your own source code and packaged it into a patch.

@arch0x
Copy link
Author

arch0x commented Oct 17, 2019

I am using your package, not build.

@Keith-CY
Copy link
Member

Keith-CY commented Dec 8, 2019

Feel free to re-open if there are still problems related to the type definition.

@Keith-CY Keith-CY closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants