Skip to content

Default values of readonly parameter properties shouldn't have literal types #11409

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
falsandtru opened this issue Oct 6, 2016 · 2 comments
Closed
Labels
Bug A bug in TypeScript
Milestone

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Oct 6, 2016

TypeScript Version: master

Code

new class {
  constructor(
    n = 1,
    public readonly m = 2
  ) {}
}(3, 4);
$ node built/local/tsc.js -t es6 -m commonjs --noEmit index.ts
index.ts(6,6): error TS2345: Argument of type '4' is not assignable to parameter of type '2'.
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 6, 2016
@falsandtru
Copy link
Contributor Author

I think this issue should be added milestone 2.1.

@RyanCavanaugh RyanCavanaugh added this to the TypeScript 2.1 milestone Oct 26, 2016
@sandersn sandersn changed the title Default parameters shouldn't be inferred to literal types Default values of readonly parameter properties shouldn't be treated as literal types Oct 26, 2016
@sandersn sandersn changed the title Default values of readonly parameter properties shouldn't be treated as literal types Default values of readonly parameter properties shouldn't have literal types Oct 26, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.1.2, Future Oct 27, 2016
@sandersn sandersn removed their assignment Jan 7, 2020
@Andarist
Copy link
Contributor

Andarist commented Jan 8, 2023

@RyanCavanaugh this works OK today, the issue can be closed

@sandersn sandersn closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants