question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useGlobal() does not compile using TypeScript - Throws TS2345 Error

See original GitHub issue

I need to use @ts-ignore to get this to compile

import React, {useGlobal, setGlobal} from 'reactn';

function foo() {
    setGlobal({bar: 'test'});
    // @ts-ignore TS2345: Argument of type '"bar"' is not assignable to parameter of type 'never'.
    const [ bar ] = useGlobal('bar');
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CharlesStovercommented, Apr 18, 2020

Check out the TypeScript support section of the README. 🙂

0reactions
simonv3commented, Aug 14, 2020

One way around the limitations of the isolatedModules call for me was to create a reactn.d.ts file in a styles folder and put the stuff from the README in there.

src/
 - ...
 - types/
   - reactn.d.ts
   - index.d.ts

That seems to load everything correctly, and typecheck appropriately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript compile error #3551 - ethers-io/ethers.js - GitHub
node_modules/@ethersproject/abstract-provider/src.ts/index.ts:251:13 - error TS2322: Type 'BigNumber' is not assignable to type 'null'.
Read more >
Error: TSError: Unable to compile TypeScript - Stack Overflow
I had met same issue. First I remove ts-node and typescript from package.json . then, npm install ts-node --save-dev npm install typescript ......
Read more >
TypeScript errors and how to fix them
error TS2345: Argument of type ' number ' is not assignable to parameter of type ' TimerHandler '. Broken Code ❌. 1 2...
Read more >
First TypeScript Program: Compile and Run - TutorialsTeacher
ts(5,32): error TS2345: Argument of type 'abc' is not assignable to parameter of type 'number'. So, TypeScript does not compile the code if...
Read more >
TSConfig Reference - Docs on every TSConfig option
When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor. ts. class...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found