diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2020-05-17 12:56:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-17 18:56:22 +0200 |
commit | a054250a2cd709f74a3c9984af0cb74b7adde3bd (patch) | |
tree | 881ac3330f587a2532535db23942665fe917c841 /cli/doc/tests.rs | |
parent | e16eb9e10841d3b63bfe50db9849ae9a2d7c20f3 (diff) |
Update to dprint 0.18.3 and the latest version of swc (#5509)
Diffstat (limited to 'cli/doc/tests.rs')
-rw-r--r-- | cli/doc/tests.rs | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/cli/doc/tests.rs b/cli/doc/tests.rs index 2bae11ec9..f8e693c9a 100644 --- a/cli/doc/tests.rs +++ b/cli/doc/tests.rs @@ -1435,3 +1435,101 @@ export function fooFn(a: number) { .contains("function fooFn(a: number)") ); } + +#[tokio::test] +async fn ts_lit_types() { + let source_code = r#" +export type boolLit = false; +export type strLit = "text"; +export type tplLit = `text`; +export type numLit = 5; +"#; + let loader = + TestLoader::new(vec![("test.ts".to_string(), source_code.to_string())]); + let entries = DocParser::new(loader).parse("test.ts").await.unwrap(); + let actual = serde_json::to_value(entries).unwrap(); + let expected_json = json!([ + { + "kind": "typeAlias", + "name": "boolLit", + "location": { + "filename": "test.ts", + "line": 2, + "col": 0 + }, + "jsDoc": null, + "typeAliasDef": { + "tsType": { + "repr": "false", + "kind": "literal", + "literal": { + "kind": "boolean", + "boolean": false + } + }, + "typeParams": [] + } + }, { + "kind": "typeAlias", + "name": "strLit", + "location": { + "filename": "test.ts", + "line": 3, + "col": 0 + }, + "jsDoc": null, + "typeAliasDef": { + "tsType": { + "repr": "text", + "kind": "literal", + "literal": { + "kind": "string", + "string": "text" + } + }, + "typeParams": [] + } + }, { + "kind": "typeAlias", + "name": "tplLit", + "location": { + "filename": "test.ts", + "line": 4, + "col": 0 + }, + "jsDoc": null, + "typeAliasDef": { + "tsType": { + "repr": "text", + "kind": "literal", + "literal": { + "kind": "string", + "string": "text" + } + }, + "typeParams": [] + } + }, { + "kind": "typeAlias", + "name": "numLit", + "location": { + "filename": "test.ts", + "line": 5, + "col": 0 + }, + "jsDoc": null, + "typeAliasDef": { + "tsType": { + "repr": "5", + "kind": "literal", + "literal": { + "kind": "number", + "number": 5.0 + } + }, + "typeParams": [] + } + } + ]); + assert_eq!(actual, expected_json); +} |