Skip to content

Unstable values of enum SyntaxKind break compatibility with language service plugins #16367

@mvirkkunen

Description

@mvirkkunen

The enum values of SyntaxKind (plus a few smaller enums) in types.ts are not specified as constant values and therefore adding new members between existing ones changes the values of other members. These values end up in tsserverlibrary.d.ts and through that into compiled language service plugins that are published on for instance npm. In a compiled plugin the values will be simple numeric constants from whatever version it was compiled against. Due to this, a language service plugin will probably work incorrectly if the compiler version it's running under is even slightly different from the one it was compiled against.

The edit history of this file looks like members are being added without taking this into account:

https://github.com/Microsoft/TypeScript/blame/d450b8b2ab788d0ca6a22e5202685ac39fc86e9f/src/compiler/types.ts#L50

Even though these values might be semi-internal, I think it would make sense to keep the values stable at least within the same major version in order to not unnecessarily break compatibility with language service plugins. I ran into this problem while playing around with a plugin compiled against the newest version of TypeScript from npm and running it within VS 2017 which apparently has a slightly older version of TypeScript and the enum values are slightly different.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions