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

The latest version v7.0.0-rc.1 does not build #803

Closed
tvarghese opened this issue Apr 3, 2019 · 19 comments
Closed

The latest version v7.0.0-rc.1 does not build #803

tvarghese opened this issue Apr 3, 2019 · 19 comments

Comments

@tvarghese
Copy link

🐛 Bug Report

The latest version v7.0.0-rc.1 does not build

To Reproduce

Steps to reproduce the behavior:
Include the module by running the following command
npm install @elastic/elasticsearch --save

Expected behavior

Should build without any errors

However i get the following error
`> tsc

node_modules/@elastic/elasticsearch/lib/Connection.d.ts:77:3 - error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.

77 [inspect.custom](object: any, options: InspectOptions): string;
~~~~~~~~~~~~~~~~
`

Your Environment

  • node version: 8
  • @elastic/elasticsearch version: >=7.0.0
  • os: Mac
  • typescript: 3.4.1
  • tslint: 5.14.0

Other observations

Including @types/elasticsearch would solve the issue however the types support is only for version 5.0.23

@delvedor
Copy link
Member

delvedor commented Apr 4, 2019

Hello!
Did you installed @types/node?

npm i @types/node --save-dev

@jlausolutions
Copy link

I am seeing the same issue with @types/node latest installed.

@delvedor
Copy link
Member

delvedor commented Apr 9, 2019

@jlausolutions can you write the following info?

  • node version: ...
  • @elastic/elasticsearch version: ...
  • os: ...
  • typescript: ...

@jlausolutions
Copy link

node: v10.0.0
@elastic/elasticsearch: ^7.0.0-rc.1
os: MacOS 10.13.6
typescript: ^3.4.2

@delvedor
Copy link
Member

delvedor commented Apr 9, 2019

I just tried the following:

mkdir tstest && cd tstest
npm init -y
npm i @elastic/elasticsearch typescript @types/node
touch index.ts
./node_modules/.bin/tsc index.ts

index.ts contains the following:

import { Client } from '@elastic/elasticsearch'
const client = new Client({ node: 'http://localhost:9200' })
client.info(console.log)

And everything works as expected.
My system info are:

  • node: v10.15.1
  • @elastic/elasticsearch: ^7.0.0-rc.1
  • os: MacOS 10.14.3
  • typescript: ^3.4.2

@jlausolutions
Copy link

I just tried updating node (v10.15.3) and ran the same commands you listed, but am seeing the same error:

node_modules/@elastic/elasticsearch/lib/Connection.d.ts:77:3 - error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.

77   [inspect.custom](object: any, options: InspectOptions): string;

Note that it compiled if you run tsc index.ts immediately after touch index.ts, but throws the error after I add the actual index.ts code that includes the import.

@delvedor
Copy link
Member

delvedor commented Apr 9, 2019

Note that it compiled if you run tsc index.ts immediately after touch index.ts, but throws the error after I add the actual index.ts code that includes the import.

Sorry, I thought it was obvious, I compiled the file after writing the code.
Are you using some additional configuration in tsconfig.json?

@jlausolutions
Copy link

It was obvious -- I was just working backwards when it was still not working.

In any case, the issue was that I also had tsc installed globally and that was an older version (3.1.3). This could be identified when comparing your line ./node_modules/.bin/tsc index.ts instead of tsc index.ts.

Thanks!

@delvedor
Copy link
Member

delvedor commented Apr 9, 2019

Thanks for the follow-up!
Closing this, feel free to reopen if you still encounter this issue.

@delvedor delvedor closed this as completed Apr 9, 2019
@lazaro9318
Copy link

lazaro9318 commented May 2, 2019

Thanks for the follow-up!
Closing this, feel free to reopen if you still encounter this issue.

Hello, I've the same error

My system info are:

  • "@elastic/elasticsearch": "^7.0.0-rc.2"
  • TSC Version 3.4.5
  • Node v10.15.0
  • Windows 10 17134
    I've installed @types/node.
    My tsconfig.json :
    { "compilerOptions": { "module": "commonjs", "esModuleInterop": true, "target": "es2017", "noImplicitAny": true, "moduleResolution": "node", "sourceMap": true, "experimentalDecorators": true, "outDir": "dist", "baseUrl": ".", "paths": { "*": ["node_modules/*", "src/types/*"] } }, "include": ["src/**/*"] }

@delvedor
Copy link
Member

delvedor commented May 2, 2019

Hello @lazaro9318!
Can you create a repository with everything needed to reproduce the issue?
Thanks!

@alanjames1987
Copy link

I'm also having the same problem. It looks just importing Client will cause the error. The problem also happens with version 5.6.16 and 6.7.0.

@delvedor here is a repo that will case the error when building.

https://github.com/alanjames1987/Elasticsearch-TypeScript-Error

Pull it, run npm i, and then run npm run build:prod to trigger the error.

Additionally, I'm using Node v10.15.3, but since this is TypeScript I doubt it's caused by a problem with Node, but giving more information never hurts.

@lazaro9318
Copy link

Hello @lazaro9318!
Can you create a repository with everything needed to reproduce the issue?
Thanks!

I solve the error, deleting the node_modules folder and installing again.

@alanjames1987
Copy link

@lazaro9318 Deleting the node_modules folder doesn't solve the problem in any test I've done. It also couldn't solve the problem unless you updated the version number after deleting node_modules and before reinstalling.

@alanjames1987
Copy link

Additionally, for anyone else having this problem you can install elasticsearch instead of @elastic/elasticsearch. You will have to change some Elasticsearch code but if you're in a time crunch to get some code released this will at least give you a working codebase.

@delvedor
Copy link
Member

Apparently, the issue is caused by this line:

[inspect.custom](object: any, options: InspectOptions): string;

Because TypeScript does not know how to handle Symbols, or if it does, it does it really bad.

I'll open a pr with a fix.

@delvedor delvedor reopened this May 11, 2019
delvedor added a commit that referenced this issue May 11, 2019
@delvedor delvedor mentioned this issue May 11, 2019
@alanjames1987
Copy link

I can confirm that this pull request works for me.

delvedor added a commit that referenced this issue May 14, 2019
delvedor added a commit that referenced this issue May 14, 2019
delvedor added a commit that referenced this issue May 14, 2019
@ariasjose
Copy link

Waiting for this fix on v6.x

@delvedor
Copy link
Member

delvedor commented Feb 4, 2020

Hello @ariasjose, the fix has already been released in 6.x :)

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

6 participants