Skip to content

Error: TS2393: Duplicate function implementation. #28833

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

Closed
bluelovers opened this issue Dec 4, 2018 · 5 comments
Closed

Error: TS2393: Duplicate function implementation. #28833

bluelovers opened this issue Dec 4, 2018 · 5 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@bluelovers
Copy link
Contributor

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms: Duplicate function implementation.

Code

// => Error: TS2393: Duplicate function implementation.
function f()
{
	if (true)
	{
		throw new Error();
	}
}
console.log(1);
f();
console.log(2);

i know in #24925 (comment)

it say can add export {};

but with follow code, work as Expected => ReferenceError: f is not defined

so there is no f in global

console.log(1);
f();
console.log(2);

Expected behavior:

should not have error

Actual behavior:

Error: TS2393: Duplicate function implementation.

Playground Link:

Related Issues:

@weswigham weswigham added the Needs More Info The issue still hasn't been fully clarified label Dec 4, 2018
@weswigham
Copy link
Member

weswigham commented Dec 4, 2018

what other code is in your compilation? This doesn't happen in the playground, so something important is missing from your description.

@bluelovers
Copy link
Contributor Author

@weswigham

2 file all have f

video https://www.youtube.com/watch?v=rj8wdubGmf8&feature=youtu.be

ts\index.d.ts
ts\index.js
ts\index.ts

uglify\index.d.ts
uglify\index.js
uglify\index.ts

@weswigham
Copy link
Member

Oh. Well, yeah. Both of those files are interpreted as being globally scoped, so we see two definitions of f in the global scope, which isn't good.

@bluelovers
Copy link
Contributor Author

bluelovers commented Dec 5, 2018

but they didn't use together

i think should not check this

i don't understand why need check this
there has something will have bug by this?

@Ln2be
Copy link

Ln2be commented Jan 14, 2021

Yes This must be a bug why all the files in the same folder are globally scopes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants