Skip to content

TypeScript reference path problem when installed via npm. #148

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

Closed
sehyun-hwang opened this issue Nov 16, 2019 · 6 comments
Closed

TypeScript reference path problem when installed via npm. #148

sehyun-hwang opened this issue Nov 16, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@sehyun-hwang
Copy link

sehyun-hwang commented Nov 16, 2019

I'm using this in Angular 8.

In the file @influxdata/influx/dist/api/api.d.ts,
the first line is: <reference path="../src/api/custom.d.ts" />
It should be: <reference path="../../src/api/custom.d.ts" />

@russorat russorat added the bug Something isn't working label Nov 22, 2019
@russorat
Copy link
Contributor

@aegggsehyun1994 thanks! Would you be able to open a quick PR for this?

@sehyun-hwang
Copy link
Author

I did some investigation, and I found that this issue could be a bug in TypeScript.
Check this out: microsoft/TypeScript#27572
Though I can write a temporary fix with shell script that will run on npm install.
If you are fine, I can write a PR this way.

@hoorayimhelping
Copy link
Contributor

hoorayimhelping commented Nov 25, 2019

@aegggsehyun1994 can you post shell script fix in a code block (```) or a gist if a code block is too long?

can you post the steps you took to trigger this error? I'm assuming it's yarn install but the specifics are helpful for posterity.

Thanks!

@sehyun-hwang
Copy link
Author

I originally found this bug when I used Angular CLI with npm, but now I found that I can reproduce this bug in a blank npm project. Here are the steps:

npm init
npm i @influxdata/influx
echo "import { Client } from '@influxdata/influx';" > index.ts  
tsc index.js

This script will produce following error:

node_modules/@influxdata/influx/dist/api/api.d.ts:1:22 - error TS6053: File '/opt/bitnami/nginx/html/influx/node_modules/@influxdata/influx/dist/src/api/custom.d.ts' not found.

1 /// <reference path="../src/api/custom.d.ts" />
                       ~~~~~~~~~~~~~~~~~~~~~~

Before I do anything to fix this, I would like to reask to you if a shell script would be the best temporary fix, until the TypeScript bug is resolved.
How would you like this to be fixed?
I think one-liner sed command would be enough though.

@vaclavh
Copy link

vaclavh commented Jan 14, 2020

Same problem I have temporarily fixed by this prebuild project script:

  1. Install shelljs npm install shelljs --save-dev
  2. Create prebuild script ./scripts/prebuild.js with this content
const shell = require('shelljs');

shell.sed('-i', '../src/api/custom.d.ts', '../../src/api/custom.d.ts', './node_modules/@influxdata/influx/dist/api/api.d.ts');
  1. Append to project's package.json scripts section:
"scripts": {
   ...
    "prebuild": "node ./scripts/prebuild.js",
   ...

@sranka
Copy link
Contributor

sranka commented Apr 1, 2020

This client library was replaced with a new version 20+ days ago, so this issue is outdated. Typescript definition files have changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants