-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
TypeScript issue when import #10
Comments
Hi @shian15810, I think that it is related to this issue : microsoft/TypeScript#2719 As a workaround, I added a I committed on the dev branch, could you check it out by running Thanks ! Also, here are the files I used to reproduce (it may help) : tsconfig.json {
"compilerOptions": {
"target": "es5",
"lib": [ "es2015", "dom" ],
"module": "commonjs",
"outDir": ".",
"moduleResolution": "node",
"declaration": false,
"noImplicitAny": false,
"sourceMap": false,
"types": [ "node" ]
},
"files": ["test-node.ts"]
} test-node.ts import * as formData from 'form-data';
import { URLSearchParams } from 'url';
import nodeFetch from 'node-fetch';
import wretch from 'wretch';
wretch().polyfills({
fetch: nodeFetch,
FormData: formData,
URLSearchParams,
});
wretch("http://google.com").get().text(_ => console.log(_)) test-node.js (compiled with tsc) "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var formData = require("form-data");
var url_1 = require("url");
var node_fetch_1 = require("node-fetch");
var wretch_1 = require("wretch");
wretch_1.default().polyfills({
fetch: node_fetch_1.default,
FormData: formData,
URLSearchParams: url_1.URLSearchParams,
});
wretch_1.default("http://google.com").get().text(function (_) { return console.log(_); }); To setup and launch :
Output seems fine and no complaints from tsc from my side ! |
Oh yes! No more complaining from tsc in my project anymore. Also, thanks for your hard work on wretch! |
Many thanks !! 😄
ASAP, meaning today or tomorrow at most ! |
When I import wretch according to the test file and polyfill it as the following,
it complain that wretch.default is not a function when build with tsc.
wretch.default().polyfills({
TypeError: wretch.default is not a function
And when i change it to the syntax below,
it works, but the linter is complaining...
[ts] Cannot invoke an expression whose type lacks a call signature.
So what I do now is
so that the type definition and
tsc build
keep working again.Is there anything wrong with my syntax? Or is there any compiler option that is causing this?
The text was updated successfully, but these errors were encountered: