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

TypeScript support is broken #16

Open
nazar-pc opened this issue Jul 3, 2019 · 1 comment · May be fixed by #17
Open

TypeScript support is broken #16

nazar-pc opened this issue Jul 3, 2019 · 1 comment · May be fixed by #17

Comments

@nazar-pc
Copy link

nazar-pc commented Jul 3, 2019

Looks like after rewrite to TypeScript "types" key in package.json was lost, which is necessary for be useful in TypeScript.

@nazar-pc nazar-pc linked a pull request Jul 3, 2019 that will close this issue
@Sakari369
Copy link

I don't know if this is related, but with this code

	const controller = new AbortController()
	const signal:AbortSignal = controller.signal;
	const timeout = setTimeout(() => { 
		controller.abort(); 
	}, 15000);

	const res = await fetch(`https://api.keygen.sh/v1/accounts/${KEYGEN_ACCOUNT_ID}/licenses/actions/validate-key`, {
		method: 'POST',
		signal: signal,
		headers: {
			'Content-Type': 'application/vnd.api+json',
			'Accept': 'application/vnd.api+json'
		},
		body: JSON.stringify({
			meta: {
				scope: { product: KEYGEN_PRODUCT_ID },
				key: license_key
			}
		}),
	})

I get the following error:

electron/main/main.ts:268:114 - error TS2345: Argument of type '{ method: string; signal: AbortSignal; headers: { 'Content-Type': string; 'Accept': string; }; body: string; }' is not assignable to parameter of type 'RequestInit'.
  Types of property 'signal' are incompatible.
    Type 'AbortSignal' is not assignable to type 'import("/Users/sakari/dvl/omg/client-standalone/electron/node_modules/@types/node-fetch/externals").AbortSignal'.
      Types of property 'onabort' are incompatible.
        Type '((this: AbortSignal, ev: ProgressEvent) => any) | null' is not assignable to type '((this: AbortSignal, event: any) => void) | null | undefined'.
          Type '(this: AbortSignal, ev: ProgressEvent) => any' is not assignable to type '(this: AbortSignal, event: any) => void'.
            The 'this' types of each signature are incompatible.
              Type 'import("/Users/sakari/dvl/omg/client-standalone/electron/node_modules/@types/node-fetch/externals").AbortSignal' is not assignable to type 'AbortSignal'.
                Types of property 'onabort' are incompatible.
                  Type '((this: AbortSignal, event: any) => void) | null | undefined' is not assignable to type '((this: AbortSignal, ev: ProgressEvent) => any) | null'.
                    Type 'undefined' is not assignable to type '((this: AbortSignal, ev: ProgressEvent) => any) | null'.

268  const res = await fetch(`https://api.keygen.sh/v1/accounts/${KEYGEN_ACCOUNT_ID}/licenses/actions/validate-key`, {

Just installed latest version of abort-controller and tsc Version 3.3.3333.

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 a pull request may close this issue.

2 participants