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

tsickle emits uncompilable code for parameter named "interface" #766

Open
mitchellwills opened this issue Mar 15, 2018 · 4 comments
Open

tsickle emits uncompilable code for parameter named "interface" #766

mitchellwills opened this issue Mar 15, 2018 · 4 comments

Comments

@mitchellwills
Copy link
Contributor

@mitchellwills mitchellwills commented Mar 15, 2018

For example, this snipit from the nodejs typings

declare module "readline" {
  export function emitKeypressEvents(stream: NodeJS.ReadableStream, interface?: ReadLine): void;
}

Generates an externs file with this content, including the parameter named "interface".

/**
 * @param {?} stream
 * @param {?=} interface
 * @return {?}
 */
tsickle_declare_module.readline.emitKeypressEvents = function(stream, interface) {};

however, closure compiler then rejects this with

.../node.externs.js:3524: ERROR - Parse error. ')' expected
tsickle_declare_module.readline.emitKeypressEvents = function(stream, interface) {};

I was a little surprised that Typescript accepts this, but Chrome, Safari, and Firefox all accept this code so i'm assuming it's valid to use "interface" as a parameter name is javascript. I did file a closure compiler bug as well.

(function x(interface) { console.log(interface); })('test')
@mitchellwills mitchellwills changed the title tsickle does not correctly handle arguments with keyword names tsickle emits uncompilable code for parameter named "interface" Mar 15, 2018
@mprobst
Copy link
Collaborator

@mprobst mprobst commented Mar 15, 2018

@mprobst
Copy link
Collaborator

@mprobst mprobst commented Mar 15, 2018

@evmar
Copy link
Collaborator

@evmar evmar commented Mar 15, 2018

Relevant part of spec:
https://www.ecma-international.org/ecma-262/8.0/index.html#sec-identifiers-static-semantics-early-errors
see "Identifier: IdentifierNamebut not ReservedWord"
curiously, you can have a var named 'yield'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.