-
Notifications
You must be signed in to change notification settings - Fork 38
upgrade to typescript 2.0 and fix broken build process #47
Conversation
|
yay! taking a look |
test/service-worker_test.js
Outdated
| serviceWorker.generateServiceWorker(); | ||
| }, Error.AssertionError, '`project` & `buildRoot` options are required'); | ||
| return serviceWorker.generateServiceWorker() | ||
| .then(() => { throw new Error('generateServiceWorker() resolved, expected rejection!'); }) |
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 would do Promise inversions as two callback to then(), so that you don't have to worry about the exception you throw in then() flowing into catch(). Then just assert.fail() in the first callback. Alternatively, we have a handy invert() function hangout out around here somewhere...
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.
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.
nice, I like this.
tsconfig.json
Outdated
| "src/**/*.ts", | ||
| "typings/index.d.ts" | ||
| ], | ||
| "files": [ |
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.
TS 2.x supports includes and excludes. Use those instead of files.
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.
🎉 nice! It's behavior is a little weird, which is why I hadn't been able to get it working before. Files still need to be referenced in the files array. ¯_(ツ)_/¯
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.
you shouldn't. We don't use files at all in the analyzer
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.
Please try to remove files before submitting. One file is replaced by compilerOptions.lib, the other should go in includes.
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.
👍 got it! Taking out"typings/index.d.ts" was what caused the error I was seeing, but it turns out it was a problem with typings and not typescript.
| "gulp": "registry:dt/gulp#3.8.0+20160316155526", | ||
| "gulp-if": "registry:dt/gulp-if#0.0.0+20160316155526", | ||
| "gulp-util": "registry:dt/gulp-util#0.0.0+20160316155526", | ||
| "merge-stream": "registry:dt/merge-stream#1.0.0+20160313224417", |
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.
can you migrate to @types while we're at this?
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.
not all of them are supported yet, but I'll migrate the ones I can
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.
which ones? All of these come from DT, so they should be available in @types
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.
Only DT stuff in their 2.0 branch is in @types. They're using this as a chance to standardize on modern practices.
usergenic
left a comment
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.
OMG ITS WORKING
|
TRAVIS Y U NO LIKE? Anything we can do to fix that here too so we have green travis checks? wrt https://travis-ci.org/Polymer/polymer-build/jobs/161702741 (unless node 4 is no longer unsupported) |
f347fa5 to
f5cada9
Compare
fe68851 to
18020ae
Compare
|
@usergenic the |
|
@justinfagnani PTAL |
tsconfig.json
Outdated
| } | ||
| "include": [ | ||
| "custom_typings/**/*.ts", | ||
| "node_modules/@types/**/*.ts", |
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 don't think you need or want this line. tsc automatically looks for these when you use node resolution
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.
+1
| "rewriteTsconfig": true | ||
| } | ||
| "include": [ | ||
| "custom_typings/**/*.ts", |
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.
@rictic do you remember why we use /// <reference path="../custom_typings/main.d.ts" /> in analyzer.ts rather than include custom_typings in tsconfig? Is it for declarations and dependers?
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.
Yeah, it's for the generated .d.ts declarations file. If you only mention the dependency in your tsconfig then downstream users won't see the custom typings.
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'll add this for the sw-precache custom typing and we can look into publishing it directly to npm. All the others are internal only and shouldn't affect the polymer-build declarations
gulpfile.js
Outdated
|
|
||
| gulp.task('depcheck', () => | ||
| depcheck(__dirname, {}) | ||
| depcheck(__dirname, {ignoreMatches: ['@types/**']}) |
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.
can you comment the ignore?
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 really make that part of the default ignoreMatches
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.
+1
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.
+10, I'll create a PR and comment for now
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.
Already tracking here: depcheck/depcheck#163
test/service-worker_test.js
Outdated
| }, Error.AssertionError, '`project` & `buildRoot` options are required'); | ||
| return serviceWorker.generateServiceWorker() | ||
| .then( | ||
| () => { throw new Error('generateServiceWorker() resolved, expected rejection!'); }, |
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.
instead of throwing, you can: assert.fail('generateServiceWorker() resolved, expected rejection!')
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.
Any reason to prefer assert.fail over new Error?
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.
The UX. I think an uncaught error is reported different, and tries to display a stacktrace. Here we know it's a plain failure and the stack won't help.
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'm fine with either, the difference seems minor
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'd use fail()
|
@justinfagnani @rictic PTAL |
e792601 to
75a531f
Compare
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
| async _buildBundles(): Promise<Map<string, string>> { | ||
| let bundles = await this._getBundles(); |
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.
Here and elsewhere: preferred style is const by default, let only when necessary.
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.
Agreed, but I'd like to keep the scope of this PR small for now. I'll make a separate PR to address this across the repo once this has been merged.
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.
Agreed w/ the agree. In the future, just do the async/await in another PR also :)
| ? urlFromPath(this.root, this.shell) | ||
| : this.sharedBundleUrl; | ||
| let sharedDeps = bundles.get(sharedDepsBundle) || []; | ||
| let promises: Promise<any>[] = []; |
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.
Minimize use of any, it's usually a code smell. Would this work?
const promises: Promise<{url: string, contents: string}>[] = []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.
Agreed, but I'd like to keep the scope of this PR small for now. This diff was only a indentation change due to a move over to async-await above. I'll make a separate PR to address this.
| "declaration": true, | ||
| "noImplicitAny": true, | ||
| "removeComments": false, | ||
| "noLib": true, |
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.
noLib still makes sense, or
"lib": ["es2017"],
| "gulp": "registry:dt/gulp#3.8.0+20160316155526", | ||
| "gulp-if": "registry:dt/gulp-if#0.0.0+20160316155526", | ||
| "gulp-util": "registry:dt/gulp-util#0.0.0+20160316155526", | ||
| "merge-stream": "registry:dt/merge-stream#1.0.0+20160313224417", |
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.
Only DT stuff in their 2.0 branch is in @types. They're using this as a chance to standardize on modern practices.
|
As a code review style note, when possible instead of rewriting existing commits add --fixup commits instead, and you can rebase them right before going to master. It makes it easier for us to see only the new changes. |
|
@rictic TIL! I've never used the @rictic @justinfagnani thanks for the help so far with all the different TypeScript config options, feeling much more confident in our config setup now. |
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
| async _buildBundles(): Promise<Map<string, string>> { | ||
| let bundles = await this._getBundles(); |
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.
Agreed w/ the agree. In the future, just do the async/await in another PR also :)
@usergenic and I ran into problems with
gulp-typescriptyesterday, this upgrades to the latest 2.0 version and fixes some issues with config, custom_typings, etc./cc @usergenic @justinfagnani