-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse this argument in TypeScript function. (#1173)
Summary: Parse `this` argument in TypeScript function. Pull Request resolved: #1173 Test Plan: Unit tests added. Reviewed By: neildhar Differential Revision: D50666819 Pulled By: avp fbshipit-source-id: 1d61361605e5530ee91cf6105a2cc3e85cbb82af
- Loading branch information
1 parent
2305173
commit 04faa3f
Showing
5 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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,13 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// RUN: (! %hermes -parse-ts -dump-ast -pretty-json %s 2>&1) | %FileCheck %s --match-full-lines | ||
|
||
type A = (this?: string) => void; | ||
// CHECK: {{.*}}:10:11: error: 'this' constraint may not be optional | ||
// CHECK-NEXT: type A = (this?: string) => void; | ||
// CHECK-NEXT: ^~~~ |
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,85 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// RUN: %hermesc -parse-ts -dump-ast -pretty-json %s | %FileCheck %s --match-full-lines | ||
|
||
// CHECK-LABEL: { | ||
// CHECK-NEXT: "type": "Program", | ||
// CHECK-NEXT: "body": [ | ||
|
||
function foo(this: string, x: boolean, y?: number, ...args: string[]): void {} | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "type": "FunctionDeclaration", | ||
// CHECK-NEXT: "id": { | ||
// CHECK-NEXT: "type": "Identifier", | ||
// CHECK-NEXT: "name": "foo" | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "params": [ | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "type": "Identifier", | ||
// CHECK-NEXT: "name": "this", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSTypeAnnotation", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSStringKeyword" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "type": "Identifier", | ||
// CHECK-NEXT: "name": "x", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSTypeAnnotation", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSBooleanKeyword" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "type": "Identifier", | ||
// CHECK-NEXT: "name": "y", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSTypeAnnotation", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSNumberKeyword" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "optional": true | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "type": "RestElement", | ||
// CHECK-NEXT: "argument": { | ||
// CHECK-NEXT: "type": "Identifier", | ||
// CHECK-NEXT: "name": "args", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSTypeAnnotation", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSArrayType", | ||
// CHECK-NEXT: "elementType": { | ||
// CHECK-NEXT: "type": "TSStringKeyword" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: ], | ||
// CHECK-NEXT: "body": { | ||
// CHECK-NEXT: "type": "BlockStatement", | ||
// CHECK-NEXT: "body": [] | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "returnType": { | ||
// CHECK-NEXT: "type": "TSTypeAnnotation", | ||
// CHECK-NEXT: "typeAnnotation": { | ||
// CHECK-NEXT: "type": "TSVoidKeyword" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "generator": false, | ||
// CHECK-NEXT: "async": false | ||
// CHECK-NEXT: } | ||
|
||
// CHECK-NEXT: ] | ||
// CHECK-NEXT: } |