Skip to content

Node: path.format input properties are optional - #21003

Merged
5 commits merged into
DefinitelyTyped:masterfrom
OliverJAsh:oja/node/format-path-input-optional
Nov 10, 2017
Merged

5 commits merged into
DefinitelyTyped:masterfrom
OliverJAsh:oja/node/format-path-input-optional

Conversation

@OliverJAsh

Copy link
Copy Markdown
Contributor

If base does not exist, name and ext will be used to compute it.

http://devdocs.io/node/path#path_path_format_pathobject

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

@dt-bot

dt-bot commented Oct 25, 2017

Copy link
Copy Markdown
Member

types/node/index.d.ts

to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis Microsoft TypeScript (account can't be detected)). Could you review this PR?
👍 or 👎?

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Oct 25, 2017
@typescript-bot

Copy link
Copy Markdown
Contributor

@OliverJAsh Please fix the failures indicated in the Travis CI log.

@OliverJAsh

Copy link
Copy Markdown
Contributor Author

Build failed due to timeout.

Comment thread types/node/index.d.ts Outdated

export interface FormatInputPathObject extends
Pick<ParsedPath, 'root' | 'dir' | 'ext' | 'name'>,
Partial<Pick<ParsedPath, 'base'>> {}

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.

I think all properties should be optional here.

  • root is ignored if dir is provided
    ==> so why have root mandatory if it is ignored?
    ==> and why should we mandate to set dir === "" to get rootused?
  • ext and name are ignored if base exists
    ==> I see no reason for mandatory ext and name as they get ignored
    ==> not every path has an extension so why force users to set ""?

Not sure if it is possible to define a type which represents these interdependency.

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.

Not sure if it is possible to define a type which represents these interdependency.

I guess you could express a union of all the permutations:

type Obj =
    { base: string; ext: string; name: string; }
  | { ext: string; name: string; } 
  | { base: string; };

However I think it's simpler just to make them all optional, like you said. After all, you can call format with an empty object and it will work (i.e. it won't throw, so it's type safe).

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.

@Flarna Updated to make all properties optional.

@RyanCavanaugh

Copy link
Copy Markdown
Member

@OliverJAsh Please fix the failures indicated in the Travis CI log.

@OliverJAsh

OliverJAsh commented Oct 31, 2017 •

Copy link
Copy Markdown
Contributor Author

@RyanCavanaugh It's just a build timeout. It happens on every build unfortunately, when linting the Node typings.

The job exceeded the maximum time limit for jobs, and has been terminated.

@kjin kjin mentioned this pull request Nov 2, 2017
6 tasks done
@Flarna Flarna mentioned this pull request Nov 5, 2017
@OliverJAsh

Copy link
Copy Markdown
Contributor Author

Ping @RyanCavanaugh @Flarna. Build failed due to timeout. Please can we merge?

@Flarna

Flarna commented Nov 10, 2017

Copy link
Copy Markdown
Contributor

Sorry, can't help here as I have no write access. As far as I know @Andy-MS has changed something in the types publisher to reduce the test time (see microsoft/types-publisher#398) but I don't know if this is already productive. You could try by closing and reopening this PR or push something.

@OliverJAsh OliverJAsh closed this Nov 10, 2017
@OliverJAsh OliverJAsh reopened this Nov 10, 2017
@ghost

ghost commented Nov 10, 2017

Copy link
Copy Markdown

Could do this without using Partial? That would be the first ts2.2 feature in @types/node.

@OliverJAsh

Copy link
Copy Markdown
Contributor Author

@Andy-MS Updated

@ghost

ghost commented Nov 10, 2017

Copy link
Copy Markdown

Thanks!

@ghost
ghost merged commit a8e8865 into DefinitelyTyped:master Nov 10, 2017
@OliverJAsh
OliverJAsh deleted the oja/node/format-path-input-optional branch November 10, 2017 15:40
luho383 added a commit to luho383/DefinitelyTyped that referenced this pull request Nov 11, 2017
* master: (356 commits)
  vuex-i18n: Fixes from code review (DefinitelyTyped#21418)
  resourcejs: Increase TypeScript version to match mongoose
  leaflet.polylinemeasure: Add TypeScript version
  updated TS version to 2.3 for �abel-webpack-plugin.
  crlf -> lf
  Make hljs a proper UMD module
  Use only major.minor for `highlight.js`.
  atom: fix several incorrect definitions.
  Update index.d.ts
  Node: `path.format` input properties are optional (DefinitelyTyped#21003)
  New typings for fs-cson module (DefinitelyTyped#21375)
  New typings for bunyan-format module (DefinitelyTyped#21376)
  [chart.js] Add 'pie' to ChartType
  Update highlight.js version to latest (9.12.0)
  Fix type for highlight.js continuation argument
  Fixed errors after dts-gen
  New typings for module wtfnode
  fix getMeasure result fix: IGenericDimensionLayout
  change return Value of getDimension() from Dimension Object
  puppeteer: setCookie should be less strict
  ...

# Conflicts:
#	types/three/test/css3d/css3d_sprites.ts
#	types/three/test/webgl/webgl_materials.ts
KSXGitHub pushed a commit to KSXGitHub/DefinitelyTyped that referenced this pull request May 12, 2018
)

* Node: `path.format` input properties are optional

If `base` does not exist, `name` and `ext` will be used to compute it.

http://devdocs.io/node/path#path_path_format_pathobject

* Node: `FormatInputPathObject`: all properties are optional

* Node: add myself as author

* Avoid usage of `Partial`
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants