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

there is a format question in typescript file #111

Open
taomas opened this issue Feb 7, 2021 · 1 comment
Open

there is a format question in typescript file #111

taomas opened this issue Feb 7, 2021 · 1 comment

Comments

@taomas
Copy link

taomas commented Feb 7, 2021

error stack

src/helpers/cookie.ts 14ms
TypeError: Cannot read property 'map' of undefined
    at Converter.convertNode (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:1225:64)
    at Converter.converter (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:72:29)
    at Converter.convertChild (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:144:21)
    at /<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:200:32
    at Array.map (<anonymous>)
    at Converter.convertBodyExpressions (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:199:14)
    at Converter.convertNode (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:433:32)
    at Converter.converter (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:72:29)
    at Converter.convertProgram (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:47:21)
    at Object.astConverter (/<path>/node_modules/prettierx/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js:25:29)
error Command failed with exit code 2.

i found the error is appear when export syntax.

this is the error code

import { isEqual } from 'lodash'
import { useState, useCallback } from 'react'
export interface IProps<U> {
  bodyParams: U | any
  queryParams?: U | any
}
export interface IParams<T> {
  bodyParams?: T
  queryParams?: T
}
export interface IOptions {
  isLoading?: boolean
}

export interface IRespoense {
  code: number
  data: any
  errInfos: any
  errorCode: number
  msg: string
  ret: number
}
function useLazyRequest<T = any> (
  request: any,
  options?: IOptions
): [boolean, any, (runParams?: T) => Promise<void>] {
  const [loading, setloadding] = useState(true)
  const [data, setdata] = useState(null)
  const run = useCallback(
    async runParams => {
      options.isLoading && setloadding(true)
      request(runParams)
        .then((res: IRespoense) => {
          if (!isEqual(res, data)) setdata(res)
        })
        .catch((err: Error) => {
          console.log(err)
        })
        .finally(() => {
          options.isLoading && setloadding(false)
        })
    },
    [data, loading]
  )
  return [loading, data, run]
}
export default useLazyRequest

how to fix the error ?

@starpit
Copy link

starpit commented Feb 21, 2021

I suspect that this is because prettierx 0.11.3 is using an old version of @typescript-eslint/typescript-estree (2.6.1) which is not compatible with typescript 4+.

the latest version of @typescript-eslint/typescript-estree is 4.15.1
the latest version of prettierx is 0.17.0

prettier-standard has hard-wired this older version of prettierx:

{
    "prettierx": "0.11.3"                                                                                                      
}

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