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

replace default value int index.d.ts with optional parameters #19

Open
lysz210 opened this issue Sep 9, 2019 · 0 comments
Open

replace default value int index.d.ts with optional parameters #19

lysz210 opened this issue Sep 9, 2019 · 0 comments

Comments

@lysz210
Copy link
Contributor

lysz210 commented Sep 9, 2019

When I first wrote the constructor declarations with defaults, VSCode didn't rais any errors, but after reopen it and declaring interfaces it raised:
A parameter initializer is only allowed in a function or constructor implementation.ts(2371)
VSCode isn't consistent with this notification.

class Point2D {
  // constructor (x: number = 0, y: number = 0)
  // replace with
  constructor (x?: number, y?: number)
}
// all this initialization are good
Point2D p0 = new Point2D() // x and y initialization are handled by the real implementation
Point2D p1 = new Point2D(1) // y initialization is handled by the real implementation
Point2D p2 = new Point2D(1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant