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

experimentalDecorators: true in tsconfig.json is not working #567

Closed
3 tasks done
JounQin opened this issue Dec 2, 2017 · 19 comments
Closed
3 tasks done

experimentalDecorators: true in tsconfig.json is not working #567

JounQin opened this issue Dec 2, 2017 · 19 comments

Comments

@JounQin
Copy link

JounQin commented Dec 2, 2017

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.11.3
  • VS Code version: 1.18.1

Problem

message: 'Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.'

I've add and enable experimentalDecorators option in tsconfig.json, and I tried decorator in pure .ts file, there was no warnings.

Reproducible Case

My source code:

<template lang="pug">
  #app
    router-view
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

@Component
export default class App extends Vue {
  name = 'app'
}
</script>
@HerringtonDarkholme
Copy link
Member

I cannot reproduce this, can you provide a repo?

@JounQin
Copy link
Author

JounQin commented Dec 3, 2017

If you don't mind, you can checkout https://github.com/JounQin/Rubick/blob/master/src/views/landing/Login.vue for more details.

@HerringtonDarkholme
Copy link
Member

I cloned the repo and it works fine. You can try reloading editor.

screen shot 2017-12-04 at 10 04 41 am

@JounQin
Copy link
Author

JounQin commented Dec 4, 2017

@HerringtonDarkholme Oops, it really works today, but custom options for Vue plugin still does not work.

jietu20171204-102453 2x

There declarations are all in src/types/shim.d.ts, which makes them work in pure .ts file and can passthrough webpack's building step.

@HerringtonDarkholme
Copy link
Member

@JounQin I still cannot reproduce. Clicking on $v directs me to shim.d.ts.

@JounQin
Copy link
Author

JounQin commented Dec 4, 2017

Hmmm... I restarted my Mac and it works just well now, so magically.

@JounQin JounQin closed this as completed Dec 4, 2017
@JounQin
Copy link
Author

JounQin commented Dec 6, 2017

@HerringtonDarkholme It seems if I modify global .d.ts file, vetur will not recognize that unless exiting and restarting vsc.

So is it as expected and should be documented?

@TheAkio
Copy link

TheAkio commented Feb 6, 2018

I'm not sure if this is an issue of the language server or the VSCode plugin, but it doesn't work when you have a Workspace open. There is a workaround tho: Simply add a tsconfig.json to the workspace directory with the proper configuration. Then this will fix the issue in workspaces.

@aboutqx
Copy link

aboutqx commented May 23, 2018

Still not working in a vue file with tsconfig "experimentalDecorators": true, "allowJs": true,
and vscode config "javascript.implicitProjectConfig.experimentalDecorators": true ,even with restart.

@TheAkio
Copy link

TheAkio commented May 23, 2018

The issue is tracked here: #424

@yang-ml
Copy link

yang-ml commented May 2, 2019

Actually, I'm still confused with the cause of this issue, but set "include" path in tsconfig.json is working for me.

Before:

"include": [
    // "src/**/*.ts"
  ]

image

Worked After:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "node",
    "target": "es5",
    "lib": ["dom", "es2015", "es2016"],
    "sourceMap": false,
    "declaration": true,
    "experimentalDecorators": true,
    "jsx": "react",
    "outDir": "lib",
    "noUnusedLocals": false 
  },
  "exclude": [
    "node_modules",
    "static",
    "lib"
  ],
  "include": [
    "src/**/*.ts"
  ]
}

I'm happy if somebody can point out my mistakes in the config file.

@octref
Copy link
Member

octref commented May 2, 2019

include tells Vetur to load the specified files with the compilerOptions you have given. Not specifying it falls back to using the default compilerOptions which doesn't set experimentalDecorators.

@flatcoke
Copy link

flatcoke commented May 4, 2019

It was not resolved by any of the above solutions, but it was fixed by updating vscode to the latest version.

@vguleaev
Copy link

vguleaev commented Aug 8, 2019

It was not resolved by any of the above solutions, but it was fixed by updating vscode to the latest version.

I have latest version but I still can see the error when I do
export default @observer class MyPageName

@Pablofr10
Copy link

I just put "experimentalDecorators": true in tsconfig.json

@yoyo930021
Copy link
Member

I just put "experimentalDecorators": true in tsconfig.json

If you set, please restart VSCode.
Still have problems, please open a new issue with template.

@Pablofr10
Copy link

I just put "experimentalDecorators": true in tsconfig.json

If you set, please restart VSCode.
Still have problems, please open a new issue with template.

It's solved my problem. 🤗🤗

@anilanar
Copy link

anilanar commented Sep 2, 2021

For majority of you, it's caused by

include: "src/**/*.ts"

It needs to be without .ts extension.

include: "src/**/*"

@edilsonalvarado
Copy link

Actually, I'm still confused with the cause of this issue, but set "include" path in tsconfig.json is working for me.

Before:

"include": [
    // "src/**/*.ts"
  ]

image

Worked After:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "node",
    "target": "es5",
    "lib": ["dom", "es2015", "es2016"],
    "sourceMap": false,
    "declaration": true,
    "experimentalDecorators": true,
    "jsx": "react",
    "outDir": "lib",
    "noUnusedLocals": false 
  },
  "exclude": [
    "node_modules",
    "static",
    "lib"
  ],
  "include": [
    "src/**/*.ts"
  ]
}

I'm happy if somebody can point out my mistakes in the config file.

It worked.
It's strange because I was working and suddenly error appeared.
Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests