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

Valid ES6 allowJs error TS8014: 'property declarations' can only be used in a .ts file. #7216

Closed
dave-hillier opened this issue Feb 24, 2016 · 6 comments
Labels
Duplicate An existing issue was already created

Comments

@dave-hillier
Copy link

TypeScript Version:

1.8.2

Code

// A self-contained demonstration of the problem follows...
class Repro
{
    static property = {
    foo: "bar"
    };
}

tsc --allowJs --out out.js repro.js

Expected behavior:

Compiles without error

Actual behavior:

repro.js(3,5): error TS8014: 'property declarations' can only be used in a .ts file.
@dave-hillier dave-hillier changed the title allowJs error TS8014: 'property declarations' can only be used in a .ts file. Valid ES6 allowJs error TS8014: 'property declarations' can only be used in a .ts file. Feb 24, 2016
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 24, 2016
@RyanCavanaugh
Copy link
Member

Duplicate of #6997

@RyanCavanaugh
Copy link
Member

Just to confirm, are you also transpiling with Babel's Stage 0 preset?

@dave-hillier
Copy link
Author

I haven't got that far yet. I wanted to try out the allowJs option on an existing code base. I simply ran tsc to reproduce this. I might just switch to using full typescript

@RyanCavanaugh
Copy link
Member

If you don't have an external transpiler in the toolchain, then that error message is definitely correct -- this code doesn't run on any current JS runtime.

@dave-hillier
Copy link
Author

so allowJs doesnt support ES6 in? Is this not fully approved code?

@RyanCavanaugh
Copy link
Member

This isn't ES6 syntax. ES6 does not have property initializers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants