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

flow-typed install generated stubs fail type check #2484

Closed
1 of 3 tasks
LoganBarnett opened this issue Jul 6, 2018 · 1 comment
Closed
1 of 3 tasks

flow-typed install generated stubs fail type check #2484

LoganBarnett opened this issue Jul 6, 2018 · 1 comment
Assignees
Labels
bug cli Related to CLI tool

Comments

@LoganBarnett
Copy link
Contributor

LoganBarnett commented Jul 6, 2018

I don't know that all stubs fail to type check, but a healthy amount of them seem to. This might warrant tracking as multiple tickets but I wanted to start from somewhere.

Here's my setup:

  • flow 0.75
  • flow-typed 2.5.0

I run yarn flow-typed install and expect there to be some stubs generated. The command completes successfully. I restart the flow server and these are the errors I see:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/@babel/core_vx.x.x.js:23:1

Unexpected token }

     20│ code: any, 
     21│ ast: any, 
     22│ inputMap
     23│ }: any) => any,
     24│     buildExternalHelpers: (whitelist: any, outputType="global": any) => any,
     25│     resolvePlugin: (name: any, dirname: any) => any,
     26│     resolvePreset: (name: any, dirname: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/@babel/preset-env_vx.x.x.js:20:5

Unexpected token default

     17│   declare module.exports: {
     18│     isPluginRequired: (supportedEnvironments: any, plugin: any) => any,
     19│     transformIncludesAndExcludes: ((result: any, opt: any) => any,
     20│     default: (api: any, options: any, dirname: any) => any,
     21│   };
     22│ }
     23│


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/apigeetool_vx.x.x.js:18:21

Unexpected token =>

     15│
     16│ declare module 'apigeetool' {
     17│   declare module.exports: {
     18│     (defaults: any) => any,
     19│     getPromiseSDK: () => any,
     20│     defaults: (newDefaults: any) => any,
     21│     listDeployments: (opts: any, cb: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/autoprefixer_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'autoprefixer' {
     17│   declare module.exports: {
     18│     () => any,
     19│     process: (css: any, processOpts: any, pluginOpts: any) => any,
     20│     data: {
     21│       browsers: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/caniuse-lite_vx.x.x.js:42:10

Unexpected token -

     39│     features: {
     40│       aac: any,
     41│       abortcontroller: any,
     42│       ac3-ec3: any,
     43│       accelerometer: any,
     44│       addeventlistener: any,
     45│       alternate-stylesheet: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/copy-webpack-plugin_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'copy-webpack-plugin' {
     17│   declare module.exports: {
     18│     () => any,
     19│     default: {
     20│       () => any,
     21│       default: () => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-config-standard_vx.x.x.js:39:15

Unexpected token -

     36│       window: boolean,
     37│     },
     38│     rules: {
     39│       accessor-pairs: string,
     40│       arrow-spacing: any,
     41│       block-spacing: any,
     42│       brace-style: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-filenames_vx.x.x.js:19:12

Unexpected token -

     16│ declare module 'eslint-plugin-filenames' {
     17│   declare module.exports: {
     18│     rules: {
     19│       match-regex: (context: any) => any,
     20│       match-exported: (context: any) => any,
     21│       no-index: (context: any) => any,
     22│     },


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js:22:12

Unexpected token -

     19│       recommended: any,
     20│     },
     21│     rules: {
     22│       array-style-complex-type: any,
     23│       array-style-simple-type: any,
     24│       boolean-style: any,
     25│       define-flow-type: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-import_vx.x.x.js:19:9

Unexpected token -

     16│ declare module 'eslint-plugin-import' {
     17│   declare module.exports: {
     18│     rules: {
     19│       no-unresolved: any,
     20│       named: any,
     21│       default: any,
     22│       namespace: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-max-len-2_vx.x.x.js:19:10

Unexpected token -

     16│ declare module 'eslint-plugin-max-len-2' {
     17│   declare module.exports: {
     18│     rules: {
     19│       max-len-2: any,
     20│     },
     21│   };
     22│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-node_vx.x.x.js:22:14

Unexpected token -

     19│       recommended: any,
     20│     },
     21│     rules: {
     22│       exports-style: any,
     23│       no-deprecated-api: any,
     24│       no-extraneous-import: any,
     25│       no-extraneous-require: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-promise_vx.x.x.js:19:12

Unexpected token -

     16│ declare module 'eslint-plugin-promise' {
     17│   declare module.exports: {
     18│     rules: {
     19│       param-names: any,
     20│       no-return-wrap: any,
     21│       always-return: any,
     22│       catch-or-return: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-react_vx.x.x.js:19:10

Unexpected token -

     16│ declare module 'eslint-plugin-react' {
     17│   declare module.exports: {
     18│     deprecatedRules: {
     19│       jsx-space-before-closing: any,
     20│     },
     21│     rules: {
     22│       boolean-prop-naming: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint-plugin-standard_vx.x.x.js:19:12

Unexpected token -

     16│ declare module 'eslint-plugin-standard' {
     17│   declare module.exports: {
     18│     rules: {
     19│       array-bracket-even-spacing: any,
     20│       computed-property-even-spacing: any,
     21│       object-curly-even-spacing: any,
     22│       no-callback-literal: any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/eslint_vx.x.x.js:25:30

Unexpected token =>

     22│     },
     23│     Linter: () => any,
     24│     CLIEngine: {
     25│       (providedOptions: any) => any,
     26│       version: string,
     27│       getFormatter: (format: any) => any,
     28│     },


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/extract-text-webpack-plugin_vx.x.x.js:18:20

Unexpected token =>

     15│
     16│ declare module 'extract-text-webpack-plugin' {
     17│   declare module.exports: {
     18│     (options: any) => any,
     19│     extract: () => any,
     20│   };
     21│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/file-loader_vx.x.x.js:18:20

Unexpected token =>

     15│
     16│ declare module 'file-loader' {
     17│   declare module.exports: {
     18│     (content: any) => any,
     19│     raw: boolean,
     20│   };
     21│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/glob_vx.x.x.js:18:43

Unexpected token =>

     15│
     16│ declare module 'glob' {
     17│   declare module.exports: {
     18│     (pattern: any, options: any, cb: any) => any,
     19│     sync: {
     20│       (pattern: any, options: any) => any,
     21│       GlobSync: (pattern: any, options: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/nodemon_vx.x.x.js:18:21

Unexpected token =>

     15│
     16│ declare module 'nodemon' {
     17│   declare module.exports: {
     18│     (settings: any) => any,
     19│     restart: () => any,
     20│     on: (event: any, handler: any) => any,
     21│     addListener: (event: any, handler: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/postcss-cssnext_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'postcss-cssnext' {
     17│   declare module.exports: {
     18│     () => any,
     19│     process: (css: any, processOpts: any, pluginOpts: any) => any,
     20│     features: {
     21│       customProperties: (options: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/postcss-custom-properties_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'postcss-custom-properties' {
     17│   declare module.exports: {
     18│     () => any,
     19│     process: (css: any, processOpts: any, pluginOpts: any) => any,
     20│   };
     21│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/postcss_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'postcss' {
     17│   declare module.exports: {
     18│     () => any,
     19│     plugin: (name: any, initializer: any) => any,
     20│     stringify: (node: any, builder: any) => any,
     21│     parse: (css: any, opts: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/react-idle_vx.x.x.js:18:8

Unexpected token =>

     15│
     16│ declare module 'react-idle' {
     17│   declare module.exports: {
     18│     () => any,
     19│     defaultProps: {
     20│       defaultIdle: boolean,
     21│       render: () => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/react-router-redux_vx.x.x.js:20:10

Unexpected token =>

     17│   declare module.exports: {
     18│     __esModule: boolean,
     19│     ConnectedRouter: {
     20│       () => any,
     21│       propTypes: any,
     22│       contextTypes: any,
     23│     },


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/redux-logger_vx.x.x.js:22:18

Cannot use undefined as a type because undefined is a value. To get the type of a value use typeof.

     19│       level: string,
     20│       logger: any,
     21│       logErrors: boolean,
     22│       collapsed: undefined,
     23│       predicate: undefined,
     24│       duration: boolean,
     25│       timestamp: boolean,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/redux-logger_vx.x.x.js:23:18

Cannot use undefined as a type because undefined is a value. To get the type of a value use typeof.

     20│       logger: any,
     21│       logErrors: boolean,
     22│       collapsed: undefined,
     23│       predicate: undefined,
     24│       duration: boolean,
     25│       timestamp: boolean,
     26│       stateTransformer: (e: any) => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/redux-logger_vx.x.x.js:31:22

Cannot use undefined as a type because undefined is a value. To get the type of a value use typeof.

     28│       errorTransformer: (e: any) => any,
     29│       colors: any,
     30│       diff: boolean,
     31│       diffPredicate: undefined,
     32│       transformer: undefined,
     33│     },
     34│     createLogger: () => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/redux-logger_vx.x.x.js:32:20

Cannot use undefined as a type because undefined is a value. To get the type of a value use typeof.

     29│       colors: any,
     30│       diff: boolean,
     31│       diffPredicate: undefined,
     32│       transformer: undefined,
     33│     },
     34│     createLogger: () => any,
     35│     logger: () => any,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/stylelint-config-standard_vx.x.x.js:20:9

Unexpected token -

     17│   declare module.exports: {
     18│     extends: string,
     19│     rules: {
     20│       at-rule-empty-line-before: any,
     21│       at-rule-name-case: string,
     22│       at-rule-name-space-after: string,
     23│       at-rule-semicolon-newline-after: string,


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/svg-sprite-loader_vx.x.x.js:18:20

Unexpected token =>

     15│
     16│ declare module 'svg-sprite-loader' {
     17│   declare module.exports: {
     18│     (content: any) => any,
     19│     NAMESPACE: string,
     20│   };
     21│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/url-loader_vx.x.x.js:18:16

Unexpected token =>

     15│
     16│ declare module 'url-loader' {
     17│   declare module.exports: {
     18│     (src: any) => any,
     19│     raw: boolean,
     20│   };
     21│ }


Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/webpack-dev-server_vx.x.x.js:18:46

Unexpected token =>

     15│
     16│ declare module 'webpack-dev-server' {
     17│   declare module.exports: {
     18│     (compiler: any, options: any, _log: any) => any,
     19│     addDevServerEntrypoints: (webpackOptions: any, devServerOptions: any, listeningApp: any) => any,
     20│   };
     21│ }

There's a smattering of issues that I can see from glazing over the errors:

  • Stubs generated from JSON files need to have their identifiers quoted (see max-len-2 for an example).
  • It looks like we're trying to generate CommonJS exports from ES6 modules. As a result we're exporting an object with a default that has no key on the object, and this isn't valid syntax. This is seen at the start of most of the erroneous modules listed above.
  • Some of the identifiers are actual keywords so they fail to parse. There's an example of "Unexpected token default". It might mean I'm wrong about the CommonJS/ES6 module mismatch on my item above. Since we're generating these identifiers it might be prudent to just quote everything pessimistically.
@gantoine gantoine self-assigned this Jul 6, 2018
@gantoine gantoine added bug cli Related to CLI tool labels Jul 6, 2018
@gantoine
Copy link
Member

gantoine commented Jul 6, 2018

Ok, I released a version 2.5.1 which disables guessing stub properties, basically reverting to the previous behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cli Related to CLI tool
Projects
None yet
Development

No branches or pull requests

2 participants