Create-react-app: Visual Studio can't suggest my prop types

Created on 2 May 2019  路  14Comments  路  Source: facebook/create-react-app

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Props, PropTypes, VS Code

Environment

VS Code: 1.33.1
System:
    OS: Windows 10 - 10.0.17763.437
    CPU: (4) x64 Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz
  Binaries:
    Node: 10.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.1.0
    Internet Explorer: 11.0.17763.1
    I have Chrome and Firefox too
  npmPackages:
    react: ^16.8.6 => 16.8.6
    react-dom: ^16.8.6 => 16.8.6
    react-scripts: 3.0.0 => 3.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

jsconfig.json places in my global folder (not in src):

{
  "compilerOptions": {
    "jsx": "react",
    "baseUrl": "./src"
  }
}

I installed React PropTypes Intellisense extension into VS Code

  1. Write propTypes
  2. In your component, type this.props. and hit [Ctrl] + [Space] to show suggestions

Expected Behavior

My PropTypes should be in suggestion window

Actual Behavior

obraz
It's also didn't work outside of component - I only have ref, children and key suggestions from React

Reproducible Demo

Not needed - it's default CRA setup 3.0.0

stale

All 14 comments

I'm practically sure only static props can be set for defaultProps and a babel configuration.
https://reactjs.org/docs/typechecking-with-proptypes.html
Try this instead:

class Greeting extends React.Component {
  render() {
    return (
      <h1>Hello, {this.props.name}</h1>
    );
  }
}

// Specifies the default values for props:
Greeting.defaultProps = {
  name: PropTypes.string
};

@semoal Thanks for your answer. It's a typo in your quick-code - should be Greeting.propTypes = {

Anyway. Changing static propTypes into ColumnChart.propTypes and this same for defaultProps (and of course moving it outside class) didn't work - both for this same class file suggestions and suggestions in other components that are calling my <ColumnChart someOfMyProp=... />

Changing my file extension from .js to .jsx didn't helped too :(

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

a

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

a

This one works --> https://marketplace.visualstudio.com/items?itemName=cuneyt-aliustaoglu.vscode-react-proptypes-intellisense

But after creating the Component.propTypes you have to call this one from command platte. cmd+shift+p and search for proptype intellisense and hit enter. It will automatically create augments for the given proptypes ;)

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

Removing stale**

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

u

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

I suggest filing an issue with the plugin, I don't think there is anything we can do from our side here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stopachka picture stopachka  路  3Comments

barcher picture barcher  路  3Comments

wereHamster picture wereHamster  路  3Comments

DaveLindberg picture DaveLindberg  路  3Comments

Aranir picture Aranir  路  3Comments