Skip to content

Readonly in declaration files (part 2)#6702

Merged
ahejlsberg merged 3 commits into
masterfrom
readonlyInDeclarationFiles2
Jan 28, 2016
Merged

Readonly in declaration files (part 2)#6702
ahejlsberg merged 3 commits into
masterfrom
readonlyInDeclarationFiles2

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

Augments #6697 to emit readonly modifier in declaration file for get-only accessors in classes.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jan 28, 2016

👍

1 similar comment
@DanielRosenwasser
Copy link
Copy Markdown
Member

👍

ahejlsberg added a commit that referenced this pull request Jan 28, 2016
@ahejlsberg ahejlsberg merged commit cb6dd18 into master Jan 28, 2016
@ahejlsberg ahejlsberg deleted the readonlyInDeclarationFiles2 branch January 28, 2016 21:56
@jkillian
Copy link
Copy Markdown

I'm concerned that this creates .d.ts files that are non-backwards compatible with versions of tsc introduced before readonly support.

As an example, we had a class with some get-only accessors as part of a library we use internally, and we started compiling the library with typescript@next. This broke usage by internal applications that were still using the TS 1.8.x line, because they couldn't consume the new typings.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Apr 15, 2016

@jkillian would adding an empty setter to the source class be a problem?

@jkillian
Copy link
Copy Markdown

@mhegazy That could be a good work around, or just changing the accessor to a regular method could work for us as well.

Really, just wanted to mention this because it was a surprising back-compat issue and I wasn't sure if it was intended or not.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Apr 15, 2016

Thanks @jkillian, this is not the first time we got this feedback, I will bring this up in the next design meeting.

@jkillian
Copy link
Copy Markdown

Sounds good. I think this case would be solved nicely in a way similar to that mentioned here: that is, a "typingsTarget" option of some sort that lets you emit typings that will be compatible with older versions of the compiler. Of course, I don't know the complexity or difficulties of that, I'll happily work with whatever you all decide.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Apr 22, 2016

looping back, we are sorry we did not catch this issue as part of implementing the readonly properties. moving forward we will be more cognizant of adding new syntax to generated .d.ts files for new features.

it seems there is no clean solution for this issue, that does not involve yet another compiler flag. we would recommend either adding an empty setter or using a post build script to remove the reference to readonly for now. again sorry for the inconvenience, and we will add dts compat to our new feature checklist in the feature.

chrisnicola added a commit to WealthBar/a2d3 that referenced this pull request May 3, 2016
1.9 has a breaking change in the way it generates d.ts files that is not
backwards compatible to 1.8.

microsoft/TypeScript#6702
@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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants