mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
This commit is contained in:
commit
fea9e11174
90 files changed
+1830
-414
No files matched your search
@@ -3,6 +3,7 @@ namespace ts {
|
||||
|
||||
interface TranspileTestSettings {
|
||||
options?: TranspileOptions;
|
||||
noSetFileName?: boolean;
|
||||
}
|
||||
|
||||
function transpilesCorrectly(name: string, input: string, testSettings: TranspileTestSettings) {
|
||||
@@ -26,15 +27,19 @@ namespace ts {
|
||||
|
||||
transpileOptions.compilerOptions.sourceMap = true;
|
||||
|
||||
if (!transpileOptions.fileName) {
|
||||
transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts";
|
||||
let unitName = transpileOptions.fileName;
|
||||
if (!unitName) {
|
||||
unitName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts";
|
||||
if (!testSettings.noSetFileName) {
|
||||
transpileOptions.fileName = unitName;
|
||||
}
|
||||
}
|
||||
|
||||
transpileOptions.reportDiagnostics = true;
|
||||
|
||||
const justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts);
|
||||
const toBeCompiled: Harness.Compiler.TestFile[] = [{
|
||||
unitName: transpileOptions.fileName,
|
||||
const toBeCompiled = [{
|
||||
unitName,
|
||||
content: input
|
||||
}];
|
||||
const canUseOldTranspile = !transpileOptions.renamedDependencies;
|
||||
@@ -453,5 +458,9 @@ var x = 0;`, {
|
||||
transpilesCorrectly("Supports 'as const' arrays", `([] as const).forEach(k => console.log(k));`, {
|
||||
options: { compilerOptions: { module: ModuleKind.CommonJS } }
|
||||
});
|
||||
|
||||
transpilesCorrectly("Infer correct file extension", `const fn = <T>(a: T) => a`, {
|
||||
noSetFileName: true
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user