microsoft / microsoft/TypeScript
Ability to disable TS8010: 'types' can only be used in a .ts file.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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 tsc when compiling a .js file.
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:true to our tsconfig.json, however tsc throws an error for every type annotation in each JS file.
Checklist
My suggestion meets these guidelines:
- [ x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [ x ] This wouldn't change the runtime behavior of existing JavaScript code
- [ x ] This could be implemented without emitting different JS based on the types of the expressions
- [ x ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- [ x ] This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TS8010 diagnostic and the allowJs option in tsconfig.json, then trace how tsc reports type annotations in .js files. Done means a configuration can disable this diagnostic without changing emitted JavaScript behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100