1

I've installed some third party library for React: react-draft-wysiwyg

While exploring the source code, i was surprised to see that my Visual Studio Code IDE gives me alot of syntax errors, within the JS files. For example, this function:

onEditorBlur: Function = (): void => {
this.setState({
  editorFocused: false
});
};

My editor tells me that "types can only be used in a TS file".

The package.json "main" filed points to an already bundled file, but when i try to switch it to the src folder, i get various errors, like "you need a special loader..."

Is there some way to use typescript within JS?

3
  • 1
    This is not valid TypeScript syntax afaik. Possibly Flow? Commented May 13, 2018 at 4:36
  • Ah yes, i see in the package.json various things related to Flow, including a special Babel plugin Commented May 13, 2018 at 4:43
  • Solutions to your problem may be available by telling vscode to treat .J's files as another type Commented May 13, 2018 at 5:41

1 Answer 1

1

Is there some way to use typescript within JS?

No. But you can (and this project does) use flow: https://flow.org/

To use Flow with VSCode : https://github.com/flowtype/flow-for-vscode

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.