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

Type 'N' cannot be used to index type 'NumberToString' with TS 2.5.2 when importing Ramda #234

Closed
alshain opened this issue Sep 6, 2017 · 11 comments

Comments

@alshain
Copy link

alshain commented Sep 6, 2017

According to the manual, I've installed the typings with npm install --save-dev types/npm-ramda#dist

import * as R from 'ramda';

leads to the following error:

node_modules@types\ramda\src\view.d.ts
(90,12): error TS2536: Type 'N' cannot be used to index type 'NumberToString'.

packge.json excerpt:

"@types/ramda": "github:types/npm-ramda#dist",
"ramda": "^0.24.1",
"typescript": "^2.5.2"
@alshain
Copy link
Author

alshain commented Sep 6, 2017

Using "@types/ramda": "^0.24.9" instead, as generated by a regular npm install -S @types/ramda works fine with said code and TS 2.5.2

@KiaraGrouwstra
Copy link
Member

Sounds like microsoft/TypeScript#15768, which I imagine should have made it in. Bit surprised, think @ikatyang had tried with 2.5.2 at #224.

@ikatyang
Copy link
Member

ikatyang commented Sep 6, 2017

I'm not sure why the error did not occur in the build, but I already have a fix for it in #233 though it'll cause TS 2.4 to error since the bug fix was in TS 2.5.

I'll port them to master later.

@ikatyang
Copy link
Member

ikatyang commented Sep 6, 2017

@alshain

The definition from npm install -S @types/ramda is currently maintained by DefinitelyTyped, and we're trying to generate DT compatible definitions so as to put them on DT.

@alshain
Copy link
Author

alshain commented Sep 6, 2017

@ikatyang Thanks for the link, I was wondering why Ramda linked here rather than to DefinitelyTyped.

@KiaraGrouwstra
Copy link
Member

@alshain: it's because the definitions over there aren't actively maintained (not to mention it's tougher to discuss issues without a distinct repo); it's been the intention to sync the types here back to there, but it hadn't happened yet so far.

@jiayihu
Copy link

jiayihu commented Sep 28, 2017

I'm having the same issue, is there any workaround available for the moment?

@ikatyang
Copy link
Member

@jiayihu

It should be fixed in TS v2.5+, if you're talking about prior to v2.5, you have to add skipLibCheck: true to your tsconfig.json.

@jiayihu
Copy link

jiayihu commented Sep 29, 2017

Thanks for the reply, I confirm it has been solved by updating TS to 2.5.3!

@bstro
Copy link

bstro commented Oct 11, 2017

I'm on typescript 2.5.3 using "@types/ramda": "types/npm-ramda#dist" and I get the following error:

/Users/bstro/foo/node_modules/@types/ramda/src/view.d.ts (89,10): error TS2536: Type 'N' cannot be used to index type 'U'.

skipLibCheck: true fixes it.

@ikatyang
Copy link
Member

@bstro

It shouldn't get errors with default config. Can you share some steps to reproduce? I'm not able to reproduce the issue, here's how I tested:

mkdir ramda-test
cd ramda-test
yarn add types/npm-ramda#dist typescript --force
echo '{"compilerOptions": {"strict": true}}' > tsconfig.json
echo 'import * as R from "ramda"; R.view(R.lensIndex(0), [0, 1, 2]);' > test.ts
yarn tsc -p tsconfig.json

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

5 participants