Skip to content
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

type definitions for gulp-tslint dont work with typescript #124

Open
damons-sportsbet opened this issue May 23, 2017 · 5 comments
Open

type definitions for gulp-tslint dont work with typescript #124

damons-sportsbet opened this issue May 23, 2017 · 5 comments

Comments

@damons-sportsbet
Copy link

I'm not sure how this is possible, but the built in type definitions for gulp-tslint itself don't work for me when trying to use a typescript gulpfile.

A lot of libraries that export a function that has members on it, like, say, mkdirp, or express, use a method where they define a function and then a namespace with the same name. The function defines the exported function and the namespace defines any members that are also on that function. This process seems to work.

The strategy that gulp-tslint uses is this:
export interface TslintPlugin {
(pluginOptions?: PluginOptions): any;
report: (options?: ReportOptions) => any;
}

which absolutely should work, but doesn't seem to actually work for us, perhaps it's because we are using the node style module loader for typescript?

Anyway, the type definitions from definitelyTyped, that are now available as the npm package @types/gulp-tslint do seem to work for me so I wonder if you can just take those ones and use them?

gulp-tslint version: 8.0.0
tslint version: 5.0.0
Operating system: MacOS

Example gulp configuration (if applicable):

gulpfile.txt

Error console output:
gulpfile.ts (140,10): Cannot invoke an expression whose type lacks a call signature. Type 'typeof "/Users/damons/Work/Sportsbet/hydra/node_modules/gulp-tslint/index"' has no compatible call signatures. (2349)
gulpfile.ts (141,15): Property 'report' does not exist on type 'typeof "/Users/damons/Work/Sportsbet/hydra/node_modules/gulp-tslint/index"'. (2339)

TypeScript example code (if applicable):

@panuhorsmalahti
Copy link
Owner

panuhorsmalahti commented May 23, 2017

I'll release 8.1.0 today, which will contain some changes to the types: #119 - maybe that will help here.

EDIT: published, can you try again?

You could also try import tslint from "gulp-tslint";

@damons-sportsbet
Copy link
Author

Hi Panu, it didn't work for me, TS still can't resolve an interface with a default function definition, even though it should work and TS doesn't complain about the definition at all.
I raised a PR (#128) which fixes it for me, hope you get a chance to review it.

@panuhorsmalahti
Copy link
Owner

What do you mean by node style module loader for typescript? Can you link to a repository which exhibits the problem?

@damons-sportsbet
Copy link
Author

damons-sportsbet commented Jun 13, 2017

Hi again, ok here's an example app that demonstrates the problem:

https://github.com/damon-at-sportsbet/types-test-gulp-tslint

if you check out that project and run npm install and then npm run test you'll see what I mean. The type definitions that you have might work internally when developing the plugin, but they don't work externally when importing it as a module and using it in a typescript gulpfile.

I have had some discussion with people and had it explained to me why this is such a nightmare to do in a nice way. If you want I can try to explain that here too.

@damons-sportsbet
Copy link
Author

Ok for now I guess I'm going to have to fork this project. Shame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants