Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Error on 'extends' operator on generic type #841

Closed
@HyunnoH

Description

I uses Storybook.js on my work, and Storybook.js puts an error when compiling my type definition.

ERROR in ../libs/shared/src/utils/types.ts
Module Error (from /Users/hyun/workspace/yennefer-suite/node_modules/eslint-loader/dist/cjs.js):

  Line 1:23:  Parsing error: Unexpected token, expected ","

> 1 | export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
    |                       ^
  2 | 
  3 | export type Partial<T> = { [P in keyof T]?: T[P] };
  4 | 

Here is my eslintrc setup.

{
  "parser": "@typescript-eslint/parser", // Specifies the ESLint parser
  "extends": [
    "plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
    "plugin:@typescript-eslint/recommended", // Uses the recommended rules from @typescript-eslint/eslint-plugin
    "plugin:import/errors",
    "plugin:import/warnings",
    "airbnb",
    "prettier"
  ],
  "parserOptions": {
    "ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
    "sourceType": "module", // Allows for the use of imports
    "ecmaFeatures": {
      "jsx": true // Allows for the parsing of JSX
    }
  },
  // plugins:
  "rules": {
    // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
    "@typescript-eslint/explicit-function-return-type": "off",
    "import/order": [
      "error",
      {
        "pathGroups": [
          {
            "pattern": "@project/shared",
            "group": "internal",
            "position": "after"
          }
        ],
        "newlines-between": "always"
      }
    ],
    "import/no-unresolved": 0,
    "import/extensions": 0,
    "react/jsx-filename-extension": 0,
    "no-undef": 0,
    "react/jsx-props-no-spreading": 0,
    "react/jsx-curly-newline": 0,
    "react/jsx-one-expression-per-line": 0,
    "react/jsx-wrap-multilines": ["error", { "declaration": false, "assignment": false }]
  },
  "settings": {
    "react": {
      "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
    }
  }
}

And this is my webpack config.

{
        test: /\.(ts|tsx)$/,
        include: path.resolve(__dirname, path.resolve('@project/shared/src')),
        use: [
          require.resolve('ts-loader'),
          {
            loader: require.resolve('react-docgen-typescript-loader'),
            options: {
              // Provide the path to your tsconfig.json so that your stories can
              // display types from outside each individual story.
              tsconfigPath: path.resolve(__dirname, './tsconfig.json'),
            },
          },
        ],
      },

This issues is already reported on #782 , but I don't know is this already solved on latest version. Can you let me know about this?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions