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

need someting overwrite type check #21880

Closed
bluelovers opened this issue Feb 12, 2018 · 2 comments
Closed

need someting overwrite type check #21880

bluelovers opened this issue Feb 12, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@bluelovers
Copy link
Contributor

TypeScript Version: 2.7.0-dev.201xxxxx

Search Terms:

Code

import * as PromiseBluebird from 'bluebird';

export function dPromise<T>(target: any, propertyKey: string, descriptor: PropertyDescriptor)
{
	/*
	if (descriptor === undefined)
	{
		descriptor = Object.getOwnPropertyDescriptor(target, propertyKey);
	}
	*/
	descriptor.value = PromiseBluebird.method<T>(descriptor.value);

	return descriptor;
}

export let a = PromiseBluebird.method<boolean>(function ()
{
	return true;
});

export interface Promise<T> extends PromiseBluebird<T>
{}

export declare var Promise: typeof PromiseBluebird;

export class Test
{
	/**
	 *
	 * @param {URL} url
	 * @param {IDownloadOptions} downloadOptions
	 * @returns {PromiseBluebird<INovel>}
	 */
	@dPromise
	// _@ts-ignore
	static async get_volume_list(url?: URL, downloadOptions = {}): Promise<boolean>
	{
		//...
		return true;
	}
}

Test.get_volume_list().tap(function (ret)
{
	console.log(ret);
});

Expected behavior:

something can realy overwrite type without warn or use // @ts-ignore
in typescript

export declare class Test {
    /**
     *
     * @param {URL} url
     * @param {IDownloadOptions} downloadOptions
     * @returns {PromiseBluebird<boolean>}
     */
    static get_volume_list(url?: URL, downloadOptions?: {}): PromiseBluebird<boolean>;
}

Actual behavior:

with warn

Error:(36, 65) TS1064: The return type of an async function or method must be the global Promise type.

import * as PromiseBluebird from 'bluebird';
export declare function dPromise<T>(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
export declare let a: (...args: any[]) => PromiseBluebird<boolean>;
export interface Promise<T> extends PromiseBluebird<T> {
}
export declare var Promise: typeof PromiseBluebird;
export declare class Test {
    /**
     *
     * @param {URL} url
     * @param {IDownloadOptions} downloadOptions
     * @returns {PromiseBluebird<boolean>}
     */
    static get_volume_list(url?: URL, downloadOptions?: {}): Promise<boolean>;
}

Playground Link:

Related Issues:

@ghost
Copy link

ghost commented Feb 12, 2018

#19139 would allow you to ignore the must be the global Promise type without ignoring other errors.
Although, I would test if that Promise returned is actually the local Promise at runtime.

@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 12, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants