mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Add fourslash tests
This commit is contained in:
parent
7102de77d3
commit
3e256e14dc
@ -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;
|
||||
|
||||
21
tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts
Normal file
21
tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts
Normal 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 />;
|
||||
`,
|
||||
}
|
||||
});
|
||||
22
tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts
Normal file
22
tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts
Normal 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 />;
|
||||
`,
|
||||
}
|
||||
});
|
||||
21
tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts
Normal file
21
tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts
Normal 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;
|
||||
`,
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user