mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Consistently avoid module resolution errors when using getSymbolAtLocation (#58668)
This commit is contained in:
1 parent
5d70bf894e
commit
3743fbc748
8 files changed
+602
-21
No files matched your search
@@ -114,4 +114,58 @@ describe("unittests:: tsc:: composite::", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
scenario: "composite",
|
||||
subScenario: "synthetic jsx import of ESM module from CJS module no crash no jsx element",
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/main.ts": "export default 42;",
|
||||
"/tsconfig.json": jsonToReadableText({
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
module: "Node16",
|
||||
jsx: "react-jsx",
|
||||
jsxImportSource: "solid-js",
|
||||
},
|
||||
}),
|
||||
"/node_modules/solid-js/package.json": jsonToReadableText({
|
||||
name: "solid-js",
|
||||
type: "module",
|
||||
}),
|
||||
"/node_modules/solid-js/jsx-runtime.d.ts": Utils.dedent`
|
||||
export namespace JSX {
|
||||
type IntrinsicElements = { div: {}; };
|
||||
}
|
||||
`,
|
||||
}),
|
||||
commandLineArgs: [],
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
scenario: "composite",
|
||||
subScenario: "synthetic jsx import of ESM module from CJS module error on jsx element",
|
||||
fs: () =>
|
||||
loadProjectFromFiles({
|
||||
"/src/main.tsx": "export default <div/>;",
|
||||
"/tsconfig.json": jsonToReadableText({
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
module: "Node16",
|
||||
jsx: "react-jsx",
|
||||
jsxImportSource: "solid-js",
|
||||
},
|
||||
}),
|
||||
"/node_modules/solid-js/package.json": jsonToReadableText({
|
||||
name: "solid-js",
|
||||
type: "module",
|
||||
}),
|
||||
"/node_modules/solid-js/jsx-runtime.d.ts": Utils.dedent`
|
||||
export namespace JSX {
|
||||
type IntrinsicElements = { div: {}; };
|
||||
}
|
||||
`,
|
||||
}),
|
||||
commandLineArgs: [],
|
||||
});
|
||||
});
|
||||
@@ -2164,6 +2164,48 @@ import { x } from "../b";`,
|
||||
],
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "when changing `allowImportingTsExtensions` of config file 2",
|
||||
commandLineArgs: ["-w", "-p", ".", "--extendedDiagnostics"],
|
||||
sys: () => {
|
||||
const module1: File = {
|
||||
path: `/user/username/projects/myproject/a.ts`,
|
||||
content: `export const foo = 10;`,
|
||||
};
|
||||
const module2: File = {
|
||||
path: `/user/username/projects/myproject/b.ts`,
|
||||
content: `export * as a from "./a.ts";`,
|
||||
};
|
||||
const config: File = {
|
||||
path: `/user/username/projects/myproject/tsconfig.json`,
|
||||
content: jsonToReadableText({
|
||||
compilerOptions: {
|
||||
noEmit: true,
|
||||
allowImportingTsExtensions: false,
|
||||
},
|
||||
}),
|
||||
};
|
||||
return createWatchedSystem([module1, module2, config, libFile], { currentDirectory: "/user/username/projects/myproject" });
|
||||
},
|
||||
edits: [
|
||||
{
|
||||
caption: "Change allowImportingTsExtensions to true",
|
||||
edit: sys =>
|
||||
sys.writeFile(
|
||||
`/user/username/projects/myproject/tsconfig.json`,
|
||||
jsonToReadableText({
|
||||
compilerOptions: {
|
||||
noEmit: true,
|
||||
allowImportingTsExtensions: true,
|
||||
},
|
||||
}),
|
||||
),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "when changing checkJs of config file",
|
||||
|
||||
Reference in new issue
Block a user