TypeScript/tests/baselines/reference/intrinsics.errors.txt
Andrew Casey 9e97b00ca1
adds error message for using value as type argument (#37359)
This addresses issue #28975
(https://github.com/microsoft/TypeScript/issues/28975).

When providing a value as a type argument, we can suggest a more specific
error message: "Did you mean to use typeof T?"

adds error message

WIP: Detect error

WIP: progress

updated tests

janky implementation

adds test coverage around literal types being unaffected

refactor out isIdentifierATypeArgument function

adds test case for type alias

adds test case for nested type arguments

fixes linting errors

merge master into branch to overwrite changes

changes value as type error message

This suggests 'typeof T' as a potential alternative when we give an error
about using value T as a type.

remove stale tests from old change

Co-authored-by: John Patterson <john@johnppatterson.com>
2020-03-11 19:18:17 -07:00

26 lines
1.2 KiB
Plaintext

tests/cases/compiler/intrinsics.ts(1,21): error TS2749: 'hasOwnProperty' refers to a value, but is being used as a type here. Did you mean 'typeof hasOwnProperty'?
tests/cases/compiler/intrinsics.ts(1,21): error TS4025: Exported variable 'hasOwnProperty' has or is using private name 'hasOwnProperty'.
tests/cases/compiler/intrinsics.ts(10,1): error TS2304: Cannot find name '__proto__'.
==== tests/cases/compiler/intrinsics.ts (3 errors) ====
var hasOwnProperty: hasOwnProperty; // Error
~~~~~~~~~~~~~~
!!! error TS2749: 'hasOwnProperty' refers to a value, but is being used as a type here. Did you mean 'typeof hasOwnProperty'?
~~~~~~~~~~~~~~
!!! error TS4025: Exported variable 'hasOwnProperty' has or is using private name 'hasOwnProperty'.
module m1 {
export var __proto__;
interface __proto__ {}
class C<T extends { __proto__: __proto__ }> { }
}
__proto__ = 0; // Error, __proto__ not defined
~~~~~~~~~
!!! error TS2304: Cannot find name '__proto__'.
m1.__proto__ = 0;
class Foo<__proto__> { }
var foo: (__proto__: number) => void;