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

Built in Symbol and shimming Symbol #8169

Closed
kitsonk opened this issue Apr 19, 2016 · 1 comment
Closed

Built in Symbol and shimming Symbol #8169

kitsonk opened this issue Apr 19, 2016 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Apr 19, 2016

TypeScript Version:

1.8.10

Code

import Symbol from './Symbol';

export interface Iterable<T> {
    [Symbol.iterator](): Iterator<T>;
}

In Dojo 2, we provide a shim for Symbol. One of the things we have decided to do as a matter of principal is not modify the global namespace with any of our shims, but provide them as modules where the consumer has to make an explicit dependency on that shim. At runtime, we offload to the native API if present, otherwise we provide replicate functionality.

This pattern works effectively, even when targeting ES6, except for Symbol because of the TypeScript's compiler's insistence that we reference the native one.

Is there a good reason why TypeScript disallows this when targeting ES6? If so, is there any way to provide a transparent shim without modifying the global namespace anyone can think of?

Expected behavior:

No errors when targeting es6.

Actual behavior:

When target is es6 we get the following error:

'Symbol' reference does not refer to the global Symbol constructor object.
@mhegazy
Copy link
Contributor

mhegazy commented Apr 19, 2016

looks like a duplicate of #8099

also see #5579 and #2012

@mhegazy mhegazy closed this as completed Apr 19, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Apr 19, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

2 participants