Skip to content

Add a TypeScript test and fix compiler errors - #1903

Merged
lukastaegert merged 5 commits into
rollup:masterfrom
unstubbable:typescript-test
Feb 1, 2018
Merged

Add a TypeScript test and fix compiler errors#1903
lukastaegert merged 5 commits into
rollup:masterfrom
unstubbable:typescript-test

Conversation

@unstubbable

Copy link
Copy Markdown
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?

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

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

alan-agius4 commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

Great idea of adding the test :)

@unstubbable

Copy link
Copy Markdown
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

unstubbable commented Jan 23, 2018

Copy link
Copy Markdown
Contributor Author

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

alan-agius4 commented Jan 23, 2018 via email

Copy link
Copy Markdown
Contributor

@unstubbable

Copy link
Copy Markdown
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
Copy Markdown
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

alan-agius4 commented Jan 23, 2018 via email

Copy link
Copy Markdown
Contributor

@alan-agius4

alan-agius4 commented Jan 27, 2018

Copy link
Copy Markdown
Contributor

cc: @lukastaegert

@lukastaegert lukastaegert left a comment

Copy link
Copy Markdown
Member

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!

Comment thread package.json Outdated
"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",

@lukastaegert lukastaegert Jan 27, 2018

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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