mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Visit child nodes in checkExpressionWithTypeArguments (#51804)
* Visit child nodes in checkExpressionWithTypeArguments * Accept new baselines * Add tests
This commit is contained in:
parent
a77a79fe4b
commit
91f89b94e4
@ -33609,6 +33609,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
function checkExpressionWithTypeArguments(node: ExpressionWithTypeArguments | TypeQueryNode) {
|
||||
checkGrammarExpressionWithTypeArguments(node);
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
const exprType = node.kind === SyntaxKind.ExpressionWithTypeArguments ? checkExpression(node.expression) :
|
||||
isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
||||
checkExpression(node.exprName);
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(9,21): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(10,20): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(11,21): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(12,23): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(12,24): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(14,28): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(15,27): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(16,28): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(17,30): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(17,31): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(19,21): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(20,20): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(21,21): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(22,23): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(22,24): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(24,28): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(25,27): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(26,28): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(27,30): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
tests/cases/compiler/expressionWithJSDocTypeArguments.ts(27,31): error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
|
||||
|
||||
==== tests/cases/compiler/expressionWithJSDocTypeArguments.ts (20 errors) ====
|
||||
// Repro from #51802
|
||||
|
||||
function foo<T>(x: T): T { return x }
|
||||
|
||||
class Bar<T> { constructor(public x: T) { } }
|
||||
|
||||
// Errors expected on all of the following
|
||||
|
||||
const WhatFoo = foo<?>;
|
||||
~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const HuhFoo = foo<string?>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const NopeFoo = foo<?string>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const ComeOnFoo = foo<?string?>;
|
||||
~~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
|
||||
type TWhatFoo = typeof foo<?>;
|
||||
~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type THuhFoo = typeof foo<string?>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type TNopeFoo = typeof foo<?string>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type TComeOnFoo = typeof foo<?string?>;
|
||||
~~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
|
||||
const WhatBar = Bar<?>;
|
||||
~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const HuhBar = Bar<string?>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const NopeBar = Bar<?string>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
const ComeOnBar = Bar<?string?>;
|
||||
~~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
|
||||
type TWhatBar = typeof Bar<?>;
|
||||
~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type THuhBar = typeof Bar<string?>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type TNopeBar = typeof Bar<?string>;
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
type TComeOnBar = typeof Bar<?string?>;
|
||||
~~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
~~~~~~~
|
||||
!!! error TS8020: JSDoc types can only be used inside documentation comments.
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
//// [expressionWithJSDocTypeArguments.ts]
|
||||
// Repro from #51802
|
||||
|
||||
function foo<T>(x: T): T { return x }
|
||||
|
||||
class Bar<T> { constructor(public x: T) { } }
|
||||
|
||||
// Errors expected on all of the following
|
||||
|
||||
const WhatFoo = foo<?>;
|
||||
const HuhFoo = foo<string?>;
|
||||
const NopeFoo = foo<?string>;
|
||||
const ComeOnFoo = foo<?string?>;
|
||||
|
||||
type TWhatFoo = typeof foo<?>;
|
||||
type THuhFoo = typeof foo<string?>;
|
||||
type TNopeFoo = typeof foo<?string>;
|
||||
type TComeOnFoo = typeof foo<?string?>;
|
||||
|
||||
const WhatBar = Bar<?>;
|
||||
const HuhBar = Bar<string?>;
|
||||
const NopeBar = Bar<?string>;
|
||||
const ComeOnBar = Bar<?string?>;
|
||||
|
||||
type TWhatBar = typeof Bar<?>;
|
||||
type THuhBar = typeof Bar<string?>;
|
||||
type TNopeBar = typeof Bar<?string>;
|
||||
type TComeOnBar = typeof Bar<?string?>;
|
||||
|
||||
|
||||
//// [expressionWithJSDocTypeArguments.js]
|
||||
"use strict";
|
||||
// Repro from #51802
|
||||
function foo(x) { return x; }
|
||||
var Bar = /** @class */ (function () {
|
||||
function Bar(x) {
|
||||
this.x = x;
|
||||
}
|
||||
return Bar;
|
||||
}());
|
||||
// Errors expected on all of the following
|
||||
var WhatFoo = foo<?>;
|
||||
var HuhFoo = foo<?string>;
|
||||
var NopeFoo = foo<?string>;
|
||||
var ComeOnFoo = foo<??string>;
|
||||
var WhatBar = Bar<?>;
|
||||
var HuhBar = Bar<?string>;
|
||||
var NopeBar = Bar<?string>;
|
||||
var ComeOnBar = Bar<??string>;
|
||||
@ -0,0 +1,83 @@
|
||||
=== tests/cases/compiler/expressionWithJSDocTypeArguments.ts ===
|
||||
// Repro from #51802
|
||||
|
||||
function foo<T>(x: T): T { return x }
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(expressionWithJSDocTypeArguments.ts, 2, 13))
|
||||
>x : Symbol(x, Decl(expressionWithJSDocTypeArguments.ts, 2, 16))
|
||||
>T : Symbol(T, Decl(expressionWithJSDocTypeArguments.ts, 2, 13))
|
||||
>T : Symbol(T, Decl(expressionWithJSDocTypeArguments.ts, 2, 13))
|
||||
>x : Symbol(x, Decl(expressionWithJSDocTypeArguments.ts, 2, 16))
|
||||
|
||||
class Bar<T> { constructor(public x: T) { } }
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
>T : Symbol(T, Decl(expressionWithJSDocTypeArguments.ts, 4, 10))
|
||||
>x : Symbol(Bar.x, Decl(expressionWithJSDocTypeArguments.ts, 4, 27))
|
||||
>T : Symbol(T, Decl(expressionWithJSDocTypeArguments.ts, 4, 10))
|
||||
|
||||
// Errors expected on all of the following
|
||||
|
||||
const WhatFoo = foo<?>;
|
||||
>WhatFoo : Symbol(WhatFoo, Decl(expressionWithJSDocTypeArguments.ts, 8, 5))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
const HuhFoo = foo<string?>;
|
||||
>HuhFoo : Symbol(HuhFoo, Decl(expressionWithJSDocTypeArguments.ts, 9, 5))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
const NopeFoo = foo<?string>;
|
||||
>NopeFoo : Symbol(NopeFoo, Decl(expressionWithJSDocTypeArguments.ts, 10, 5))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
const ComeOnFoo = foo<?string?>;
|
||||
>ComeOnFoo : Symbol(ComeOnFoo, Decl(expressionWithJSDocTypeArguments.ts, 11, 5))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
type TWhatFoo = typeof foo<?>;
|
||||
>TWhatFoo : Symbol(TWhatFoo, Decl(expressionWithJSDocTypeArguments.ts, 11, 32))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
type THuhFoo = typeof foo<string?>;
|
||||
>THuhFoo : Symbol(THuhFoo, Decl(expressionWithJSDocTypeArguments.ts, 13, 30))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
type TNopeFoo = typeof foo<?string>;
|
||||
>TNopeFoo : Symbol(TNopeFoo, Decl(expressionWithJSDocTypeArguments.ts, 14, 35))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
type TComeOnFoo = typeof foo<?string?>;
|
||||
>TComeOnFoo : Symbol(TComeOnFoo, Decl(expressionWithJSDocTypeArguments.ts, 15, 36))
|
||||
>foo : Symbol(foo, Decl(expressionWithJSDocTypeArguments.ts, 0, 0))
|
||||
|
||||
const WhatBar = Bar<?>;
|
||||
>WhatBar : Symbol(WhatBar, Decl(expressionWithJSDocTypeArguments.ts, 18, 5))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
const HuhBar = Bar<string?>;
|
||||
>HuhBar : Symbol(HuhBar, Decl(expressionWithJSDocTypeArguments.ts, 19, 5))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
const NopeBar = Bar<?string>;
|
||||
>NopeBar : Symbol(NopeBar, Decl(expressionWithJSDocTypeArguments.ts, 20, 5))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
const ComeOnBar = Bar<?string?>;
|
||||
>ComeOnBar : Symbol(ComeOnBar, Decl(expressionWithJSDocTypeArguments.ts, 21, 5))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
type TWhatBar = typeof Bar<?>;
|
||||
>TWhatBar : Symbol(TWhatBar, Decl(expressionWithJSDocTypeArguments.ts, 21, 32))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
type THuhBar = typeof Bar<string?>;
|
||||
>THuhBar : Symbol(THuhBar, Decl(expressionWithJSDocTypeArguments.ts, 23, 30))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
type TNopeBar = typeof Bar<?string>;
|
||||
>TNopeBar : Symbol(TNopeBar, Decl(expressionWithJSDocTypeArguments.ts, 24, 35))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
type TComeOnBar = typeof Bar<?string?>;
|
||||
>TComeOnBar : Symbol(TComeOnBar, Decl(expressionWithJSDocTypeArguments.ts, 25, 36))
|
||||
>Bar : Symbol(Bar, Decl(expressionWithJSDocTypeArguments.ts, 2, 37))
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
=== tests/cases/compiler/expressionWithJSDocTypeArguments.ts ===
|
||||
// Repro from #51802
|
||||
|
||||
function foo<T>(x: T): T { return x }
|
||||
>foo : <T>(x: T) => T
|
||||
>x : T
|
||||
>x : T
|
||||
|
||||
class Bar<T> { constructor(public x: T) { } }
|
||||
>Bar : Bar<T>
|
||||
>x : T
|
||||
|
||||
// Errors expected on all of the following
|
||||
|
||||
const WhatFoo = foo<?>;
|
||||
>WhatFoo : (x: any) => any
|
||||
>foo<?> : (x: any) => any
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
const HuhFoo = foo<string?>;
|
||||
>HuhFoo : (x: string | null) => string | null
|
||||
>foo<string?> : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
const NopeFoo = foo<?string>;
|
||||
>NopeFoo : (x: string | null) => string | null
|
||||
>foo<?string> : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
const ComeOnFoo = foo<?string?>;
|
||||
>ComeOnFoo : (x: string | null) => string | null
|
||||
>foo<?string?> : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
type TWhatFoo = typeof foo<?>;
|
||||
>TWhatFoo : (x: any) => any
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
type THuhFoo = typeof foo<string?>;
|
||||
>THuhFoo : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
type TNopeFoo = typeof foo<?string>;
|
||||
>TNopeFoo : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
type TComeOnFoo = typeof foo<?string?>;
|
||||
>TComeOnFoo : (x: string | null) => string | null
|
||||
>foo : <T>(x: T) => T
|
||||
|
||||
const WhatBar = Bar<?>;
|
||||
>WhatBar : { new (x: any): Bar<any>; prototype: Bar<any>; }
|
||||
>Bar<?> : { new (x: any): Bar<any>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
const HuhBar = Bar<string?>;
|
||||
>HuhBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar<string?> : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
const NopeBar = Bar<?string>;
|
||||
>NopeBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar<?string> : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
const ComeOnBar = Bar<?string?>;
|
||||
>ComeOnBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar<?string?> : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
type TWhatBar = typeof Bar<?>;
|
||||
>TWhatBar : { new (x: any): Bar<any>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
type THuhBar = typeof Bar<string?>;
|
||||
>THuhBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
type TNopeBar = typeof Bar<?string>;
|
||||
>TNopeBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
type TComeOnBar = typeof Bar<?string?>;
|
||||
>TComeOnBar : { new (x: string | null): Bar<string | null>; prototype: Bar<any>; }
|
||||
>Bar : typeof Bar
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
tests/cases/conformance/types/import/importWithTypeArguments.ts(1,1): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.
|
||||
tests/cases/conformance/types/import/importWithTypeArguments.ts(1,8): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/types/import/importWithTypeArguments.ts(2,11): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/import/importWithTypeArguments.ts (2 errors) ====
|
||||
==== tests/cases/conformance/types/import/importWithTypeArguments.ts (3 errors) ====
|
||||
import<T>
|
||||
~~~~~~~~~
|
||||
!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
const a = import<string, number>
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.
|
||||
|
||||
@ -4,12 +4,14 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,4): error TS1477: An instantiation expression cannot be followed by a property access.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,5): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,4): error TS1477: An instantiation expression cannot be followed by a property access.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,5): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (9 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (11 errors) ====
|
||||
Foo<T>();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
@ -25,11 +27,15 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
~~~
|
||||
!!! error TS1477: An instantiation expression cannot be followed by a property access.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
Foo<T>.Bar<T>();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
~~~
|
||||
!!! error TS1477: An instantiation expression cannot be followed by a property access.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,15): error TS2304: Cannot find name 'A'.
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,17): error TS2304: Cannot find name 'B'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts (2 errors) ====
|
||||
var v: typeof A<B>
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'B'.
|
||||
29
tests/cases/compiler/expressionWithJSDocTypeArguments.ts
Normal file
29
tests/cases/compiler/expressionWithJSDocTypeArguments.ts
Normal file
@ -0,0 +1,29 @@
|
||||
// @strict: true
|
||||
|
||||
// Repro from #51802
|
||||
|
||||
function foo<T>(x: T): T { return x }
|
||||
|
||||
class Bar<T> { constructor(public x: T) { } }
|
||||
|
||||
// Errors expected on all of the following
|
||||
|
||||
const WhatFoo = foo<?>;
|
||||
const HuhFoo = foo<string?>;
|
||||
const NopeFoo = foo<?string>;
|
||||
const ComeOnFoo = foo<?string?>;
|
||||
|
||||
type TWhatFoo = typeof foo<?>;
|
||||
type THuhFoo = typeof foo<string?>;
|
||||
type TNopeFoo = typeof foo<?string>;
|
||||
type TComeOnFoo = typeof foo<?string?>;
|
||||
|
||||
const WhatBar = Bar<?>;
|
||||
const HuhBar = Bar<string?>;
|
||||
const NopeBar = Bar<?string>;
|
||||
const ComeOnBar = Bar<?string?>;
|
||||
|
||||
type TWhatBar = typeof Bar<?>;
|
||||
type THuhBar = typeof Bar<string?>;
|
||||
type TNopeBar = typeof Bar<?string>;
|
||||
type TComeOnBar = typeof Bar<?string?>;
|
||||
Loading…
x
Reference in New Issue
Block a user