diff --git a/package.json b/package.json index 8e7f31b10..89baca3dd 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "resolve": "1.5.0", "semver": "5.4.1", "string-width": "2.1.1", - "typescript": "2.8.0-dev.20180222", + "typescript": "2.8.0-rc", "typescript-eslint-parser": "14.0.0", "unicode-regex": "1.0.1", "unified": "6.1.6" diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 7d4fc4fad..e8f923c6a 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -2722,13 +2722,20 @@ function printPathNoParens(path, options, print, args) { concat([ options.bracketSpacing ? line : softline, n.readonlyToken - ? concat([path.call(print, "readonlyToken"), " "]) + ? concat([ + n.readonlyToken.type === "TSMinusToken" + ? "-readonly" + : "readonly", + " " + ]) : "", printTypeScriptModifiers(path, options, print), "[", path.call(print, "typeParameter"), "]", - n.questionToken ? "?" : "", + n.questionToken + ? n.questionToken.type === "TSMinusToken" ? "-?" : "?" + : "", ": ", path.call(print, "typeAnnotation") ]) diff --git a/tests/typescript/custom/modifiers/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/custom/modifiers/__snapshots__/jsfmt.spec.js.snap index a95c3d80c..da09d3ee0 100644 --- a/tests/typescript/custom/modifiers/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/custom/modifiers/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`minustoken.ts 1`] = ` +type MutableAndRequired = { + -readonly [P in keyof T]-?: T[P] +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +type MutableAndRequired = { -readonly [P in keyof T]-?: T[P] }; + +`; + exports[`question.ts 1`] = ` var x: { [A in keyof B]?: any; diff --git a/tests/typescript/custom/modifiers/minustoken.ts b/tests/typescript/custom/modifiers/minustoken.ts new file mode 100644 index 000000000..1f4dedc5a --- /dev/null +++ b/tests/typescript/custom/modifiers/minustoken.ts @@ -0,0 +1,3 @@ +type MutableAndRequired = { + -readonly [P in keyof T]-?: T[P] +} diff --git a/yarn.lock b/yarn.lock index 134668386..4d79bf55a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4784,9 +4784,9 @@ typescript-eslint-parser@14.0.0: lodash.unescape "4.0.1" semver "5.5.0" -typescript@2.8.0-dev.20180222: - version "2.8.0-dev.20180222" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.0-dev.20180222.tgz#50ee5fd5c76f2c9817e949803f946d74a559fc01" +typescript@2.8.0-rc: + version "2.8.0-rc" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.8.0-rc.tgz#a0256b7d1d39fb7493ba0403f55e95d31e8bc374" ua-parser-js@^0.7.9: version "0.7.17"