TypeScript/tests/cases/fourslash/extract-const3.ts
Eli Barzilay 5c8def9a06 Fix emitting ?.
Use `emit()` for writing `questionDotToken`, leading to properly calling
the emit hooks (which `emitTokenWithComment` doesn't) and printing the
comments.  This fixes #35372 by calling its hooks to set the `.__pos`
and `.__end` fields.

Also, remove `getDotOrQuestionDotToken` which was used only here --
mainly because it seems likely to encourage misusing the
`questionDotToken` again.

Also, fix a bunch of `visitor` -> `tokenVisiton` calls in
`visitorPublic.ts`.
2020-03-04 14:52:33 -05:00

18 lines
409 B
TypeScript

/// <reference path='fourslash.ts' />
// GH#35372
////function foo(bar?: number) {
//// /*a*/bar?.toString();/*b*/
////}
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "constant_scope_0",
actionDescription: "Extract to constant in enclosing scope",
newContent:
`function foo(bar?: number) {
const /*RENAME*/newLocal = bar?.toString();
}`
});