-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
TypeScript Boilerplate #17
Conversation
typescript/package.json
Outdated
"test": "xo && ava" | ||
}, | ||
"main": "dist", | ||
"types": "dist", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer to put non-standard package.json properties at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea here is that it nearly does the same as main
does.
typescript/package.json
Outdated
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"build": "del dist && tsc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should open an issue on TypeScript for tsc
to get a --cleanup
flag or something so we don't need del dist
.
By "we", I'm hoping you can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of reading through a bunch of TypeScript Issues:
They don't like to delete a folder completely (good summary microsoft/TypeScript#13722) but deleting output files when the source files are gone is an ongoing Issue (microsoft/TypeScript#16057).
Sadly this issue is not planned for one of the next releases (attached as a Milestones).
typescript/package.json
Outdated
}, | ||
"scripts": { | ||
"build": "del dist && tsc", | ||
"prepare": "npm run build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why prepare
? I usually use prepublishOnly
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prepare as build script in
package.json
. npm-scripts describesprepare
,prepack
andprepublishOnly
. I personally like to check package content vianpm pack
soprepublishOnly
is not helpful here.prepare
also runs on anpm install
without arguments as its done after agit clone
. This might save some time as it hasn't to be done manually but could be annoying on WIP feature branches. The safest solution would beprepack
but I thinkprepare
is a nice to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to prepack
as prepare
runs into errors with a fresh start repo. As prepare
is not needed anyway use prepack
as it runs on npm pack
and npm publish
.
typescript/package.json
Outdated
"@typescript-eslint/promise-function-async": "off", | ||
"ava/no-ignored-test-files": "off" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A goal of mine is to get rid of a lot of the config boilerplate here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. But sadly we are not there yet. It's currently the way to go so until its possible to do it more clean I would like to keep the current state here. That way everyone can see what still has to be done.
Unless the CLI is large, like XO/AVA large, I will probably not bother to make CLI's in TS. |
This is moot since it's being compiled to |
I assume we talked past each other: |
otherwise the tsc already rejects this
No need to run this at `npm install` and it was prone to errors.
ava itself uses ts-node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this repository is a template, adding a folder for the typescript version might defeat the point of a "template" since an extra step is added to either expand or remove the folder. I suggest moving this code to a separate template repository.
@Richienb This PR was added before changing this repo from multiple templates inside folders into multiple templates in multiple repositories. I followed the migration into a template repository like 90ddca2 did. For my typescript template head over to EdJoPaTo/typescript-node-module-boilerplate, PRs and suggestion for improvement welcome :) |
Add a TypeScript Boilerplate to create node modules fast.
Current problems I see
These things stop this currently from being a proper boilerplate
ava/no-ignored-test-files
see Consider extensions in no-import-test-file rule avajs/eslint-plugin-ava#201@typescript-eslint/promise-function-async
does not work for me currently. Have not checked for a relevant issue yet.Open questions I have
I would like other thoughts on these one.
Also a cli boilerplate in TypeScript? The main benefit I see is easier and less error prone usage from dependants. The cli does not do many things so I currently don't think it will be as useful as the module itself in TypeScript.package.json
. npm-scripts describesprepare
,prepack
andprepublishOnly
. I personally like to check package content vianpm pack
soprepublishOnly
is not helpful here.prepare
also runs on anpm install
without arguments as its done after agit clone
. This might save some time as it hasn't to be done manually but could be annoying on WIP feature branches. The safest solution would beprepack
but I thinkprepare
is a nice to have.index.js
/index.d.ts
inpackage.json
types
andmain
? This may not be clear to a inexperienced user. Add it or omit it? For example got is currently omitting it.closes #16