Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Remove destructuring from generateRequestUrl signature #363

Merged

Conversation

nicknisi
Copy link
Member

@nicknisi nicknisi commented Nov 4, 2017

Description:

The generateRequestUrl function is correct, but its usage of destructuring with a default argument is throwing an error in the way that ts-loader reads the code. Issue TypeStrong/ts-loader#442 describes the issue, but it hasn't really had much progress, and it's easier to just change this.

Copy link
Member

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

Also the CI is failing due to some sort of TypeScript error. Not entirely sure why but we should find out what is going on.

query = new UrlSearchParams(query).toString();
if (cacheBust) {
export function generateRequestUrl(url: string, options: RequestOptions = {}): string {
let query = new UrlSearchParams(options.query).toString();
Copy link
Member

Choose a reason for hiding this comment

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

Why not just move the destructering down?

export function generateRequestUrl(url: string, options: RequestOptions = {}): string {
    let { query, cacheBust } = options;

Copy link
Member Author

@nicknisi nicknisi Nov 5, 2017

Choose a reason for hiding this comment

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

I changed it for a couple reasons:

  • I thought it'd be weird to set query and then set it again on the line after it.
	let { query, cacheBust } = options;
	query = new UrlSearchParams(query).toString();
  • I didn't want cacheBust to be a let variable since it's not modified.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, ok, and it is only accessed once (cacheBust) 👍

@nicknisi
Copy link
Member Author

nicknisi commented Nov 5, 2017

It looks like the errors are related to errors in functional tests, and not to changes in this PR.

Running "ts:dev" (ts) task
Compiling...
Using tsc v2.4.2
tests/functional/text/textPlugin.ts(25,30): error TS2339: Property 'text' does not exist on type '{}'.
tests/functional/text/textPlugin.ts(30,30): error TS2339: Property 'text' does not exist on type '{}'.
tests/functional/text/textPlugin.ts(35,30): error TS2339: Property 'text' does not exist on type '{}'.
tests/functional/text/textPlugin.ts(40,30): error TS2339: Property 'text' does not exist on type '{}'.

I'm happy to address, but I can't reproduce locally.

@kitsonk kitsonk added the beta4 label Nov 6, 2017
@kitsonk
Copy link
Member

kitsonk commented Nov 6, 2017

Found the issue and fixed it in #364. I am not sure why it wasn't reproducible on your machine though.

@nicknisi nicknisi merged commit 886d7c3 into dojo:master Nov 7, 2017
@nicknisi nicknisi deleted the generate-request-url-destructure-change branch November 7, 2017 16:08
@dylans dylans added this to the beta.4 milestone Dec 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants