-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Avoid confusing TS9025 error in isolatedDeclarations
#60129
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 2 commits into
microsoft:main
from
Andarist:avoid-confusing-has-to-include-undefined
Oct 11, 2024
+279
−1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/isolatedDeclarationsAddUndefined2.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,48 @@ | ||
isolatedDeclarationsAddUndefined2.ts(4,29): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
isolatedDeclarationsAddUndefined2.ts(8,29): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
isolatedDeclarationsAddUndefined2.ts(12,28): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
isolatedDeclarationsAddUndefined2.ts(16,28): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
isolatedDeclarationsAddUndefined2.ts(19,27): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
isolatedDeclarationsAddUndefined2.ts(21,27): error TS2304: Cannot find name 'Unresolved'. | ||
isolatedDeclarationsAddUndefined2.ts(23,27): error TS2304: Cannot find name 'Unresolved'. | ||
|
||
|
||
==== isolatedDeclarationsAddUndefined2.ts (7 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
|
||
export class Bar { | ||
constructor(private x?: Array | undefined) {} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
} | ||
|
||
export class Bar2 { | ||
constructor(private x?: Array) {} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
} | ||
|
||
export class Bar3 { | ||
constructor(private x: Array | undefined) {} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
} | ||
|
||
export class Bar4 { | ||
constructor(private x: Array) {} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
} | ||
|
||
export function test1(x?: Array | undefined): void {} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
|
||
export function test2(x?: Unresolved | undefined): void {} | ||
~~~~~~~~~~ | ||
!!! error TS2304: Cannot find name 'Unresolved'. | ||
|
||
export function test3(x?: Unresolved): void {} | ||
~~~~~~~~~~ | ||
!!! error TS2304: Cannot find name 'Unresolved'. | ||
|
89 changes: 89 additions & 0 deletions
89
tests/baselines/reference/isolatedDeclarationsAddUndefined2.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,89 @@ | ||
//// [tests/cases/compiler/isolatedDeclarationsAddUndefined2.ts] //// | ||
|
||
//// [isolatedDeclarationsAddUndefined2.ts] | ||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
|
||
export class Bar { | ||
constructor(private x?: Array | undefined) {} | ||
} | ||
|
||
export class Bar2 { | ||
constructor(private x?: Array) {} | ||
} | ||
|
||
export class Bar3 { | ||
constructor(private x: Array | undefined) {} | ||
} | ||
|
||
export class Bar4 { | ||
constructor(private x: Array) {} | ||
} | ||
|
||
export function test1(x?: Array | undefined): void {} | ||
|
||
export function test2(x?: Unresolved | undefined): void {} | ||
|
||
export function test3(x?: Unresolved): void {} | ||
|
||
|
||
//// [isolatedDeclarationsAddUndefined2.js] | ||
"use strict"; | ||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Bar4 = exports.Bar3 = exports.Bar2 = exports.Bar = void 0; | ||
exports.test1 = test1; | ||
exports.test2 = test2; | ||
exports.test3 = test3; | ||
var Bar = /** @class */ (function () { | ||
function Bar(x) { | ||
this.x = x; | ||
} | ||
return Bar; | ||
}()); | ||
exports.Bar = Bar; | ||
var Bar2 = /** @class */ (function () { | ||
function Bar2(x) { | ||
this.x = x; | ||
} | ||
return Bar2; | ||
}()); | ||
exports.Bar2 = Bar2; | ||
var Bar3 = /** @class */ (function () { | ||
function Bar3(x) { | ||
this.x = x; | ||
} | ||
return Bar3; | ||
}()); | ||
exports.Bar3 = Bar3; | ||
var Bar4 = /** @class */ (function () { | ||
function Bar4(x) { | ||
this.x = x; | ||
} | ||
return Bar4; | ||
}()); | ||
exports.Bar4 = Bar4; | ||
function test1(x) { } | ||
function test2(x) { } | ||
function test3(x) { } | ||
|
||
|
||
//// [isolatedDeclarationsAddUndefined2.d.ts] | ||
export declare class Bar { | ||
private x?; | ||
constructor(x?: Array | undefined); | ||
} | ||
export declare class Bar2 { | ||
private x?; | ||
constructor(x?: Array); | ||
} | ||
export declare class Bar3 { | ||
private x; | ||
constructor(x: Array | undefined); | ||
} | ||
export declare class Bar4 { | ||
private x; | ||
constructor(x: Array); | ||
} | ||
export declare function test1(x?: Array | undefined): void; | ||
export declare function test2(x?: Unresolved | undefined): void; | ||
export declare function test3(x?: Unresolved): void; |
52 changes: 52 additions & 0 deletions
52
tests/baselines/reference/isolatedDeclarationsAddUndefined2.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,52 @@ | ||
//// [tests/cases/compiler/isolatedDeclarationsAddUndefined2.ts] //// | ||
|
||
=== isolatedDeclarationsAddUndefined2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
|
||
export class Bar { | ||
>Bar : Symbol(Bar, Decl(isolatedDeclarationsAddUndefined2.ts, 0, 0)) | ||
|
||
constructor(private x?: Array | undefined) {} | ||
>x : Symbol(Bar.x, Decl(isolatedDeclarationsAddUndefined2.ts, 3, 16)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
} | ||
|
||
export class Bar2 { | ||
>Bar2 : Symbol(Bar2, Decl(isolatedDeclarationsAddUndefined2.ts, 4, 1)) | ||
|
||
constructor(private x?: Array) {} | ||
>x : Symbol(Bar2.x, Decl(isolatedDeclarationsAddUndefined2.ts, 7, 16)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
} | ||
|
||
export class Bar3 { | ||
>Bar3 : Symbol(Bar3, Decl(isolatedDeclarationsAddUndefined2.ts, 8, 1)) | ||
|
||
constructor(private x: Array | undefined) {} | ||
>x : Symbol(Bar3.x, Decl(isolatedDeclarationsAddUndefined2.ts, 11, 16)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
} | ||
|
||
export class Bar4 { | ||
>Bar4 : Symbol(Bar4, Decl(isolatedDeclarationsAddUndefined2.ts, 12, 1)) | ||
|
||
constructor(private x: Array) {} | ||
>x : Symbol(Bar4.x, Decl(isolatedDeclarationsAddUndefined2.ts, 15, 16)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
} | ||
|
||
export function test1(x?: Array | undefined): void {} | ||
>test1 : Symbol(test1, Decl(isolatedDeclarationsAddUndefined2.ts, 16, 1)) | ||
>x : Symbol(x, Decl(isolatedDeclarationsAddUndefined2.ts, 18, 22)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
export function test2(x?: Unresolved | undefined): void {} | ||
>test2 : Symbol(test2, Decl(isolatedDeclarationsAddUndefined2.ts, 18, 53)) | ||
>x : Symbol(x, Decl(isolatedDeclarationsAddUndefined2.ts, 20, 22)) | ||
>Unresolved : Symbol(Unresolved) | ||
|
||
export function test3(x?: Unresolved): void {} | ||
>test3 : Symbol(test3, Decl(isolatedDeclarationsAddUndefined2.ts, 20, 58)) | ||
>x : Symbol(x, Decl(isolatedDeclarationsAddUndefined2.ts, 22, 22)) | ||
>Unresolved : Symbol(Unresolved) | ||
|
59 changes: 59 additions & 0 deletions
59
tests/baselines/reference/isolatedDeclarationsAddUndefined2.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,59 @@ | ||
//// [tests/cases/compiler/isolatedDeclarationsAddUndefined2.ts] //// | ||
|
||
=== isolatedDeclarationsAddUndefined2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
|
||
export class Bar { | ||
>Bar : Bar | ||
> : ^^^ | ||
|
||
constructor(private x?: Array | undefined) {} | ||
>x : any | ||
> : ^^^ | ||
} | ||
|
||
export class Bar2 { | ||
>Bar2 : Bar2 | ||
> : ^^^^ | ||
|
||
constructor(private x?: Array) {} | ||
>x : any | ||
> : ^^^ | ||
} | ||
|
||
export class Bar3 { | ||
>Bar3 : Bar3 | ||
> : ^^^^ | ||
|
||
constructor(private x: Array | undefined) {} | ||
>x : any | ||
> : ^^^ | ||
} | ||
|
||
export class Bar4 { | ||
>Bar4 : Bar4 | ||
> : ^^^^ | ||
|
||
constructor(private x: Array) {} | ||
>x : any | ||
> : ^^^ | ||
} | ||
|
||
export function test1(x?: Array | undefined): void {} | ||
>test1 : (x?: Array | undefined) => void | ||
> : ^ ^^^ ^^^^^ | ||
>x : any | ||
> : ^^^ | ||
|
||
export function test2(x?: Unresolved | undefined): void {} | ||
>test2 : (x?: Unresolved | undefined) => void | ||
> : ^ ^^^ ^^^^^ | ||
>x : any | ||
> : ^^^ | ||
|
||
export function test3(x?: Unresolved): void {} | ||
>test3 : (x?: any) => void | ||
> : ^ ^^^^^^^^^^^ | ||
>x : any | ||
> : ^^^ | ||
|
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,27 @@ | ||
// @isolatedDeclarations: true | ||
// @declaration: true | ||
// @strict: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/60123 | ||
|
||
export class Bar { | ||
constructor(private x?: Array | undefined) {} | ||
} | ||
|
||
export class Bar2 { | ||
constructor(private x?: Array) {} | ||
} | ||
|
||
export class Bar3 { | ||
constructor(private x: Array | undefined) {} | ||
} | ||
|
||
export class Bar4 { | ||
constructor(private x: Array) {} | ||
} | ||
|
||
export function test1(x?: Array | undefined): void {} | ||
|
||
export function test2(x?: Unresolved | undefined): void {} | ||
|
||
export function test3(x?: Unresolved): void {} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this extra test would be valuable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, i just pushed it out