Steps to Reproduce:
Create a .js file and add the following code in it(the file will be processed by Flowtype):
// @flow
type LogActionsType = { type: 'NEW_LOG', payload: Array<Object> } | { type: 'LOGS_PUSHED', payload: null };
export type LogType = Object
Whenever I define a type alias the error 'Type aliases can be used only in a .ts file' keeps showing up and is highlighed in the 'Problems' panel.
Is there any way to disable typescript ? Or prevent this kind of validation of running ?
Got the same issue:
// @Flow annotation at top of file.
and javascript.validate.enable": false in my Workspace settings.
Error highlighted:
[js] 'types' can only be used in a .ts file.
[Flow]
string: (object: Object) => Array<string>
Confirmed on latest bits. Moving to TS Server repo.
This issue was moved to Microsoft/TypeScript#12186
Reopening here. The suggestion from TS team recommends this be handled on VS Code's side.
The recommendation is for VS Code to check to see the Flow annotation and not pass it on to the TS Server.
@dbaeumer this looks like something we should look into soon as it can be a poor experience for flow users.
@waderyan this should not go into the TS extension. We shouldn't parse the first line. There are two ways to deal with this:
javascript.validate.enable": falseI tested that if I set javascript.validate.enable": false that the error is not shown.

@waderyan recommend to close.
I still got this error with Flow 0.40 using VSCode 1.10.2.
// .vscode/settings.json
{
"javascript.validate.enable": false,
...
}
Sorry, after restarting VSCode, this error was gone.
I still got this error with Flow 0.40 using VSCode 1.10.2.
I still got this issue with VSCode 1.13.1.
After restarting VSCode, the issue is going away. But it's only a matter of time before it comes back. I find myself having to restart VSCode at least once per hour, which is quite annoying.
I've got javascript.validate.enable set to false.
I was able to resolve by doing the following:
javascript.validate.enable to false.flowconfig from my src dir to the workspace rootI am also still getting this error. I have the .flowconfig in my root and set javascript.validate.enable to false. Any troubleshooting steps would be appreciated.


I'm on vscode Version 1.14.2 (1.14.2) and flow ^0.42.0
Maybe this will be helpful for someone, ... what I did (i think) to finally get ts to stop was adding .tsconfig
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "../../built/local/tsc.js",
"sourceMap": true
},
"include": [
],
"exclude": [
"**/*.js"
"node_modules",
]
}
@foobar8675 the problem is still there:

I writed this file: ".tsconfig" in root folder (tried also in just "./src" folder), reloaded VSCode and still the problem.
.tsconfig:
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "../../built/local/tsc.js",
"sourceMap": true
},
"include": [],
"exclude": ["**/*.js", "node_modules"]
}
@johnunclesam sorry, i have no idea what the issue is then.
Most helpful comment
I still got this error with
Flow 0.40usingVSCode 1.10.2.UPDATED
Sorry, after restarting VSCode, this error was gone.