-
Notifications
You must be signed in to change notification settings - Fork 717
Fix: Remove definite assignment assertions from class property declaration files #1751
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
Merged
jakebailey
merged 7 commits into
main
from
copilot/fix-e75565ee-d32e-4143-97a5-3fa1a505dd1a
Sep 25, 2025
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a4674b
Initial plan
Copilot 53d08bf
Initial test case for definite assignment assertion issue
Copilot 0025519
Fix: Remove definite assignment assertions from declaration files
Copilot d8d0781
Simplify definite assignment assertion removal logic
Copilot 7e59ec3
Refactor: Extract helper function to remove code duplication
Copilot cd2565a
Remove newly added tests - existing tests already cover the functiona…
Copilot cce82fd
Remove helper function call for property signatures - they can't have…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
testdata/baselines/reference/compiler/definiteAssignmentAssertionInDeclaration.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclaration.ts] //// | ||
|
||
//// [definiteAssignmentAssertionInDeclaration.ts] | ||
export class DbObject { | ||
id!: string; | ||
} | ||
|
||
//// [definiteAssignmentAssertionInDeclaration.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DbObject = void 0; | ||
class DbObject { | ||
id; | ||
} | ||
exports.DbObject = DbObject; | ||
|
||
|
||
//// [definiteAssignmentAssertionInDeclaration.d.ts] | ||
export declare class DbObject { | ||
id: string; | ||
} |
9 changes: 9 additions & 0 deletions
9
testdata/baselines/reference/compiler/definiteAssignmentAssertionInDeclaration.symbols
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclaration.ts] //// | ||
|
||
=== definiteAssignmentAssertionInDeclaration.ts === | ||
export class DbObject { | ||
>DbObject : Symbol(DbObject, Decl(definiteAssignmentAssertionInDeclaration.ts, 0, 0)) | ||
|
||
id!: string; | ||
>id : Symbol(DbObject.id, Decl(definiteAssignmentAssertionInDeclaration.ts, 0, 23)) | ||
} |
9 changes: 9 additions & 0 deletions
9
testdata/baselines/reference/compiler/definiteAssignmentAssertionInDeclaration.types
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclaration.ts] //// | ||
|
||
=== definiteAssignmentAssertionInDeclaration.ts === | ||
export class DbObject { | ||
>DbObject : DbObject | ||
|
||
id!: string; | ||
>id : string | ||
} |
19 changes: 19 additions & 0 deletions
19
.../baselines/reference/compiler/definiteAssignmentAssertionInDeclarationExtended.errors.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
definiteAssignmentAssertionInDeclarationExtended.ts(7,18): error TS1255: A definite assignment assertion '!' is not permitted in this context. | ||
|
||
|
||
==== definiteAssignmentAssertionInDeclarationExtended.ts (1 errors) ==== | ||
export class DbObject { | ||
id!: string; | ||
name?: string; | ||
count: number = 0; | ||
private secret!: string; | ||
protected value!: number; | ||
static config!: boolean; | ||
~ | ||
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context. | ||
} | ||
|
||
export interface IConfig { | ||
setting?: boolean; | ||
optionalSetting?: string; | ||
} |
45 changes: 45 additions & 0 deletions
45
testdata/baselines/reference/compiler/definiteAssignmentAssertionInDeclarationExtended.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclarationExtended.ts] //// | ||
|
||
//// [definiteAssignmentAssertionInDeclarationExtended.ts] | ||
export class DbObject { | ||
id!: string; | ||
name?: string; | ||
count: number = 0; | ||
private secret!: string; | ||
protected value!: number; | ||
static config!: boolean; | ||
} | ||
|
||
export interface IConfig { | ||
setting?: boolean; | ||
optionalSetting?: string; | ||
} | ||
|
||
//// [definiteAssignmentAssertionInDeclarationExtended.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DbObject = void 0; | ||
class DbObject { | ||
id; | ||
name; | ||
count = 0; | ||
secret; | ||
value; | ||
static config; | ||
} | ||
exports.DbObject = DbObject; | ||
|
||
|
||
//// [definiteAssignmentAssertionInDeclarationExtended.d.ts] | ||
export declare class DbObject { | ||
id: string; | ||
name?: string; | ||
count: number; | ||
private secret; | ||
protected value: number; | ||
static config: boolean; | ||
} | ||
export interface IConfig { | ||
setting?: boolean; | ||
optionalSetting?: string; | ||
} |
34 changes: 34 additions & 0 deletions
34
...ata/baselines/reference/compiler/definiteAssignmentAssertionInDeclarationExtended.symbols
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclarationExtended.ts] //// | ||
|
||
=== definiteAssignmentAssertionInDeclarationExtended.ts === | ||
export class DbObject { | ||
>DbObject : Symbol(DbObject, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 0, 0)) | ||
|
||
id!: string; | ||
>id : Symbol(DbObject.id, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 0, 23)) | ||
|
||
name?: string; | ||
>name : Symbol(DbObject.name, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 1, 16)) | ||
|
||
count: number = 0; | ||
>count : Symbol(DbObject.count, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 2, 18)) | ||
|
||
private secret!: string; | ||
>secret : Symbol(DbObject.secret, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 3, 22)) | ||
|
||
protected value!: number; | ||
>value : Symbol(DbObject.value, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 4, 28)) | ||
|
||
static config!: boolean; | ||
>config : Symbol(DbObject.config, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 5, 29)) | ||
} | ||
|
||
export interface IConfig { | ||
>IConfig : Symbol(IConfig, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 7, 1)) | ||
|
||
setting?: boolean; | ||
>setting : Symbol(IConfig.setting, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 9, 26)) | ||
|
||
optionalSetting?: string; | ||
>optionalSetting : Symbol(IConfig.optionalSetting, Decl(definiteAssignmentAssertionInDeclarationExtended.ts, 10, 22)) | ||
} |
33 changes: 33 additions & 0 deletions
33
testdata/baselines/reference/compiler/definiteAssignmentAssertionInDeclarationExtended.types
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//// [tests/cases/compiler/definiteAssignmentAssertionInDeclarationExtended.ts] //// | ||
|
||
=== definiteAssignmentAssertionInDeclarationExtended.ts === | ||
export class DbObject { | ||
>DbObject : DbObject | ||
|
||
id!: string; | ||
>id : string | ||
|
||
name?: string; | ||
>name : string | undefined | ||
|
||
count: number = 0; | ||
>count : number | ||
>0 : 0 | ||
|
||
private secret!: string; | ||
>secret : string | ||
|
||
protected value!: number; | ||
>value : number | ||
|
||
static config!: boolean; | ||
>config : boolean | ||
} | ||
|
||
export interface IConfig { | ||
setting?: boolean; | ||
>setting : boolean | undefined | ||
|
||
optionalSetting?: string; | ||
>optionalSetting : string | undefined | ||
} |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ void type; // Ok | |
|
||
//// [a.d.ts] | ||
declare class A { | ||
a!: string; | ||
a: string; | ||
} | ||
export = A; | ||
//// [b.d.ts] | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.