Skip to content

Add TypeScript recipe #589

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

Closed
wants to merge 4 commits into from
Closed

Add TypeScript recipe #589

wants to merge 4 commits into from

Conversation

SamVerschueren
Copy link
Contributor

I kept it simple. Feel free to provide feedback if I missed something or if I have to add some extra things.

@ivogabe Something you would like to add or improve?

return Promise.resolve('foo');
}

test(async (t) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test(async t => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sindresorhus
Copy link
Member

Can you also add a link to the readme?

@sindresorhus sindresorhus changed the title add typescript recipe Add TypeScript recipe Mar 2, 2016
{
"compilerOptions": {
"module": "commonjs",
"target": "es2015"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add outDir? That will compile the sources to a different directory. If you place all files in the same directory, you can easily confuse JS fileswith TS files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the outDir. AVA looks for test.js or test/*.js if I'm not mistaken. So what should I use as value for outDir then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used lib/test for the TS tests and dist/test for the compiled tests. The options should be "outDir": "dist", "rootDir": "lib".

AVA needs some configuration for that, I started AVA using ava dist/test. It can also be configured in the readme. Though maybe dist/test/*.js could be added as a new test location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it quite specific per project? I mean, some people will use TypeScript for the entire project, some might only use it for the tests. I don't want to force them in using a specific approach or directory structure. This recipe is just for the basics, they can always go from here and do some more advanced stuff with it, no?

@ivogabe
Copy link
Contributor

ivogabe commented Mar 2, 2016

👍 after you've addressed my two minor comments

@SamVerschueren
Copy link
Contributor Author

@sindresorhus What link? Link to the AVA readme? Can't find something similar in the other recipes so guess I'm a little confused :p.

@sindresorhus
Copy link
Member

@SamVerschueren
Copy link
Contributor Author

Damnit, just screwed up squasing my commits. Let me try to fix it.

@SamVerschueren
Copy link
Contributor Author

Alright, don't gonna touch the commits anymore :). Not sure if I should add the outDir property to tsconfig.json?

@sindresorhus tips for squashing when you had to sync with the remote in between? It totally got screwed up the previous time :).

@ivogabe
Copy link
Contributor

ivogabe commented Mar 2, 2016

TypeScript users should already know how to use the outDir option, so it should be fine without it too.

@SamVerschueren
Copy link
Contributor Author

We can always improve depending on the feedback via twitter/gitter/issues.

@sindresorhus
Copy link
Member

tips for squashing when you had to sync with the remote in between?

Don't sync with git pull, but with git pull --rebase.

@sindresorhus
Copy link
Member

But don't worry. I'll squash when I merge.

@SamVerschueren
Copy link
Contributor Author

@sindresorhus Alright, thanks for the tip :)!

@sindresorhus
Copy link
Member

Landed. I'd like to keep it simple as is. TypeScript will (should) know how to use the TSC options. Not the correct place to teach it here.

Thanks Sam!

@SamVerschueren
Copy link
Contributor Author

Glad I could help :)

@ivogabe
Copy link
Contributor

ivogabe commented Mar 2, 2016

👍

@kasperlewau
Copy link
Contributor

Don't sync with git pull, but with git pull --rebase.

off topic

I'd like to chime in on this statement and say; put it in your global git config. Fire and forget. Be rid of any nonsense merge [remote]master into [local]X commits.

# git >= 1.7.9
git config --global pull.rebase true

# git < 1.7.9 
git config --global branch.autosetuprebase always

I for one can't think of a time and place where a straight up git pull would be preferential. Sorry for the off topic comment!

@SamVerschueren
Copy link
Contributor Author

Thanks @kasperlewau . Will save me some headaches in the future :).

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

Successfully merging this pull request may close these issues.

4 participants