vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

[Bug Report] ERROR TS18002: The 'files' list in config file 'tsconfig.json' is empty #38

Closed salazarr-js closed 4 years ago

salazarr-js commented 4 years ago

Environment

Describe the bug

After installing the plugin vuepress-plugin-typescript as the docs specify, I got [tsl] ERROR TS18002: The 'files' list in config file 'tsconfig.json' is empty.

Steps To Reproduce

  1. Install
    npm install -D vuepress-plugin-typescript typescript
  2. Add plugin to .vuepress/config.js
    module.exports = {
    ...
    plugins: [
    [ 'vuepress-plugin-typescript'],
    ...
    ],
    ...
    }
  3. Edit a component
    
    <template>...</template>
    <script lang="ts">
    import Vue from 'vue'

export default Vue.extend({ data: () => ({ msg: 'Hello, TypeScript in Markdown!', }) });

...
4. Run `dev`
```sh
vuepress dev notes

In my case, .vuepress is inside notes folder

Screenshots

tsl ERROR TS18002

Expected behavior

We can expect following the steps in the docs everything works fine out of the box.

Additional context

If I add an empty enhanceApp.ts in .vuepress folder everything works fine, but I don't use it.

meteorlxy commented 4 years ago

What's the content of your tsconfig.json?

Could you please provide a reproduce repo?

salazarr-js commented 4 years ago

@meteorlxy in this repo I specify every step I did to get the error message, maybe is not a bug, I don't know if this behavior is by design, but just following the docs I got the error. The tsconfig.json and any .ts files are required to the plugin to function properly

meteorlxy commented 4 years ago

Uh, didn't try a minimal repo with this plugin, so didn't notice this behavior.

I could not figure the root cause immediately.

I guess:

Notice that, the files or include here has no effects. It might be ONLY part of the check.

For example, you can set files to anything exists:

{
  "files": ["screenshot.png"]
}

Although this file has nothing to do with typescript, it will pass the check of the "parser", and everything works well.

BTW, seems that the include property does not respect non-ts files, e.g. **/*.md šŸ¤”

salazarr-js commented 4 years ago

nice, what I can do? add a little clarification to the documentation?

meteorlxy commented 4 years ago

@salazarr-js It would be nice if you can help šŸ˜„

Mister-Hope commented 4 years ago

Uh, didn't try a minimal repo with this plugin, so didn't notice this behavior.

I could not figure the root cause immediately.

I guess:

  • ts-loader requires typescript compiler
  • typescript compiler will use a "parser" to parse the tsconfig.json
  • If nothing match the files or include in tsconfig.json, the "parser" will throw an error like this

Notice that, the files or include here has no effects. It might be ONLY part of the check.

For example, you can set files to anything exists:

{
  "files": ["screenshot.png"]
}

Although this file has nothing to do with typescript, it will pass the check of the "parser", and everything works well.

BTW, seems that the include property does not respect non-ts files, e.g. **/*.md šŸ¤”

That 's correct, we must have something in files or include

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.