-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Enable the .js and .es file extensions for TypeScript files #2302
Comments
This would probably mean GitHub wouldn't be able to detect whether a repository is using javascript or typescript |
What sort of processing are you suggestion for |
@NoelAbrahams Treating them as TypeScript-files and selectively enabling certain features. |
@RobertSundstrom If you would like them to be treated as TypeScript files, why not rename them to .ts? |
I actually ran into a use-case today for wanting to compile a We have We want to include I tried setting
For the use-case above we cannot simply change the extension to |
@NoelAbrahams this is slightly different from the original proposal from @RobertSundstrom , you want the compiler to read in .js files, write them to the output, but do not report any errors in them. is this accurate? |
@mhegazy, I would see it as an enhancement to the original request. The following would happen:
|
What about other semantic errors, e.g.: var x = 2;
if (false) {
x = "string":
} or var x = 1;
var x = ""; should these be reported for moment.js? |
I think for most users the processing of We need to include If people want the compiler to catch semantic errors then they should be writing TypeScript. I think for |
👍 I would also like to typecheck javascript files. My use case is to use the typescript type checker but still author ES5 code that does not need to be compiled for someone to use it. |
+1 Being able to compile files with a .js extension using |
@ianfp it sounds like a totally different problem/subject in that you are looking for a JavaScript -> TypeScript migrator that helps you easily get on the right path of converting a code base from JavaScript to TypeScript. Sounds like an interesting project... |
I'd like to run TS as an extra to ESLint (sometimes) but also be able to benefit from some of the advanced type stuff you guys have available autocompletion in VIM. |
@forbesmyester what do you mean by "as an extra to ESLint (sometimes)"? FYI https://github.com/palantir/tslint exists |
@adidahiya did not know about tslint, does it give the same results of mistakes that TypeScript itself seems to? In which case that part of the desire is no longer relevant, would still like to use it for the VIM omni completion / hints as they are really good. Requiring a .ts extension is annoying as it means that you need buy in from a whole team as apposed to just a single developer using it for some of the smaller (editor / linting) enhancements. |
Sorry for being late to the conversation but I'm currently working on a project where it would be nice to have the original requested feature. Our project code base contains a mix of open source derivative code written in js (es5), es6 and TypeScript. It would be nice if TypeScript could be used to transpile es6 as well, rather than resorting to another transpiler such as babel to process the es6 source. |
I am in the same situation and in fact waiting for this feature to move to VSC! |
I have the same needs as ldminoc and robertsundstrum. |
@anievagomez can you elaborate? do you have other es6 assets that you want the TS compiler to transpile, or just es5 sources that you do not want to migrate but still want to code against? |
@mhegazy, it seems intuitive to me that any serious 'ambitious' application or enhancement to existing long-lived projects (incrementally transitioning to newer technology) would need both capabilities when considering adopting TypeScript, or face a massive uplifting exercise. |
@ldminoc i am interested in building an intuition of what a .js file "mean" in a typescript context. is it a reference (e.g. library, sources from that you do not intend to migrate to ts) that you would code against, or a source (i.e. an ES6 JS file that you want transpiled and bundled with your other .ts file outputs). |
A .ts file can just mean a JavaScript file with some ES6 features and At the moment I'm not sure TypeScript is the right choice for a project, Matt On Thu, 1 Oct 2015 20:50 Mohamed Hegazy [email protected] wrote:
|
You are right... find . -name "*.js" -exec bash -c 'mv "$1" "$(sed "s/\.js$/.ts/" <<< "$1")"' - '{}' \; is too much to ask... The whole project is doomed. |
I can write simple Bash too, that's not the issue. Not all projects are single person project and some people really hate It'd be nice if I could use TypeScript without anyone else being effective, Matt On Fri, 2 Oct 2015 09:33 Kitson Kelly [email protected] wrote:
|
What is the issue then? The assertion was "forcing me to change all my extensions is too big an ask at this point"... Why? |
Not all projects are single person project and some people really hate Matt On Fri, 2 Oct 2015 11:13 Kitson Kelly [email protected] wrote:
|
@forbesmyester what you are looking for is #4793 then, correct? you want the TS developer experience (completion, highlighting, etc..) in an ES6 source file, without committing to using types, TS-specific-syntax, etc.. is this accurate? |
@mhegazy, it would be yes to both:
Both are bundled but that will be the responsibility of a third-party tool such as webpack, hth. |
consuming .js and .jsx is now allowed using --allowJS (see https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#including-js-files-with---allowjs) |
Enable the .js, .jsx, .es and .es6 file extensions for TS compiler file inputs and module imports. This is already supported by other transpilers, such as babel.
The feature would ideally be added as an option in the compiler. With .js together with .ts on by default, but .ts still being prefered.
This would cause the files with the enabled extensions to, just as .ts-files today, be processed (e.g. in and IDE), and transformed if the options so allow it.
One objection to this would be that this could potentially confuse scripts that are using TypeScript-specific features with scripts using official ES6 features. I don't personaly see this as an issue. It is up to the developers to come up with conventions in their own projects.
The text was updated successfully, but these errors were encountered: