TypeStrong / fork-ts-checker-webpack-plugin

Webpack plugin that runs typescript type checker on a separate process.
MIT License
1.95k stars 240 forks source link

TS error in file can no longer be opened at the error location (v4 -> v5) #509

Closed lerit closed 3 years ago

lerit commented 4 years ago

Current behavior

i use vscode ,it work fine with v4,when error in console,i can opened the file,but not work after upgrade to v5. for some research,the file location lose 'server' prefix. this line cause the issue: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/master/src/formatter/WebpackFormatter.ts#L16 this is my folder structure:

root
- client
- server
 -index.ts
- tsconfig.json

the webpack config context is 'server'

Current behavior

ERROR in services/patrol/problem.ts:799:5
TS2552: Cannot find name 'GetProblemTypeList'. Did you mean 'GetProblemTypeList1'?
    797 |     }),
    798 |     GetOrganizationListByUserID(auth, userID),
    799 |     GetProblemTypeList(),
           |     ^^^^^^^^^^^^^^^^^^
    800 |     GetTeamsByUserID(userID)
    801 |   ])

Expected behavior

ERROR in server/services/patrol/problem.ts:799:5
TS2552: Cannot find name 'GetProblemTypeList'. Did you mean 'GetProblemTypeList1'?
    797 |     }),
    798 |     GetOrganizationListByUserID(auth, userID),
    799 |     GetProblemTypeList(),
           |     ^^^^^^^^^^^^^^^^^^
    800 |     GetTeamsByUserID(userID)
    801 |   ])

Environment

piotr-oles commented 4 years ago

It follows webpack's semantics so if you would have errors that are produced by other webpack's plugins, they should look the same. Therefore, I don't think we should change the behavior of the plugin. I would suggest changing the context :)

lerit commented 4 years ago

@piotr-oles in fact, eslint plugin output correct: this is my webpack setting:

    new ESLintPlugin({
      files: ['**/*.js'],
      formatter: 'codeframe'
    }),
    new ForkTsCheckerWebpackPlugin({
      formatter: { type: 'codeframe', options: { highlightCode: true } },
      typescript: {
        enabled: true,
        configFile: path.resolve(config.context, 'tsconfig.server.json')
      },
      eslint: {
        enabled: true,
        files: ['**/*.js'],
        options: {
        }
      }
    })

and output: image

i can open eslint file,because it prefix with server

lerit commented 4 years ago

after some research,the reason why eslintplugin work fine: 1.eslintplugin use eslint 2.eslint format base on process.cwd https://github.com/eslint/eslint/blob/022257a71b7579cf88cf3b8b936a696e8d2a09ed/lib/cli-engine/formatters/codeframe.js#L33

piotr-oles commented 4 years ago

Ok, if it improves developer experience, I think it makes sense to change to process.cwd. Would you like to create a PR?

piotr-oles commented 3 years ago

Will be released in few minutes :)

piotr-oles commented 3 years ago

:tada: This issue has been resolved in version 6.0.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: