Forward originalText in multiparser (#2260)

If we don't, all the places where we read from the original text (mostly comments) are reading into random places.

Fixes #2258
master
Christopher Chedeau 2017-06-24 17:54:09 -07:00 committed by GitHub
parent 8def8e13b0
commit 38d4661ba9
7 changed files with 50 additions and 1 deletions

View File

@ -11,7 +11,9 @@ const concat = docBuilders.concat;
function printSubtree(subtreeParser, path, print, options) {
const next = Object.assign({}, { transformDoc: doc => doc }, subtreeParser);
next.options = Object.assign({}, options, next.options);
next.options = Object.assign({}, options, next.options, {
originalText: next.text
});
const ast = require("./parser").parse(next.text, next.options);
const astComments = ast.comments;
delete ast.comments;

View File

@ -33,6 +33,7 @@ exports[`html-with-ts-script.html 1`] = `
<script lang="ts">
type X = { [K in keyof Y]: Partial<K> };
class Foo<T> {
constructor(private foo: keyof Apple) {}
}

View File

@ -17,11 +17,13 @@ border-color : tomato
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const Button = styled.button\`
color: palevioletred;
font-size: 1em;
\`;
const TomatoButton = Button.extend\`
color: tomato;
border-color: tomato;
\`;

View File

@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`text.js 1`] = `
a = {
viewer: graphql\`
fragment x on Viewer {
y(named: [
"projects_feedback_ids" # PROJECTS_FEEDBACK_IDS
]) {
name
}
}
\`,
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = {
viewer: graphql\`
fragment x on Viewer {
y(
named: [
"projects_feedback_ids" # PROJECTS_FEEDBACK_IDS
]
) {
name
}
}
\`
};
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,11 @@
a = {
viewer: graphql`
fragment x on Viewer {
y(named: [
"projects_feedback_ids" # PROJECTS_FEEDBACK_IDS
]) {
name
}
}
`,
}

View File

@ -41,8 +41,10 @@ const EqualDivider = styled.div\`
margin: 0.5rem;
padding: 1rem;
background: papayawhip;
> * {
flex: 1;
&:not(:first-child) {
\${props => (props.vertical ? "margin-top" : "margin-left")}: 1rem;
}