vechain / connex

The mono-repo contains libraries to help build dApps for VeChain.
https://docs.vechain.org/developer-resources/sdks-and-providers/connex
GNU Lesser General Public License v3.0
86 stars 3.64k forks source link

index.d.ts' is not a module #46

Closed malikov917 closed 5 years ago

malikov917 commented 5 years ago

hi, I have angular 5 project and currently face with a problem:

in my app.component.ts

import {Connex} from '@vechain/connex'; _nodemodules/@vechain/connex/index.d.ts' is not a module

tsconfig.app.json is:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": ["@vechain/connex"]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": ["@vechain/connex"], // tried this too ->["node_modules/@vechain/connex"]
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "exclude": [
    "dist"
  ],
  "include": [
    "**/*.ts"
  ]
}

in addition:

ERROR in node_modules/@vechain/connex/index.d.ts(438,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(439,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(447,19): error TS1005: '>' expected. node_modules/@vechain/connex/index.d.ts(448,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(449,9): error TS1109: Expression expected. node_modules/@vechain/connex/index.d.ts(540,15): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(541,15): error TS1005: ';' expected.

Angular CLI: 1.7.4 Node: 8.11.2 OS: win32 x64 Angular: 5.2.11 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.7.4 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.2 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.5.3 webpack-raphael: 2.1.4 webpack: 3.11.0

qianbin commented 5 years ago

@malikov917 no need to import. 'types' settings in tsconfig is all right.

malikov917 commented 5 years ago

@qianbin then how to use connex inside a project? even after declare const connex; I'm getting: ERROR ReferenceError: connex is not defined

qianbin commented 5 years ago

I'm not familiar with angular, while you can check the tips at https://github.com/vechain/connex#typescript-complier-does-not-find-connex

malikov917 commented 5 years ago

@qianbin I've tried this tips without result

qianbin commented 5 years ago

Have you tried to remove typeRoots in tsconfig.json?

malikov917 commented 5 years ago

@qianbin hm I need it for "typeRoots": [ "node_modules/@types" ]

that's for others 'types'

qianbin commented 5 years ago

try upgrade typescript to latest release

malikov917 commented 5 years ago

@qianbin Ok, update up to "typescript": "3.4.5" (latest), still getting same issue

File '.../node_modules/@vechain/connex/index.d.ts' is not a module.

qianbin commented 5 years ago

@malikov917 Remove the line import {Connex} from '@vechain/connex';

malikov917 commented 5 years ago

@qianbin but how can I use 'connex' inside a project? connex is undefined

malikov917 commented 5 years ago

@qianbin thank you for your support, actually I've figured out how to make it work. In 10 minutes I'll leave a short review and "close and comment" 💯

qianbin commented 5 years ago

@malikov917 :-) wondering how

malikov917 commented 5 years ago

@qianbin I appreciate your support, well the solution was:

  1. Work via Sync App

  2. NOT to import it via: import {Connex} from '@vechain/connex';

  3. Just declare it like: declare const window; declare const connex;

Rest of things are described in dev tips in instruction on Connex; That was a bit strange for me that I don't need to import Connex into my project and this thing is happening automatically;

malikov917 commented 5 years ago

@qianbin hm I just thought one more time on that and decided that usage of Typescript is impossible still. I'm supposing that this issue still has a sense