Repository navigation
feat(typescript): allow declare for class properties - #21281
Merged
Dmitry Gozman (dgozman) merged 1 commit intoMar 2, 2023
Merged
Conversation
Pavel Feldman (pavelfeldman)
approved these changes
Mar 1, 2023
Pavel Feldman (pavelfeldman)
approved these changes
Mar 1, 2023
This enables `allowDeclareFields` flag that allows code like:
```ts
class Foo {
declare prop: string;
}
```
Declaring is a workaround for inheritance vs property initialization issues.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier
For `allowDeclareFields` to work, we have to run plugin-transform-typescript
before plugin-proposal-class-properties and few others, so this change
migrates from preset-typescript that always runs last to individual
plugin-transform-typescript, and reorders some plugins.
Dmitry Gozman (dgozman)
force-pushed
the
babel-ts-allow-declare
branch
from
March 1, 2023 23:31
3202003 to
9f12fcf
Compare
Max Schmitt (mxschmitt)
added a commit
to mxschmitt/playwright
that referenced
this pull request
Mar 20, 2023
…soft#21281)" This reverts commit a1ba675.
github-actions Bot
added a commit
that referenced
this pull request
Mar 20, 2023
…ass properties (#21281)"
This was referenced Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This enables
allowDeclareFieldsflag that allows code like:Declaring is a workaround for inheritance vs property initialization issues. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier
For
allowDeclareFieldsto work, we have to run plugin-transform-typescript before plugin-proposal-class-properties and few others, so this change migrates from preset-typescript that always runs last to individual plugin-transform-typescript, and reorders some plugins.References #21119.