Add fourslash tests

This commit is contained in:
Andrew Casey 2019-01-16 19:18:25 -08:00
parent 7102de77d3
commit 3e256e14dc
4 changed files with 69 additions and 0 deletions

View File

@ -510,7 +510,12 @@ namespace ts.refactor {
}
const jsxNamespace = checker.getJsxNamespace(containsJsx);
// Strictly speaking, this could resolve to a symbol other than the JSX namespace.
// This will produce erroneous output (probably, an incorrectly copied import) but
// is expected to be very rare and easily reversible.
const jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, SymbolFlags.Namespace, /*excludeGlobals*/ true);
return !!jsxNamespaceSymbol && some(jsxNamespaceSymbol.declarations, isInImport)
? jsxNamespaceSymbol
: undefined;

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: file.tsx
//// import React = require('react');
//// [|<div/>;|]
//// 1;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`1;`,
"/tests/cases/fourslash/newFile.tsx":
`import React = require('react');
<div />;
`,
}
});

View File

@ -0,0 +1,22 @@
/// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: file.tsx
//// import React = require('react');
//// [|<div/>;|]
//// <div/>;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`import React = require('react');
<div/>;`,
"/tests/cases/fourslash/newFile.tsx":
`import React = require('react');
<div />;
`,
}
});

View File

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts' />
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
// @Filename: file.tsx
//// import React = require('react');
//// [|1;|]
//// <div/>;
verify.moveToNewFile({
newFileContents: {
"/tests/cases/fourslash/file.tsx":
`import React = require('react');
<div/>;`,
"/tests/cases/fourslash/newFile.tsx":
`1;
`,
}
});