kotas / gulp-tsc Goto Github PK
View Code? Open in Web Editor NEWgulp.js plugin for compiling TypeScript files
gulp.js plugin for compiling TypeScript files
I've encountered the following issue with gulp-tsc:
Has anyone encountered that? Is there a solution?
The TypeScript compiler can take in all command line arguments via a temporary file, as described here:
http://stackoverflow.com/questions/12699781/how-can-i-pass-multiple-source-files-to-the-typescript-compiler
We encountered this error months and months ago prior to using gulp, when Microsoft was forced to do the same thing (pass all the source file names and arguments in via file). Could you make this change to
/lib/compiler.js to support this argument file? I will be working on a pull request myself
The plugin appears to throw an error when compiling a .d.ts file because there is no .js file output. It appears to be trying to open the file, but it does not exist.
I think it's common to put a single .d.ts file in the root of the application and reference it from the rest of the project.
It will be useful to support specifying tsc command line arguments directly, as simple string.
TSC is growing up, 1.4.1 is on air, and some new keys added - --suppressImplicitAnyIndexErrors --preserveConstEnums, etc...
In fact, we can tract each property of options object as tsc argument, and pass it directly (if option name is unknown), with conversion of boolean values, whereas string values passed as they are.
Hi there,
I'm getting an error when I use your plugin in Windows 8. In Linux works fine though.
[gulp] Failed to compile TypeScript: Error: Command failed: The filename, directory name, or volume label syntax is incorrect
I am using gulp-tsc to compile TypeScript files in an Angular 2 application. According to Angular's doc the files must be generated with the following line:
tsc --watch -m commonjs -t es5 --emitDecoratorMetadata file.ts
My gulpfile.js file is as follows:
gulp.task('compile-ts', function(){
return gulp.src(['resources/angular/**/*.ts'])
.pipe(typescript({target : "ES5", module : "commonjs" }))
.pipe(gulp.dest('./public/angular/'))
.pipe(plugins.livereload());
});
It supports specifying ES5 and commonjs but there's no way to add the flag --emitDecoratorMetadata
I just re-installed gulp-tsc and it brought typescript 1.1.0-1 with it - the newest beta version of the typescript compiler, which is still buggy and doesn't compile my code. Perhaps it is wise to adjust package.json so that only typescript 1.0.x versions will get installed?
Hello,
I'm trying gulp-tsc and it seems when you're watching, it restarts the compiler every time a file changes (and it takes about 2-3s on my machine).
Is it possible to have an option to start the compiler with the -w option as it should be much faster.
I'll have a look at the code later this week but let me know what you think of it
Is there any tool available
like https://github.com/TypeStrong/grunt-ts
to support transformations like automatically adding a global <// ../../../reference.d.ts
to all .ts files
Is it something for gulp-tsc? visual studio has this build in, so it would make probably sense to have it within the compiler project.
I have the following in my gulpfile.js:
gulp.task("typescript", function() {
return gulp.src([
"/**/*.ts",
], {base: "."})
.pipe(gulpFilter("!**/*.d.ts"))
.pipe(typescript({
module: "commonjs",
declaration: true,
target: "es5",
}))
.pipe(gulp.dest("."))
});
This generates all .js and .js.map files correctly and the .d.ts files look fine too, except that any reference to a .d.ts file (e.g. /// <reference path="../typings/lib.d.ts"/>
) will get mangled to one level too far back and becomes
/// <reference path="../../typings/lib.d.ts"/>
, which is of course wrong, because the .d.ts files are written in the same directory as the .ts source files.
I did a bit of debugging here, and I think that the reason for this behavior is because the files are first generated to a temporary directory (gulp-tsc-tmp-*) and then copied back to their eventual destination. Because I used gulp.dest(".")
I assumed that these references would stay intact, but apparently they do not.
The Readme states that the default value for options.target
is ES5, but when I run gulp, the argument passed to tsc
is in fact --target ES3
.
If I specify ES5 explicitly, this is passed correctly to tsc.
Hello.
I am having strange error when trying to compile any .ts via gulp-tsc (tried both 0.0.2 and 0.0.3)
Here is the output:
[gulp] Failed to compile TypeScript: Error: Command failed:
module.js:340
throw err;
^
Error: Cannot find module '...\Documents\frontend\tool\'C:\Program'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Seems like the module path is screwed.
However, in Ubuntu it works.
Any idea for workaround?
Thanks.
please support vinyl-sourcemaps-apply. https://github.com/floridoo/vinyl-sourcemaps-apply
and I do not want to emit .js.map
file to downstream.
This request makes Multistage SourceMap support easier
https://github.com/floridoo/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support
[11:11:30] [tsc] > <Buffer 6d 65 73 73 61 67 65 20 54 53 36 30 38 31 3a 20 41 72 67 75 6d 65 6e 74 20 66 6f 72 20 27 2d 2d 6a 73 78 27 20 6d 75 73 74 20 62 65 20 27 70 72 65 73 ... >
It looks like the lib "byline" is causing the issue but I'm not quite sure.
Changing lines 227 to 235 in compiler.js "fixes" the issue.
proc.on('error', function (err) {
_this.emit('error', err);
});
stdout.on('data', function (chunk) {
_this.emit('stdout', chunk.toString('utf8'));
});
stderr.on('data', function (chunk) {
_this.emit('stderr', chunk.toString('utf8'));
});
Node version is v6.2.2, gulp-tsc is 1.1.5 and tsc is 1.8.10.
I use gulp-tsc with watch task.
If i have an error in my ts files and hit save, an unhandled error is thrown and gulp exits.
I believe this error should be caught so that i can fix my code without restarting gulp
In my project I have multiple typescript file groups that need to be compiled separately (a library, and it's unit tests). I have tried adding them both to the same task, and separate tasks. They compile successfully, but the 2nd task leaves behind a temp folder in the project root containing the output file from the 2nd compilation.
gulp-tsc uses a 'shellescape' function that processes the arguments passed to tsc. This function replaces backslashes by double backslashes. This results in invalid paths on Windows. Some Windows versions don't care (e.g. Windows 7) but others do (e.g. Windows 8, Windows Server 2008). I have several computers where gulp-tsc does not work for this reason.
Would it be possible to disable backslash escaping on Windows?
Hi, using
tsc( {allowBool : true})
it will still say angular.d.ts(32,43): Cannot find name 'bool'.
besides, the gulp-tsc docu is wrong, it "Bool" is uppercase and should be enabled by default
Reported by @bestander in #18 (comment)
Hi, thanks for the best gulp tsc task.
I think this pull request broke my build and I reverted to version 0.5.0.
This is my setup:
gulp.task('compile-typescript', function() {
return gulp.src(['app/**/*.ts'])
.pipe(cache('typescript'))
.pipe(typescript(typescriptOptions))
.pipe(gulp.dest(webOutputPath + '/app'));
});
gulp.task('dev', function(callback) {
runSequence('clean-web-output',
['compile-typescript', 'compile-sass' ],//, 'run-tests'],
function() {
gulp.watch(['app/**/*.ts'], ['compile-typescript']);
});
});
If I change one TS file I expect 1 or more JS files to be compiled into my .tmp folder.
For example if I change:
/app/online-reader/popup-reader-directive.ts
Then compiler produces this list:
<tmp>/online-reader/popup-reader-directive.js
<tmp>/online-reader/reader-preferences-service.js
<tmp>/analytics/http-latency-sampler.js
The change in this ticket changes it to:
<tmp>/online-reader/online-reader/popup-reader-directive.js
<tmp>/online-reader/online-reader/reader-preferences-service.js
<tmp>/online-reader/analytics/http-latency-sampler.js
Which os wrong.
I am happy to debug or provide more test data.
While compiling typescript using gulp-tsc , I seem to encounter a strange issue. The file references on the d.ts seems to be messed up.
Source :
///<reference path='typings/lodash/lodash.d.ts'/>
///<reference path='typings/angularjs/angular.d.ts'/>
Gulp
return gulp.src('src/gravy/gravy.ts')
.pipe(tsc({sourcemap: true,declaration:true,logErrors: true, out:'gravy.js',outDir:'src/gravy'}))
.pipe(gulp.dest('src/gravy'));
Generated d.ts file.
/// <reference path="typings/lodash/lodash.d.ts" />
/// <reference path="../src//gravy/typings/angularjs/angular.d.ts" />
See the generated file , the references are messed up. Its strange that the first line is good , the second line always seems to be messed. I reversed the order on the source to see same symptom.
The generated mapping file out of equivalent typescript CLI is good. Any ideas ?
Thanks
Santhosh
The feature where gulp-tsc will use the typescript compiler in node_modules is helpful in the case that different projects are using different versions of typescript (I'm in this situation).
In my case, it would also be helpful if instead of just searching for typescript in the ./node_modules it would also search in ../node_modules, ../../node_modules, etc.
What do you think?
Thanks,
Chris
Hi,
This file was generated from some ts files using gulp-tsc 0.9.2 with out option.
https://github.com/nakamura-to/join/blob/v0.0.0/dist/join.js
Original ts files are here.
https://github.com/nakamura-to/join/tree/v0.0.0/src
gulpfiles.js is here.
https://github.com/nakamura-to/join/blob/v0.0.0/gulpfile.js
It seems that the order of code blocks is sorted by ts file name (alphabetical order).
But should it be sorted by reference path order ?
With the newest (beta) compiler, I see this message on every compilation:
Compiling TypeScript files using tsc version null
Sounds like they might have changed that API? Not sure what the deal is.
I upgraded to 0.5.0 from 0.0.4, and I don't see any .js files after doing a build.
Here is my gulp task:
gulp.task('typescript', ['clean'], function() {
var typescript = require('gulp-tsc');
return gulp.src(['./**/*.ts', '!./node_modules/**'], { read: false })
.pipe(typescript({ noImplicitAny: true, target: 'ES5', module: 'COMMONJS', sourcemap: true }))
.pipe(gulp.dest('.'));
});
gulp.task('build', ['clean', 'typescript'], function(){
});
Here is a screencast which attempts to demonstrate that I am not crazy:
I have two typescript projects (app and util). The app project references files in the util project.
I set up my gulp-tsc with sources from the app project, but during compilation, the typescript compiler also compiles files in the util project. This is mostly ok, but because the util files don't get added to the gulp output files, there's a couple caveats:
I'm not even sure there's anything worthwhile to do about this, but just thought I'd bring it up to see if you had any ideas.
Thanks,
Chris
Hello!
I successfully compiled my .ts script using command line:
tsc source/ts/docmaster/document/Explorer.class.ts --module commonjs --target ES5 --out source/ts/d.ts/docmaster/docmaster.js --declaration --noEmitOnError --removeComments
In compiled .d.ts file I see correctly used references.
/// <reference path="../DefinitelyTyped/jstorage/jstorage.d.ts" />
/// <reference path="../jquery/a2j.d.ts" />
/// <reference path="../DefinitelyTyped/q/Q.d.ts" />
I need to reproduce compiling in gulp script
gulp.task('test', function (callback) {
gulp.src([
'source/ts/docmaster/document/Explorer.class.ts'
])
.pipe(tsc({
module: 'commonjs',
target: 'ES5',
out: 'source/ts/d.ts/docmaster/docmaster.js',
declaration: true,
noEmitOnError: true,
removeComments: true
}))
.pipe(gulp.dest(''))
.pipe(notify('docmaster.js compiled'));
});
But in compiled d.ts my references are different:
/// <reference path="../../../../../source/ts/d.ts/DefinitelyTyped/jstorage/jstorage.d.ts" />
/// <reference path="../../../../../source/ts/d.ts/jquery/a2j.d.ts" />
/// <reference path="../../../../../source/ts/d.ts/DefinitelyTyped/q/Q.d.ts" />
Why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.