Skip to content
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

fix: lib.fetch types using experimental ts-graft discover mode #100

Merged
merged 1 commit into from Mar 27, 2021

Conversation

jstewmon
Copy link
Contributor

lib.fetch.d.ts includes all type definitions from the dom and
dom.iterable libs which were reachable from the original cross-fetch
index.d.ts file:

git checkout 7b19cdab1c9b84294032f16a2b13ec258f3a726e -- index.d.ts

lib.fetch.d.ts was generated with the following command:

cat <<EOF > .ts-graftrc.yaml \
&& npx ts-graft@2.0.0-1 \
&& rm .ts-graftrc.yaml \
grafts:
  - source: index.d.ts
    output: lib.fetch.d.ts
    include:
      - dom
      - dom.iterable
EOF

index.d.ts was then updated to its new state and verified with the
following command:

npx tsc --lib ES6 index.d.ts

Issue #95 was validated as follows:

cat <<EOF > test.ts \
&& npx tsc --target ES6 --moduleResolution node --noEmit  test.ts \
&& rm test.ts
import fetch from "./";
export const customFetch = (
  input: RequestInfo,
  init: RequestInit,
): Promise<Response> => {
  let url = "";
  url += input;
  return fetch(url, init);
};
EOF

n.b. consumers must include the dom.iterable lib, which is implied by
the ES6 target, lest their globals lack the required members defined
by dom.iterable.

lib.fetch.d.ts includes all type definitions from the dom and
dom.iterable libs which were reachable from the original cross-fetch
index.d.ts file:

```
git checkout 7b19cda -- index.d.ts
```

lib.fetch.d.ts was generated with the following command:

```
cat <<EOF > .ts-graftrc.yaml \
&& npx ts-graft@2.0.0-1 \
&& rm .ts-graftrc.yaml \
grafts:
  - source: index.d.ts
    output: lib.fetch.d.ts
    include:
      - dom
      - dom.iterable
EOF
```

index.d.ts was then updated to its new state and verified with the
following command:

```
npx tsc --lib ES6 index.d.ts
```

Issue lquixada#95 was validated as follows:

```
cat <<EOF > test.ts \
&& npx tsc --target ES6 --moduleResolution node --noEmit  test.ts \
&& rm test.ts
import fetch from "./";
export const customFetch = (
  input: RequestInfo,
  init: RequestInit,
): Promise<Response> => {
  let url = "";
  url += input;
  return fetch(url, init);
};
EOF
```

n.b. consumers must include the dom.iterable lib, which is implied by
the ES6 target, lest their globals lack the required members defined
by dom.iterable.
@lquixada
Copy link
Owner

thanks @jstewmon ! I feel there's still some work to do here such as adding a job on CI to prevent further type issues but this PR is a good step!

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

Successfully merging this pull request may close these issues.

None yet

2 participants