Skip to content

Switching to Typescript #157

@silkentrance

Description

@silkentrance
Collaborator

@raszi while Typescript may be a valid candidate for node-tmp, it is not a candidate for refactoring the existing sources.

RATIONALE

  • packaging and build process is far more complicated
  • dev dependencies increase a manifold
  • and believe you me 😬

Activity

changed the title [-]Swjt[/-] [+]Discussion: Switching to Typescript[/+] on Nov 27, 2017
silkentrance

silkentrance commented on Nov 27, 2017

@silkentrance
CollaboratorAuthor

my humble proposal would be to provide typescript typings, e.g . *.d.ts, for the general Typescript community, e.g. /tmp/index.d.ts instead of moving everything to typescript.

raszi

raszi commented on Nov 28, 2017

@raszi
Owner

That is an option of course, but switching to TypeScript would solve other problems too. When I was doing the switch I've found a couple of issues which were reported later.

So it has other benefits too.

silkentrance

silkentrance commented on Nov 28, 2017

@silkentrance
CollaboratorAuthor

@raszi I am open to that change. I am currently learning typescript and also have a setup here for gulp (also using typescript here) and mocha test cases implemented in typescript and so on...

silkentrance

silkentrance commented on Nov 28, 2017

@silkentrance
CollaboratorAuthor

@raszi Please have a look at the branch https://github.com/raszi/node-tmp/tree/gulp-ts. Here you can find the dependencies and scripts that I use for my typescript based projects including gulp for the build process, working coverage reports and mocha based tests.

This still needs more work and must be further customised for node-tmp.

jmendiara

jmendiara commented on Dec 1, 2017

@jmendiara

My2cents: From my own experience, making manual .d.ts files is a hard task, error prone and adds more (hard!) maintenance. For small codebases, once you decide you want to go ts is better making a full port.

Also, a gulp/grunt/* based workflow adds lots of boilerplate and devDependencies code that can be done simply using npm scripts
Did you hear about https://github.com/TypeStrong/ts-node ?

silkentrance

silkentrance commented on Dec 1, 2017

@silkentrance
CollaboratorAuthor

@jmendiara I hear you. However, I think I have reduced the required dependencies to a minimum. In addition, the gulp tasks themselves are simple and maintainable and once realised, would not need any further maintenance work unless, of course, gulp finally manages to get 4.x out.

  "scripts": {
    "doc": "jsdoc -c .jsdoc.json",
    "clean": "gulp clean",
    "dist": "npm run clean lint test build coverage && gulp dist",
    "deploy": "npm run clean lint test build coverage dist && gulp deploy",
    "test": "gulp test",
    "coverage": "gulp clean:build && gulp build && gulp clean:coverage && gulp coverage",
    "lint": "gulp lint",
    "bump": "gulp bump",
    "bump:major": "gulp bump:major",
    "bump:minor": "gulp bump:minor",
    "bump:patch": "gulp bump:patch",
    "bump:prerelease": "gulp bump:prerelease"
  },
  "devDependencies": {
    "@types/chai": "^4.0.5",
    "@types/mocha": "^2.2.44",
    "@types/node": "^8.0.53",
    "chai": "^4.1.2",
    "del": "^3.0.0",
    "gulp": "^3.9.1",
    "gulp-bump": "^2.8.0",
    "gulp-debug": "^3.1.0",
    "gulp-istanbul": "^1.1.2",
    "gulp-json-editor": "^2.2.1",
    "gulp-mocha": "^4.3.1",
    "gulp-sourcemaps": "^2.6.1",
    "gulp-tslint": "^8.1.2",
    "gulp-typescript": "^3.2.3",
    "gulp-watch": "^4.3.11",
    "istanbul": "^0.4.5",
    "mocha": "^4.0.1",
    "mocha-lcov-reporter": "^1.3.0",
    "mocha-typescript": "^1.1.12",
    "remap-istanbul": "^0.9.5",
    "ts-node": "^3.3.0",
    "tslint": "^5.8.0",
    "typescript": "^2.6.1"
  }

Of course, the above dependencies have a lot of other dev dependencies, but I myself can live with that. (maven/npm downloading the internet again, have a beer 🥂 ).
And with the latest updates to npm, the download of these dependencies is no longer a PITA as it had been.

changed the title [-]Discussion: Switching to Typescript[/-] [+]Switching to Typescript[/+] on Dec 2, 2017
silkentrance

silkentrance commented on Apr 30, 2018

@silkentrance
CollaboratorAuthor

@raszi from what I have learned, we have to provide a complete set of typings for the tmp api, regardless of whether the code base is pure javascript or transpiled typescript. Either way, the provisioning of the typings and leaving the source as is would seem to be the best choice for an initial migration towards typescript.

silkentrance

silkentrance commented on Mar 20, 2019

@silkentrance
CollaboratorAuthor

Now that I have gained confidence in TypeScript and I see that others already have provided typings for node-tmp under the hood of the DefinitelyTyped project on github, I am also open to switch to TypeScript as a whole. However, we still need to provide the typings since we will transpile to standard JS and publish the package as such.

And while we do not have to switch to TypeScript at all, we might want to provide these type declarations as part of the node-tmp package.

Yet, and since the package will not change any more unless we come up with some clever scheme of how doing things differently, I also see no urgent need in doing so.

@raszi Your call.

raszi

raszi commented on Mar 20, 2019

@raszi
Owner

I believe it would be better to switch to TypeScript all together. The last time I've checked the provided type definitions those were not easy to use and were not entirely correct.

silkentrance

silkentrance commented on Mar 20, 2019

@silkentrance
CollaboratorAuthor

Ok, well then it is TypeScript. Will you make the necessary changes?

silkentrance

silkentrance commented on Mar 20, 2019

@silkentrance
CollaboratorAuthor

I think that we need to move lib/tmp.js to src/tmp.ts and distribute it via dist/tmp.js. The typings should then reside in a dist/tmp.d.ts, copied over from typings/tmp.d.ts or something like that.

What do you think or do you already have a plan for making this work?

18 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @raszi@jmendiara@paulmelnikow@silkentrance@ehmicky

      Issue actions

        Switching to Typescript · Issue #157 · raszi/node-tmp