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

Add a TypeScript test and fix compiler errors #1903

Merged
merged 5 commits into from
Feb 1, 2018

Conversation

unstubbable
Copy link
Contributor

fixes #1902

Open question: Should npm run test:typescript be included in npm test or is it sufficient to be included in prepublishOnly? Maybe it should also be included in npm run ci?

Copy link
Contributor

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Good job, Can you also try to remove https://github.com/rollup/rollup/blob/master/tsconfig.json#L4

This will remove the possibility of errors in future when using default imports when indeed a module doesn't have

@alan-agius4
Copy link
Contributor

alan-agius4 commented Jan 23, 2018

Great idea of adding the test :)

@unstubbable
Copy link
Contributor Author

Can you also try to remove https://github.com/rollup/rollup/blob/master/tsconfig.json#L4

This will remove the possibility of errors in future when using default imports when indeed a module doesn't have

Good point, I will try it – the tests are failing right now without a compiler error, need to find the culprit...

Great idea of adding the test :)

Thanks. It won't catch everything though. Especially missing dependencies won't be caught, because they are in node_modules.

@unstubbable
Copy link
Contributor Author

unstubbable commented Jan 23, 2018

The culprit could be any of those modules: https://github.com/rollup/rollup/blob/master/typings/declarations.d.ts#L9-L19
By the way, I would strongly advise against defining these stubs. Often times it's not that much effort to write the typings for the smaller libraries. And for some of them even @types typings exist. (EDIT: Well, it was only one: pretty-ms.)

@alan-agius4
Copy link
Contributor

alan-agius4 commented Jan 23, 2018 via email

@unstubbable
Copy link
Contributor Author

@alan-agius4 I don't think I can make rollup work with allowSyntheticDefaultImports set to false. Here is what I've got so far. But with that change suddenly any module in node_modules can not require path anymore, for example!? I'm not sure whether this is a constraint of rollup-plugin-typescript. In other TS projects I never ran into issues like that. Maybe I'm holding it wrong, though.

@unstubbable
Copy link
Contributor Author

@alan-agius4 Confirmed, so that won't work with rollup-plugin-typescript. But theses type of issues would now be covered by the test I added.

@alan-agius4
Copy link
Contributor

alan-agius4 commented Jan 23, 2018 via email

@alan-agius4
Copy link
Contributor

alan-agius4 commented Jan 27, 2018

cc: @lukastaegert

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Hi, sorry for letting this rest here a few days. Thanks for taking care here, the test works nicely 👍
Once we updated the scripts (see my comment) this is good to go!

package.json Outdated
"pretest-coverage": "npm run build",
"test-coverage": "rm -rf coverage/* && istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/test.js",
"posttest-coverage": "remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.lcov -t lcovonly -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped -t html -b dist",
"ci": "npm run test-coverage && codecov < coverage/coverage-remapped.lcov",
"build": "git rev-parse HEAD > .commithash && rollup -c && tsc -p tsconfig-types.json && chmod a+x bin/rollup",
"watch": "rollup -cw",
"prepublishOnly": "npm run lint && npm run test:only && npm run test:leak",
"prepublishOnly": "npm run lint && npm run test:only && npm run test:leak && npm run test:typescript",
Copy link
Member

Choose a reason for hiding this comment

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

Answering your question when this test should run: As it appears that, at least on my system, this test is rather fast, I think it would be ok to include it in the test script. Otherwise the person publishing it would be the only one fixing issues here (i.e. probably me).
However I would add it after the regular test, i.e. npm run test:only && npm run test:typescript. Adding it to test will also make it run on CI. The ci script, on the other hand, seems to be unused at the moment.

Another issue I stumble upon is that the typings in the dist folder are never cleaned up which resulted in a lot of weird errors for me when running this test. My suggestion is to remove the dist/typings folder (or maybe even the dist folder) as part of the build script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 65a713d. I'm not a windows guy so I'm not sure whether commands like rm or mv are still a cross-platform problem these days. Since rm -rf is already used in the test-coveragescript I used the same in prebuild. If that's a concern we could use rimraf instead. I'm not sure about the mv though. Maybe cash-mv is an option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, appveyor just answered my question. Will fix...

- add test:typescript script to test script
- remove dist directory before build
@lukastaegert
Copy link
Member

👍

@lukastaegert lukastaegert added this to the 0.55.2 milestone Jan 29, 2018
@lukastaegert lukastaegert merged commit 70fee6c into rollup:master Feb 1, 2018
@unstubbable unstubbable deleted the typescript-test branch February 1, 2018 08:32
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.

Integration in TypeScript project broke again
3 participants