feat(typescript): support TSOptionalType and TSRestType (#4757)

Ref: Microsoft/TypeScript#24897
master
Ika 2018-06-30 09:10:56 +08:00 committed by GitHub
parent e10c31a333
commit 50d242d085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 4 deletions

View File

@ -56,7 +56,7 @@
"resolve": "1.5.0",
"semver": "5.4.1",
"string-width": "2.1.1",
"typescript": "3.0.0-dev.20180602",
"typescript": "3.0.0-dev.20180626",
"typescript-eslint-parser": "eslint/typescript-eslint-parser#42f29a1db5c51262fd9ed2d6105015da8925ba2d",
"unicode-regex": "1.0.1",
"unified": "6.1.6",

View File

@ -2490,6 +2490,10 @@ function printPathNoParens(path, options, print, args) {
return group(concat(parts));
}
case "TSRestType":
return concat(["...", path.call(print, "typeAnnotation")]);
case "TSOptionalType":
return concat([path.call(print, "typeAnnotation"), "?"]);
case "FunctionTypeParam":
return concat([
path.call(print, "name"),

View File

@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`simple.ts 1`] = `
type X = [number, string?];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type X = [number, string?];
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, ["typescript"]);

View File

@ -0,0 +1 @@
type X = [number, string?];

View File

@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`simple.ts 1`] = `
type X = [...number[]];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type X = [...number[]];
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, ["typescript"]);

View File

@ -0,0 +1 @@
type X = [...number[]];

View File

@ -5747,9 +5747,9 @@ typescript-eslint-parser@eslint/typescript-eslint-parser#42f29a1db5c51262fd9ed2d
lodash.unescape "4.0.1"
semver "5.5.0"
typescript@3.0.0-dev.20180602:
version "3.0.0-dev.20180602"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.0-dev.20180602.tgz#ca368c199b4e3cbfd25b82ecece3f2b13349c893"
typescript@3.0.0-dev.20180626:
version "3.0.0-dev.20180626"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.0-dev.20180626.tgz#fb6be91cfc8e8757d551e83af208d0083be61499"
ua-parser-js@^0.7.9:
version "0.7.17"