mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 02:30:15 -06:00
When source file is redirected, set the prototype correctly in node factory (#48862)
Fixes #48039
This commit is contained in:
parent
d879880a37
commit
c8ec855f9f
@ -5275,7 +5275,7 @@ namespace ts {
|
||||
hasNoDefaultLib: boolean,
|
||||
libReferences: readonly FileReference[]
|
||||
) {
|
||||
const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable<SourceFile>;
|
||||
const node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile)) as Mutable<SourceFile>;
|
||||
for (const p in source) {
|
||||
if (p === "emitNode" || hasProperty(node, p) || !hasProperty(source, p)) continue;
|
||||
(node as any)[p] = (source as any)[p];
|
||||
|
||||
@ -154,6 +154,7 @@
|
||||
"unittests/tsc/incremental.ts",
|
||||
"unittests/tsc/listFilesOnly.ts",
|
||||
"unittests/tsc/projectReferences.ts",
|
||||
"unittests/tsc/redirect.ts",
|
||||
"unittests/tsc/runWithoutArgs.ts",
|
||||
"unittests/tscWatch/consoleClearing.ts",
|
||||
"unittests/tscWatch/emit.ts",
|
||||
|
||||
34
src/testRunner/unittests/tsc/redirect.ts
Normal file
34
src/testRunner/unittests/tsc/redirect.ts
Normal file
@ -0,0 +1,34 @@
|
||||
namespace ts {
|
||||
describe("unittests:: tsc:: redirect::", () => {
|
||||
verifyTsc({
|
||||
scenario: "redirect",
|
||||
subScenario: "when redirecting ts file",
|
||||
fs: () => loadProjectFromFiles({
|
||||
"/src/project/tsconfig.json": JSON.stringify({
|
||||
compilerOptions: {
|
||||
outDir: "out"
|
||||
},
|
||||
include: [
|
||||
"copy1/node_modules/target/*",
|
||||
"copy2/node_modules/target/*",
|
||||
]
|
||||
}),
|
||||
"/src/project/copy1/node_modules/target/index.ts": "export const a = 1;",
|
||||
"/src/project/copy1/node_modules/target/import.ts": `import {} from "./";`,
|
||||
"/src/project/copy1/node_modules/target/package.json": JSON.stringify({
|
||||
name: "target",
|
||||
version: "1.0.0",
|
||||
main: "index.js",
|
||||
}),
|
||||
"/src/project/copy2/node_modules/target/index.ts": "export const a = 1;",
|
||||
"/src/project/copy2/node_modules/target/import.ts": `import {} from "./";`,
|
||||
"/src/project/copy2/node_modules/target/package.json": JSON.stringify({
|
||||
name: "target",
|
||||
version: "1.0.0",
|
||||
main: "index.js",
|
||||
}),
|
||||
}),
|
||||
commandLineArgs: ["-p", "src/project"],
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
Input::
|
||||
//// [/lib/lib.d.ts]
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface Boolean {}
|
||||
interface Function {}
|
||||
interface CallableFunction {}
|
||||
interface NewableFunction {}
|
||||
interface IArguments {}
|
||||
interface Number { toExponential: any; }
|
||||
interface Object {}
|
||||
interface RegExp {}
|
||||
interface String { charAt: any; }
|
||||
interface Array<T> { length: number; [n: number]: T; }
|
||||
interface ReadonlyArray<T> {}
|
||||
declare const console: { log(msg: any): void; };
|
||||
|
||||
//// [/src/project/copy1/node_modules/target/import.ts]
|
||||
import {} from "./";
|
||||
|
||||
//// [/src/project/copy1/node_modules/target/index.ts]
|
||||
export const a = 1;
|
||||
|
||||
//// [/src/project/copy1/node_modules/target/package.json]
|
||||
{"name":"target","version":"1.0.0","main":"index.js"}
|
||||
|
||||
//// [/src/project/copy2/node_modules/target/import.ts]
|
||||
import {} from "./";
|
||||
|
||||
//// [/src/project/copy2/node_modules/target/index.ts]
|
||||
export const a = 1;
|
||||
|
||||
//// [/src/project/copy2/node_modules/target/package.json]
|
||||
{"name":"target","version":"1.0.0","main":"index.js"}
|
||||
|
||||
//// [/src/project/tsconfig.json]
|
||||
{"compilerOptions":{"outDir":"out"},"include":["copy1/node_modules/target/*","copy2/node_modules/target/*"]}
|
||||
|
||||
|
||||
|
||||
Output::
|
||||
/lib/tsc -p src/project
|
||||
exitCode:: ExitStatus.Success
|
||||
|
||||
|
||||
//// [/src/project/out/copy1/node_modules/target/import.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
|
||||
|
||||
//// [/src/project/out/copy1/node_modules/target/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.a = void 0;
|
||||
exports.a = 1;
|
||||
|
||||
|
||||
//// [/src/project/out/copy2/node_modules/target/import.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
|
||||
|
||||
//// [/src/project/out/copy2/node_modules/target/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.a = void 0;
|
||||
exports.a = 1;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user