Skip to content

fix: add support for typescript 2.6 #74

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

Merged
merged 1 commit into from
Nov 3, 2017
Merged

Conversation

ofrobots
Copy link
Contributor

@ofrobots ofrobots commented Nov 2, 2017

No description provided.

@ofrobots ofrobots requested a review from kjin November 2, 2017 14:43
@codecov-io
Copy link

codecov-io commented Nov 2, 2017

Codecov Report

Merging #74 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #74      +/-   ##
=========================================
+ Coverage    99.6%   99.6%   +<.01%     
=========================================
  Files           8       8              
  Lines         251     254       +3     
  Branches       10      10              
=========================================
+ Hits          250     253       +3     
  Misses          1       1
Impacted Files Coverage Δ
test/test-kitchen.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update daaa1a6...1ff36c3. Read the comment docs.

package.json Outdated
@@ -66,7 +66,7 @@
"nyc": "^11.2.1",
"source-map-support": "^0.5.0",
"tmp": "0.0.31",
"typescript": "~2.4.1"
"typescript": "^2.6.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to go with the ~ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that!

@@ -22,18 +22,33 @@ const simpleExecp = pify(cp.exec);
const renamep = pify(fs.rename);
const ncpp = pify(ncp.ncp);

// TODO: improve the typedefinitions in @types/node. Right now they specify
// the return type to be Error.
interface ExecError extends Error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is non-blocking PR commentary :) I see the pattern of attaching a code property to Error objects all over our repositories. It makes working with TypeScript and errors kind of ugly. Two thoughts on how to address:

  1. Should we maybe consider using Error.prototype.name instead?

  2. Should we consider chatting with tc39 folks about adding a general purpose code field to the Error object?

Copy link
Member

Choose a reason for hiding this comment

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

@types/node defines NodeJS.ErrnoException, which extends Error and has errno, code, path, syscall, and stack. Is that what we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jinwoo No. ErrnoException has a string code. child_process.exec API returns an Error with a number code property. @types/node doesn't have an error type for the exec at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JustinBeckwith

Should we maybe consider using Error.prototype.name instead?

This is not up to us. The exec API in Node.js core returns an Error with a particular structure.

Should we consider chatting with tc39 folks about adding a general purpose code field to the Error object?

In Node.js core, James Snell is championing an effort to have a code property added to all errors returned by core. I think it would be worth chatting with him to the next steps beyond that.

@ofrobots
Copy link
Contributor Author

ofrobots commented Nov 3, 2017

TBR= @kjin

@ofrobots ofrobots merged commit 7b3db0f into google:master Nov 3, 2017
@ofrobots ofrobots deleted the ts-2.6 branch November 3, 2017 02:57
Copy link
Contributor

@kjin kjin left a comment

Choose a reason for hiding this comment

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

Posthumous LGTM w/ Q's.

}

function isExecError(err: Error|ExecError): err is ExecError {
return (<ExecError>err).code !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we prefer err as ExecError?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, isExecError could have checked that err is undefined.

const execp =
(command: string, execOptions?: cp.ExecOptions): Promise<ExecResult> => {
return new Promise((resolve) => {
cp.exec(
command, execOptions || {},
(err: Error&{code: number}, stdout, stderr) => {
resolve({exitCode: err ? err.code : 0, stdout, stderr});
(err: Error|ExecError|null, stdout, stderr) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be ExecError|null? This looks like the same as googleapis/gcp-metadata#16

If so, I think isExecError might not be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants