Skip to content

Add system argument to readConfigFile#4497

Merged
DanielRosenwasser merged 3 commits intomicrosoft:masterfrom
weswigham:patch-4
Sep 5, 2015
Merged

Add system argument to readConfigFile#4497
DanielRosenwasser merged 3 commits intomicrosoft:masterfrom
weswigham:patch-4

Conversation

@weswigham
Copy link
Copy Markdown
Member

Which allows the caller to specify the System used to read the file.

Which allows the caller to specify the `System` used to read the file.
Comment thread src/compiler/commandLineParser.ts Outdated
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.

Given that it's only used once in the compiler, I'd make this non-optional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree completely (and have followed up by doing so). But we should acknowledge this is a breaking change to a public API. (exported in the ts namespace without a /* @internal */ annotation)

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.

Keep it optional so this is not a breaking change.

@weswigham weswigham changed the title Add optional argument to readConfigFile Add system argument to readConfigFile Aug 27, 2015
Comment thread src/compiler/commandLineParser.ts Outdated
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 would use readFile: (path: string) => string instead of full-blown sys as an optional argument. For consumers that does not have sys it will be simpler then supplying implementation of System where everything but readFile throws Error("Unsupported") or something like that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair. It is really all it cares about.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Aug 28, 2015

why is this needed?

@vladima
Copy link
Copy Markdown
Contributor

vladima commented Aug 28, 2015

I'd say this is a cleanup work that will our API more transparent and easy to use on environments where sys is not defined.

@weswigham
Copy link
Copy Markdown
Member Author

Less needed, more for consistency. Up until 8 days ago the language service server called ts.readConfigFile and wasn't even aware that it called into sys (meaning if you actually wanted to use your host you had to override sys, too!). If ts.sys is an implementation detail of the default host, then we should clearly mark when public functions use it - or remove public functions' dependencies on it. @vladima has an open PR which removes the remaining sys dependencies in commandLineParser.ts.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Aug 28, 2015

thanks for the explanation. 👍

DanielRosenwasser added a commit that referenced this pull request Sep 5, 2015
Add system argument to readConfigFile
@DanielRosenwasser DanielRosenwasser merged commit 4a85546 into microsoft:master Sep 5, 2015
@vladima
Copy link
Copy Markdown
Contributor

vladima commented Sep 5, 2015

Why it was merged? Currently it is a breaking change because new argument is non optional?

@weswigham
Copy link
Copy Markdown
Member Author

You're right, and nobody picked up on it because continuing commenting on outdated diffs is odd. >.>

Would we like to fix it?

@vladima
Copy link
Copy Markdown
Contributor

vladima commented Sep 5, 2015

I would say yes, there is no compelling reason for this to be a breaking change

jbrantly added a commit to TypeStrong/ts-loader that referenced this pull request Sep 8, 2015
@weswigham weswigham deleted the patch-4 branch August 17, 2017 23:02
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants