-
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.
Browse files
Browse the repository at this point in the history
Summary: Original Author: [email protected] Original Git: 04faa3f Parse `this` argument in TypeScript function. Original Reviewed By: neildhar Original Revision: D50666819 Pull Request resolved: #1173 Pulled By: avp Reviewed By: tmikov Differential Revision: D50696601 fbshipit-source-id: eb02bbada84410dc3b73d1bac05ade62acf0c7ba
- Loading branch information
1 parent
e0592c9
commit aca7f7c
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: } |