Fixed crash related to creating file diagnostics outside of the source file range in checkPotentialUncheckedRenamedBindingElementsInTypes (#59428)

This commit is contained in:
Mateusz Burzyński 2024-07-29 13:31:16 -07:00 committed by GitHub
parent 2daa5027a3
commit 68648256f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 140 additions and 1 deletions

View File

@ -43552,7 +43552,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// entire parameter does not have type annotation, suggest adding an annotation
addRelatedInfo(
diagnostic,
createFileDiagnostic(getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, declarationNameToString(node.propertyName)),
createFileDiagnostic(getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 0, Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, declarationNameToString(node.propertyName)),
);
}
diagnostics.add(diagnostic);

View File

@ -0,0 +1,42 @@
parametersSyntaxErrorNoCrash1.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration.
parametersSyntaxErrorNoCrash1.ts(3,10): error TS7010: 'identity', which lacks return-type annotation, implicitly has an 'any' return type.
parametersSyntaxErrorNoCrash1.ts(3,22): error TS2300: Duplicate identifier 'arg'.
parametersSyntaxErrorNoCrash1.ts(3,28): error TS1005: ',' expected.
parametersSyntaxErrorNoCrash1.ts(3,30): error TS7006: Parameter 'T' implicitly has an 'any' type.
parametersSyntaxErrorNoCrash1.ts(3,32): error TS1005: ',' expected.
parametersSyntaxErrorNoCrash1.ts(4,12): error TS1005: ':' expected.
parametersSyntaxErrorNoCrash1.ts(4,12): error TS2300: Duplicate identifier 'arg'.
parametersSyntaxErrorNoCrash1.ts(4,12): error TS2842: 'arg' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
parametersSyntaxErrorNoCrash1.ts(4,15): error TS1005: ',' expected.
parametersSyntaxErrorNoCrash1.ts(5,2): error TS1005: ')' expected.
==== parametersSyntaxErrorNoCrash1.ts (11 errors) ====
// https://github.com/microsoft/TypeScript/issues/59422
function identity<T>(arg: T: T {
~~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
~~~~~~~~
!!! error TS7010: 'identity', which lacks return-type annotation, implicitly has an 'any' return type.
~~~
!!! error TS2300: Duplicate identifier 'arg'.
~
!!! error TS1005: ',' expected.
~
!!! error TS7006: Parameter 'T' implicitly has an 'any' type.
~
!!! error TS1005: ',' expected.
return arg;
~~~
!!! error TS1005: ':' expected.
~~~
!!! error TS2300: Duplicate identifier 'arg'.
~~~
!!! error TS2842: 'arg' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
!!! related TS2843 parametersSyntaxErrorNoCrash1.ts:5:2: We can only write a type for 'return' by adding a type for the entire parameter here.
~
!!! error TS1005: ',' expected.
}
!!! error TS1005: ')' expected.

View File

@ -0,0 +1,35 @@
parametersSyntaxErrorNoCrash2.ts(3,25): error TS2391: Function implementation is missing or not immediately following the declaration.
parametersSyntaxErrorNoCrash2.ts(3,25): error TS7010: 'getThing', which lacks return-type annotation, implicitly has an 'any' return type.
parametersSyntaxErrorNoCrash2.ts(3,43): error TS2300: Duplicate identifier '(Missing)'.
parametersSyntaxErrorNoCrash2.ts(3,43): error TS2842: '(Missing)' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
parametersSyntaxErrorNoCrash2.ts(3,44): error TS1005: ':' expected.
parametersSyntaxErrorNoCrash2.ts(3,51): error TS2300: Duplicate identifier '(Missing)'.
parametersSyntaxErrorNoCrash2.ts(3,51): error TS2842: '(Missing)' is an unused renaming of ''thing''. Did you intend to use it as a type annotation?
parametersSyntaxErrorNoCrash2.ts(3,51): error TS1005: ':' expected.
parametersSyntaxErrorNoCrash2.ts(3,54): error TS1005: ')' expected.
==== parametersSyntaxErrorNoCrash2.ts (9 errors) ====
// https://github.com/microsoft/TypeScript/issues/59353
export default function getThing( { return 'thing'; }
~~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
~~~~~~~~
!!! error TS7010: 'getThing', which lacks return-type annotation, implicitly has an 'any' return type.
!!! error TS2300: Duplicate identifier '(Missing)'.
!!! error TS2842: '(Missing)' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
!!! related TS2843 parametersSyntaxErrorNoCrash2.ts:3:54: We can only write a type for 'return' by adding a type for the entire parameter here.
~~~~~~~
!!! error TS1005: ':' expected.
!!! error TS2300: Duplicate identifier '(Missing)'.
!!! error TS2842: '(Missing)' is an unused renaming of ''thing''. Did you intend to use it as a type annotation?
!!! related TS2843 parametersSyntaxErrorNoCrash2.ts:3:54: We can only write a type for ''thing'' by adding a type for the entire parameter here.
~
!!! error TS1005: ':' expected.
!!! error TS1005: ')' expected.

View File

@ -0,0 +1,37 @@
parametersSyntaxErrorNoCrash3.ts(3,17): error TS2391: Function implementation is missing or not immediately following the declaration.
parametersSyntaxErrorNoCrash3.ts(3,17): error TS7010: 'getHtml', which lacks return-type annotation, implicitly has an 'any' return type.
parametersSyntaxErrorNoCrash3.ts(4,11): error TS2300: Duplicate identifier '(Missing)'.
parametersSyntaxErrorNoCrash3.ts(4,11): error TS2842: '(Missing)' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
parametersSyntaxErrorNoCrash3.ts(4,13): error TS1005: ':' expected.
parametersSyntaxErrorNoCrash3.ts(4,22): error TS2300: Duplicate identifier '(Missing)'.
parametersSyntaxErrorNoCrash3.ts(4,22): error TS2842: '(Missing)' is an unused renaming of '" string"'. Did you intend to use it as a type annotation?
parametersSyntaxErrorNoCrash3.ts(5,1): error TS1005: ':' expected.
parametersSyntaxErrorNoCrash3.ts(5,2): error TS1005: ')' expected.
==== parametersSyntaxErrorNoCrash3.ts (9 errors) ====
// https://github.com/microsoft/TypeScript/issues/59449
export function getHtml({
~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
~~~~~~~
!!! error TS7010: 'getHtml', which lacks return-type annotation, implicitly has an 'any' return type.
return " string" // a long string;
!!! error TS2300: Duplicate identifier '(Missing)'.
!!! error TS2842: '(Missing)' is an unused renaming of 'return'. Did you intend to use it as a type annotation?
!!! related TS2843 parametersSyntaxErrorNoCrash3.ts:5:2: We can only write a type for 'return' by adding a type for the entire parameter here.
~~~~~~~~~
!!! error TS1005: ':' expected.
!!! error TS2300: Duplicate identifier '(Missing)'.
!!! error TS2842: '(Missing)' is an unused renaming of '" string"'. Did you intend to use it as a type annotation?
!!! related TS2843 parametersSyntaxErrorNoCrash3.ts:5:2: We can only write a type for '" string"' by adding a type for the entire parameter here.
}
~
!!! error TS1005: ':' expected.
!!! error TS1005: ')' expected.

View File

@ -0,0 +1,9 @@
// @strict: true
// @noEmit: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/59422
function identity<T>(arg: T: T {
return arg;
}

View File

@ -0,0 +1,7 @@
// @strict: true
// @noEmit: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/59353
export default function getThing( { return 'thing'; }

View File

@ -0,0 +1,9 @@
// @strict: true
// @noEmit: true
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/59449
export function getHtml({
return " string" // a long string;
}