mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
fix for TypeScript test on Windows
This commit is contained in:
@@ -19,7 +19,16 @@ function compile(content, contentFilename) {
|
||||
var output = null;
|
||||
var compilerHost = {
|
||||
getSourceFile: function(filename, languageVersion) {
|
||||
var source;
|
||||
var source, reactRegex;
|
||||
|
||||
// Accomodations for backslashes in Windows file paths.
|
||||
if (process.platform === 'win32') {
|
||||
filename = filename.replace(/\//g, '\\');
|
||||
reactRegex = /\\(?:React|ReactDOM)(?:\.d)?\.ts$/;
|
||||
} else {
|
||||
reactRegex = /\/(?:React|ReactDOM)(?:\.d)?\.ts$/;
|
||||
}
|
||||
|
||||
if (filename === 'lib.d.ts') {
|
||||
source = fs.readFileSync(
|
||||
require.resolve('typescript/bin/lib.d.ts')
|
||||
@@ -30,7 +39,7 @@ function compile(content, contentFilename) {
|
||||
).toString();
|
||||
} else if (filename === contentFilename) {
|
||||
source = content;
|
||||
} else if (/\/(?:React|ReactDOM)(?:\.d)?\.ts$/.test(filename)) {
|
||||
} else if (reactRegex.test(filename)) {
|
||||
// TypeScript will look for the .d.ts files in each ancestor directory,
|
||||
// so there may not be a file at the referenced path as it climbs the
|
||||
// hierarchy.
|
||||
|
||||
Reference in New Issue
Block a user