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
Ability to disable TS8010: 'types' can only be used in a .ts file. #35470
Comments
|
Super confused here. Why is the file extension |
|
I don't think this anywhere ideal; more of an accident of history. I'm very much open to ideas on how to get out of this mess! Offering a flag to disable TS8010 was just the first idea that came to mind. :) A little more context if it's helpful: Considering the above two points, we have ended up with A LOT of TS type annotations in Our goal is to migrate more of the codebase to TypeScript, and I am under the impression that the right way to go about doing this is to add |
|
I'm still unclear why you don't rename |
|
@RyanCavanaugh. In react-native .js file combines javascript and css together, change file name to .ts creates more problems then switch ts8010 syntax checking off. |
|
This could also be a valid use case for me. Indeed, I'm migrating an app from Flow to Typescript. Right now, I'm using Being able to disable this during the migration would really help us. |
|
You can't use ts-node with typescript files in a node module because node 13+ is stupid anal about file extensions. So you rename the file .js and use allowJS = true. The last step is ignoring this particular warning. |
I believe real Captain wouldn't say something like |
|
i use this link and help me fix this issues or this but is some video https://www.facebook.com/watch/?v=2782095745399197&extid=T54ZcHrD4BPCy62c |
|
This issue is so annoying. We even have |
|
I'm seeing this issue and it's making things super tough to migrate from Flow to TS. |
|
I am in a similar boat with Flow => TS migration. The ideal configuration during the migration is |
|
@alexkrolick same scenario, you say you can compile the code using Webpack, how do you do so? Because Edit: found out a way, using instead only Babel typeScript preset + an override to differentiate the build of .ts and .js, does the job so far. |
|
@eric-burel we got Webpack working the same way, via the Typescript plugin and a regex override for .ts/.tsx files |
|
will be nice make this even more powerful and allow us define an array of errors that we want to omit. |
|
Hi everyone! I ran in the same problem, currently migrating project from flow to TS. Have anyone found solution for that issue? |
|
I found workaround for that issue, definitely not ideal. |


brandonpearcy commentedDec 3, 2019
Search Terms
TS8010
TS 8010
types can only be used in a .ts file
'types' can only be used in a .ts file
Suggestion
Ability to disable TS8010: 'types' can only be used in a .ts file. Type annotations could simply be ignore by
tscwhen compiling a.jsfile.Use Cases
I work in a JS / TS blended codebase. My team uses WebStorm as our IDE, and it supports type annotations in .js files. When a variable/param is typed, it provides type-specific autocompletion. As you can imagine, that's quite powerful when working in a JS environment. Consequently, we have thousands of type annotations throughout our JS files. We would like to add
allowJs:trueto ourtsconfig.json, howevertscthrows an error for every type annotation in each JS file.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: