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

warning Missing return type on function #3

Closed
BlueAccords opened this issue Mar 29, 2019 · 8 comments
Closed

warning Missing return type on function #3

BlueAccords opened this issue Mar 29, 2019 · 8 comments

Comments

@BlueAccords
Copy link

WARNING in ./src/App.tsx
Module Warning (from ./node_modules/eslint-loader/index.js):

/Users/blueaccords/dev/main-project/src/App.tsx
  4:42  warning  Missing return type on function  @typescript-eslint/explicit-function-return-type

 1 problem (0 errors, 1 warning)

 @ ./src/index.tsx 3:0-24 4:36-39
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src
Child html-webpack-plugin for "index.html":

Is what I get after running npm install and npm run dev on the project.

Didn't make any changes to the default files.

App.tsx is

import React from 'react';
import { hot } from 'react-hot-loader/root';

const App: React.FunctionComponent<{}> = () => <div>Hello World</div>;
App.displayName = 'App';
export default hot(App);

Is the explicit-function-return-type typescript rule just too strict and not recommended to have on or am I missing something?

@BlueAccords
Copy link
Author

BlueAccords commented Mar 29, 2019

Nvm just pulled your latest update that fixed this! 95ac64a

@saranshkataria
Copy link
Owner

@BlueAccords The error still exists in the test file, and I am still trying to get that to work. Having a discussion here: typescript-eslint/typescript-eslint#384

@BlueAccords
Copy link
Author

Oh ok, i'll keep an eye out for updates to the repo then. Do you think it'll cause any problems if I use your boilerplate as a base for development or will I run into issues if I try to write tests due to the same issue?

@saranshkataria
Copy link
Owner

I will update this repo as soon as I get a response from someone there. Also, I am trying to convert this into a npm package so that you don't have to copy paste it and can just use npm versions to update the whole boilerplate.

@saranshkataria
Copy link
Owner

The issue still has a workaround that you explicitly mention void as a return type on test functions, which can be a short term solution. Apart from that, I don't think it would break anything else.

@BlueAccords
Copy link
Author

Alright. Also with the latest version i'm getting this error when trying to run tests but i'm assuming this is the same one you're running into and trying to resolve .

> jest

 FAIL  src/App.test.tsx
  ● Test suite failed to run

    Cannot find module 'core-js/modules/es6.promise' from 'App.test.tsx'

      1 | import React from 'react';
      2 | import TestRenderer from 'react-test-renderer';
    > 3 | import App from './App';
        | ^
      4 |
      5 | it('renders without crashing', async () => {
      6 |   TestRenderer.create(<App />);

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:202:17)
      at Object.<anonymous> (src/App.test.tsx:3:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.996s

@saranshkataria
Copy link
Owner

@BlueAccords I updated the project, Could you take the latest change, remove the node modules and do a fresh install?

@BlueAccords
Copy link
Author

Alright quick run through on a fresh pull, npm run dev and npm run test are both working without any errors/warnings. Thanks for the help!

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

2 participants