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

bug(d.ts): does not allow simple computed properties on declared classes #5114

Closed
EisenbergEffect opened this issue Oct 5, 2015 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@EisenbergEffect
Copy link

The error "A computed property name in an ambient context must directly refer to a built-in symbol." is produced by the following code in the aurelia-templating-binding.d.ts file.

declare module 'aurelia-templating-binding' {
  export class SyntaxInterpreter {
    ['one-time'](resources: any, element: any, info: any, existingInstruction: any): any;
  }
}

This code works fine in the TypeScript playground when used normally in a class, but not inside a declaration. This is a problem for us since it means we can't generate complete d.ts files for our api and also cannot generate the docs (which are based on the d.ts files).

@RyanCavanaugh
Copy link
Member

I think you want to write this instead:

declare module 'aurelia-templating-binding' {
  export class SyntaxInterpreter {
    'one-time'(resources: any, element: any, info: any, existingInstruction: any): any;
  }
}

The bracketed syntax shouldn't be used for statically-named things

@EisenbergEffect
Copy link
Author

@RyanCavanaugh Is that a TypeScript-specific syntax rule? because it is valid ES6. Can you emit the brackets with ES6 too? or is this a divergence between ES6 and TypeScript.

@weswigham
Copy link
Member

Actually method declaration with a string without square brackets is still valid es6, but not supporting square brackets in type definitions for any other primitives than symbols is a known limitation and has been discussed in #4653 (most recently, AFAIK).

@danquirk
Copy link
Member

danquirk commented Oct 5, 2015

Yeah I think we can close this as a dupe

@danquirk danquirk closed this as completed Oct 5, 2015
@danquirk danquirk added the Duplicate An existing issue was already created label Oct 5, 2015
@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

4 participants