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.

createUseStyles typescript declaration missing

See original GitHub issue

Steps to reproduce:

  1. Create a fresh react app
  • npx create-react-app use-styles-ts
  • cd use-styles-ts
  1. Add react-jss and typescript
  • yarn add react-jss@next typescript
  • yarn add -D @types/react
  1. Rename App.js -> App.tsx and implement a simple usage of createUseStyles hook
import React from 'react';
import { createUseStyles } from 'react-jss';

const useStyles = createUseStyles({
  App: { textAlign: 'center' },
})

function App() {
  const classes = useStyles();
  return (
    <div className={classes.App}>
    ...
  1. Start app
  • yarn start

Expected behavior:

  • App compiles and runs normally

Describe the bug:

  • App fails to compile with error:
Failed to compile.

/Users/robcmills/src/jss-use-styles/src/App.tsx
TypeScript error in /Users/robcmills/src/jss-use-styles/src/App.tsx(2,10):
Module '"../../../../../Users/robcmills/src/jss-use-styles/node_modules/react-jss/src"' has no exported member 'createUseStyles'.  TS2305

    1 | import React from 'react';
  > 2 | import { createUseStyles } from 'react-jss';
      |          ^
    3 | import logo from './logo.svg';
    4 | import './App.css';
  • Apparently a typescript declaration for createUseStyles is missing from react-jss/src/index.d.ts
  • I have confirmed that adding a declaration for createUseStyles to this file silences the error

Versions:

  • react-jss: 10.0.0-alpha.17
  • typescript: 3.5.2
  • Browser [e.g. chrome, safari]: Chrome Version 74.0.3729.131 (Official Build) (64-bit)
  • OS [e.g. Windows, macOS]: macOS Sierra version 10.12.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
Kudzecommented, Jul 24, 2019

Having the same issue, just wondering why the issue has been closed.

4reactions
stewartduffycommented, Aug 26, 2019

Any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript Typings with createUseStyles from react-jss
The main thing I believe was missing was having useTheme typed const theme = useTheme<PUTheme>();. View working Code Sandbox here! Share.
Read more >
@types/jss | Yarn - Package Manager
This is a stub types definition. jss provides its own type definitions, so you do not need this installed. Stub TypeScript definitions entry...
Read more >
JSS v10 - Oleg Isonen - Medium
So why do we need a hook creator function createUseStyles() that returns a hook function useStyles() ? It's because we want to automate...
Read more >
jsstyles - Bountysource
Describe the bug: I'm creating a useStyles hook where the rules are all derived from prop values: const useStyles = createUseStyles({ styles: {...
Read more >
Exploring CSS in JS - lee.david.cs
Many well-maintained CiJ libraries ship with TypeScript definitions (examples: Styled-Components, JSS, Emotion, Aphrodite).
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