-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extra test cases for fixed
reportNonexistentProperty
crashes (#…
- Loading branch information
Showing
7 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...es/reference/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.errors.txt
This file contains 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,16 @@ | ||
index.js(5,21): error TS2339: Property 'fn' does not exist on type '{ (...args: any[]): void; readonly name: string; }'. | ||
|
||
|
||
==== index.js (1 errors) ==== | ||
export function test(fn) { | ||
const composed = function (...args) { } | ||
|
||
Object.defineProperty(composed, 'name', { | ||
value: composed.fn + '_test' | ||
~~ | ||
!!! error TS2339: Property 'fn' does not exist on type '{ (...args: any[]): void; readonly name: string; }'. | ||
}) | ||
|
||
return composed | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
.../baselines/reference/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.js
This file contains 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,37 @@ | ||
//// [tests/cases/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.ts] //// | ||
|
||
//// [index.js] | ||
export function test(fn) { | ||
const composed = function (...args) { } | ||
|
||
Object.defineProperty(composed, 'name', { | ||
value: composed.fn + '_test' | ||
}) | ||
|
||
return composed | ||
} | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.test = test; | ||
function test(fn) { | ||
var composed = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
}; | ||
Object.defineProperty(composed, 'name', { | ||
value: composed.fn + '_test' | ||
}); | ||
return composed; | ||
} | ||
|
||
|
||
//// [index.d.ts] | ||
export function test(fn: any): { | ||
(...args: any[]): void; | ||
readonly name: string; | ||
}; |
28 changes: 28 additions & 0 deletions
28
...lines/reference/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.symbols
This file contains 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,28 @@ | ||
//// [tests/cases/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.ts] //// | ||
|
||
=== index.js === | ||
export function test(fn) { | ||
>test : Symbol(test, Decl(index.js, 0, 0)) | ||
>fn : Symbol(fn, Decl(index.js, 0, 21)) | ||
|
||
const composed = function (...args) { } | ||
>composed : Symbol(composed, Decl(index.js, 1, 7)) | ||
>args : Symbol(args, Decl(index.js, 1, 29)) | ||
|
||
Object.defineProperty(composed, 'name', { | ||
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) | ||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --)) | ||
>composed : Symbol(composed, Decl(index.js, 1, 7)) | ||
>'name' : Symbol(composed.name, Decl(index.js, 1, 41)) | ||
|
||
value: composed.fn + '_test' | ||
>value : Symbol(value, Decl(index.js, 3, 43)) | ||
>composed : Symbol(composed, Decl(index.js, 1, 7)) | ||
|
||
}) | ||
|
||
return composed | ||
>composed : Symbol(composed, Decl(index.js, 1, 7)) | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
...selines/reference/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.types
This file contains 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,54 @@ | ||
//// [tests/cases/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.ts] //// | ||
|
||
=== index.js === | ||
export function test(fn) { | ||
>test : (fn: any) => { (...args: any[]): void; readonly name: string; } | ||
> : ^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>fn : any | ||
> : ^^^ | ||
|
||
const composed = function (...args) { } | ||
>composed : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>function (...args) { } : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>args : any[] | ||
> : ^^^^^ | ||
|
||
Object.defineProperty(composed, 'name', { | ||
>Object.defineProperty(composed, 'name', { value: composed.fn + '_test' }) : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>Object.defineProperty : <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ | ||
>Object : ObjectConstructor | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>defineProperty : <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T | ||
> : ^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^ | ||
>composed : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>'name' : "name" | ||
> : ^^^^^^ | ||
>{ value: composed.fn + '_test' } : { value: string; } | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
value: composed.fn + '_test' | ||
>value : string | ||
> : ^^^^^^ | ||
>composed.fn + '_test' : string | ||
> : ^^^^^^ | ||
>composed.fn : any | ||
> : ^^^ | ||
>composed : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>fn : any | ||
> : ^^^ | ||
>'_test' : "_test" | ||
> : ^^^^^^^ | ||
|
||
}) | ||
|
||
return composed | ||
>composed : { (...args: any[]): void; readonly name: string; } | ||
> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
} | ||
|
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/findAllRefsNonexistentPropertyNoCrash1.baseline.jsonc
This file contains 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,50 @@ | ||
// === findAllReferences === | ||
// === /tests/cases/fourslash/src/parser.js === | ||
// --- (line: 10) skipped --- | ||
// variable: function () { | ||
// let name; | ||
// | ||
// if (parserInput.currentChar() === "[|{| isInString: true |}@|]") { | ||
// return name[1]; | ||
// } | ||
// }, | ||
// --- (line: 18) skipped --- | ||
|
||
// === /tests/cases/fourslash/./src/parser.js === | ||
// --- (line: 10) skipped --- | ||
// variable: function () { | ||
// let name; | ||
// | ||
// if (parserInput.currentChar() === "/*FIND ALL REFS*/@") { | ||
// return name[1]; | ||
// } | ||
// }, | ||
// --- (line: 18) skipped --- | ||
|
||
// === Definitions === | ||
// === /tests/cases/fourslash/src/parser.js === | ||
// --- (line: 10) skipped --- | ||
// variable: function () { | ||
// let name; | ||
// | ||
// if (parserInput.currentChar() === "[|@|]") { | ||
// return name[1]; | ||
// } | ||
// }, | ||
// --- (line: 18) skipped --- | ||
|
||
// === Details === | ||
[ | ||
{ | ||
"containerKind": "", | ||
"containerName": "", | ||
"kind": "var", | ||
"name": "@", | ||
"displayParts": [ | ||
{ | ||
"text": "\"@\"", | ||
"kind": "stringLiteral" | ||
} | ||
] | ||
} | ||
] |
16 changes: 16 additions & 0 deletions
16
tests/cases/compiler/checkingObjectDefinePropertyOnFunctionNonexistentPropertyNoCrash1.ts
This file contains 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,16 @@ | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @declaration: true | ||
// @outDir: dist | ||
|
||
// @filename: index.js | ||
|
||
export function test(fn) { | ||
const composed = function (...args) { } | ||
|
||
Object.defineProperty(composed, 'name', { | ||
value: composed.fn + '_test' | ||
}) | ||
|
||
return composed | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/cases/fourslash/findAllRefsNonexistentPropertyNoCrash1.ts
This file contains 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,51 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @strict: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
|
||
// @filename: ./src/parser-input.js | ||
//// export default () => { | ||
//// let input; | ||
//// | ||
//// const parserInput = {}; | ||
//// | ||
//// parserInput.currentChar = () => input.charAt(parserInput.i); | ||
//// | ||
//// parserInput.end = () => { | ||
//// const isFinished = parserInput.i >= input.length; | ||
//// | ||
//// return { | ||
//// isFinished, | ||
//// furthest: parserInput.i, | ||
//// }; | ||
//// }; | ||
//// | ||
//// return parserInput; | ||
//// }; | ||
|
||
// @filename: ./src/parser.js | ||
//// import getParserInput from "./parser-input"; | ||
//// | ||
//// const Parser = function Parser(context, imports, fileInfo, currentIndex) { | ||
//// currentIndex = currentIndex || 0; | ||
//// let parsers; | ||
//// const parserInput = getParserInput(); | ||
//// | ||
//// return { | ||
//// parserInput, | ||
//// parsers: (parsers = { | ||
//// variable: function () { | ||
//// let name; | ||
//// | ||
//// if (parserInput.currentChar() === "/*1*/@") { | ||
//// return name[1]; | ||
//// } | ||
//// }, | ||
//// }), | ||
//// }; | ||
//// }; | ||
//// | ||
//// export default Parser; | ||
|
||
verify.baselineFindAllReferences("1"); |