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

Emits broken declaration for class that extends from function that returns a constructor signature. #15692

Closed
rzvc opened this issue May 9, 2017 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@rzvc
Copy link

rzvc commented May 9, 2017

TypeScript Version: nightly (2.4.0-dev.20170509)

Code

namespace Test
{
	export interface IFace
	{
	}

	export class SomeClass implements IFace
	{
	}

	export class Derived extends getClass<IFace>()
	{
	}

	export function getClass<T>() : new() => T
	{
		return SomeClass as (new() => T);
	}
}

Expected output:

declare namespace Test {
    interface IFace {
    }
    class SomeClass implements IFace {
    }
    const Derived_base: new () => IFace;
    class Derived extends Derived_base {
    }
    function getClass<T>(): new () => T;
}

Actual behavior:

declare namespace Test {
    interface IFace {
    }
    class SomeClass implements IFace {
    }
    declare const Derived_base: new () => IFace;
    class Derived extends Derived_base {
    }
    function getClass<T>(): new () => T;
}

Notice the extra declare, in front of the "const Derived_base" declaration.
That makes the compiler complain about the declare modifier being inside an already ambient context.

Edit: related to #15572.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label May 9, 2017
@mhegazy mhegazy added this to the TypeScript 2.3.3 milestone May 9, 2017
@mhegazy
Copy link
Contributor

mhegazy commented May 9, 2017

looks like a regression from #15537

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 10, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants