Skip to content

Commit db08a77

Browse files
author
Armando Aguirre
committed
Merge branch 'master' into AddVueSupport
2 parents f17603d + 2f6b59e commit db08a77

File tree

81 files changed

+1097
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1097
-579
lines changed

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@
1818
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
1919
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git
2020
ignore = all
21+
[submodule "tests/cases/user/create-react-app/create-react-app"]
22+
path = tests/cases/user/create-react-app/create-react-app
23+
url = https://github.com/facebook/create-react-app.git
24+
ignore = all
2125
[submodule "tests/cases/user/webpack/webpack"]
2226
path = tests/cases/user/webpack/webpack
2327
url = https://github.com/webpack/webpack.git
2428
ignore = all
29+
[submodule "tests/cases/user/puppeteer/puppeteer"]
30+
path = tests/cases/user/puppeteer/puppeteer
31+
url = https://github.com/GoogleChrome/puppeteer.git
32+
ignore = all
33+
[submodule "tests/cases/user/axios-src/axios-src"]
34+
path = tests/cases/user/axios-src/axios-src
35+
url = https://github.com/axios/axios.git
36+
ignore = all

Gulpfile.ts renamed to Gulpfile.js

Lines changed: 126 additions & 131 deletions
Large diffs are not rendered by default.

Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ compileFile(/*outfile*/configurePrereleaseJs,
491491
/*prereqs*/[configurePrereleaseTs],
492492
/*prefixes*/[],
493493
/*useBuiltCompiler*/ false,
494-
{ noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false });
494+
{ noOutFile: true, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false });
495495

496496
task("setDebugMode", function () {
497497
useDebugMode = true;

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"source-map-support": "latest",
7777
"through2": "latest",
7878
"travis-fold": "latest",
79-
"ts-node": "latest",
8079
"tslint": "latest",
8180
"vinyl": "latest",
8281
"chalk": "latest",

scripts/configurePrerelease.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
/// <reference path="../src/compiler/sys.ts" />
1+
/// <reference types="node"/>
2+
import { normalize } from "path";
3+
import assert = require("assert");
4+
import { readFileSync, writeFileSync } from "fs";
5+
const args = process.argv.slice(2);
6+
27

38
/**
49
* A minimal description for a parsed package.json object.
@@ -10,28 +15,27 @@ interface PackageJson {
1015
}
1116

1217
function main(): void {
13-
const sys = ts.sys;
14-
if (sys.args.length < 3) {
15-
sys.write("Usage:" + sys.newLine)
16-
sys.write("\tnode configureNightly.js <dev|insiders> <package.json location> <file containing version>" + sys.newLine);
18+
if (args.length < 3) {
19+
console.log("Usage:");
20+
console.log("\tnode configureNightly.js <dev|insiders> <package.json location> <file containing version>");
1721
return;
1822
}
1923

20-
const tag = sys.args[0];
24+
const tag = args[0];
2125
if (tag !== "dev" && tag !== "insiders") {
2226
throw new Error(`Unexpected tag name '${tag}'.`);
2327
}
2428

2529
// Acquire the version from the package.json file and modify it appropriately.
26-
const packageJsonFilePath = ts.normalizePath(sys.args[1]);
27-
const packageJsonValue: PackageJson = JSON.parse(sys.readFile(packageJsonFilePath));
30+
const packageJsonFilePath = normalize(args[1]);
31+
const packageJsonValue: PackageJson = JSON.parse(readFileSync(packageJsonFilePath).toString());
2832

2933
const { majorMinor, patch } = parsePackageJsonVersion(packageJsonValue.version);
3034
const prereleasePatch = getPrereleasePatch(tag, patch);
3135

3236
// Acquire and modify the source file that exposes the version string.
33-
const tsFilePath = ts.normalizePath(sys.args[2]);
34-
const tsFileContents = ts.sys.readFile(tsFilePath);
37+
const tsFilePath = normalize(args[2]);
38+
const tsFileContents = readFileSync(tsFilePath).toString();
3539
const modifiedTsFileContents = updateTsFile(tsFilePath, tsFileContents, majorMinor, patch, prereleasePatch);
3640

3741
// Ensure we are actually changing something - the user probably wants to know that the update failed.
@@ -44,20 +48,20 @@ function main(): void {
4448
// Finally write the changes to disk.
4549
// Modify the package.json structure
4650
packageJsonValue.version = `${majorMinor}.${prereleasePatch}`;
47-
sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4))
48-
sys.writeFile(tsFilePath, modifiedTsFileContents);
51+
writeFileSync(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4))
52+
writeFileSync(tsFilePath, modifiedTsFileContents);
4953
}
5054

5155
function updateTsFile(tsFilePath: string, tsFileContents: string, majorMinor: string, patch: string, nightlyPatch: string): string {
5256
const majorMinorRgx = /export const versionMajorMinor = "(\d+\.\d+)"/;
5357
const majorMinorMatch = majorMinorRgx.exec(tsFileContents);
54-
ts.Debug.assert(majorMinorMatch !== null, "", () => `The file seems to no longer have a string matching '${majorMinorRgx}'.`);
58+
assert(majorMinorMatch !== null, `The file seems to no longer have a string matching '${majorMinorRgx}'.`);
5559
const parsedMajorMinor = majorMinorMatch[1];
56-
ts.Debug.assert(parsedMajorMinor === majorMinor, "versionMajorMinor does not match.", () => `${tsFilePath}: '${parsedMajorMinor}'; package.json: '${majorMinor}'`);
60+
assert(parsedMajorMinor === majorMinor, `versionMajorMinor does not match. ${tsFilePath}: '${parsedMajorMinor}'; package.json: '${majorMinor}'`);
5761

5862
const versionRgx = /export const version = `\$\{versionMajorMinor\}\.(\d)(-dev)?`;/;
5963
const patchMatch = versionRgx.exec(tsFileContents);
60-
ts.Debug.assert(patchMatch !== null, "The file seems to no longer have a string matching", () => versionRgx.toString());
64+
assert(patchMatch !== null, "The file seems to no longer have a string matching " + versionRgx.toString());
6165
const parsedPatch = patchMatch[1];
6266
if (parsedPatch !== patch) {
6367
throw new Error(`patch does not match. ${tsFilePath}: '${parsedPatch}; package.json: '${patch}'`);
@@ -69,7 +73,7 @@ function updateTsFile(tsFilePath: string, tsFileContents: string, majorMinor: st
6973
function parsePackageJsonVersion(versionString: string): { majorMinor: string, patch: string } {
7074
const versionRgx = /(\d+\.\d+)\.(\d+)($|\-)/;
7175
const match = versionString.match(versionRgx);
72-
ts.Debug.assert(match !== null, "package.json 'version' should match", () => versionRgx.toString());
76+
assert(match !== null, "package.json 'version' should match " + versionRgx.toString());
7377
return { majorMinor: match[1], patch: match[2] };
7478
}
7579

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24465,7 +24465,10 @@ namespace ts {
2446524465
checkImportBinding(importClause.namedBindings);
2446624466
}
2446724467
else {
24468-
forEach(importClause.namedBindings.elements, checkImportBinding);
24468+
const moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
24469+
if (moduleExisted) {
24470+
forEach(importClause.namedBindings.elements, checkImportBinding);
24471+
}
2446924472
}
2447024473
}
2447124474
}

src/compiler/core.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,18 +2994,19 @@ namespace ts {
29942994
}
29952995

29962996
/** Remove the *first* occurrence of `item` from the array. */
2997-
export function unorderedRemoveItem<T>(array: T[], item: T): void {
2998-
unorderedRemoveFirstItemWhere(array, element => element === item);
2997+
export function unorderedRemoveItem<T>(array: T[], item: T) {
2998+
return unorderedRemoveFirstItemWhere(array, element => element === item);
29992999
}
30003000

30013001
/** Remove the *first* element satisfying `predicate`. */
3002-
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
3002+
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean) {
30033003
for (let i = 0; i < array.length; i++) {
30043004
if (predicate(array[i])) {
30053005
unorderedRemoveItemAt(array, i);
3006-
break;
3006+
return true;
30073007
}
30083008
}
3009+
return false;
30093010
}
30103011

30113012
export type GetCanonicalFileName = (fileName: string) => string;

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,10 +2943,6 @@
29432943
"category": "Message",
29442944
"code": 6040
29452945
},
2946-
"Compilation complete. Watching for file changes.": {
2947-
"category": "Message",
2948-
"code": 6042
2949-
},
29502946
"Generates corresponding '.map' file.": {
29512947
"category": "Message",
29522948
"code": 6043
@@ -3522,11 +3518,11 @@
35223518
"code": 6192,
35233519
"reportsUnnecessary": true
35243520
},
3525-
"Found 1 error.": {
3521+
"Found 1 error. Watching for file changes.": {
35263522
"category": "Message",
35273523
"code": 6193
35283524
},
3529-
"Found {0} errors.": {
3525+
"Found {0} errors. Watching for file changes.": {
35303526
"category": "Message",
35313527
"code": 6194
35323528
},

src/compiler/resolutionCache.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace ts {
1010

1111
invalidateResolutionOfFile(filePath: Path): void;
1212
removeResolutionsOfFile(filePath: Path): void;
13+
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map<ReadonlyArray<string>>): void;
1314
createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution;
1415

1516
startCachingPerDirectoryResolution(): void;
@@ -74,6 +75,7 @@ namespace ts {
7475
export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string, logChangesWhenResolvingModule: boolean): ResolutionCache {
7576
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
7677
let filesWithInvalidatedResolutions: Map<true> | undefined;
78+
let filesWithInvalidatedNonRelativeUnresolvedImports: Map<ReadonlyArray<string>> | undefined;
7779
let allFilesHaveInvalidatedResolution = false;
7880

7981
const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
@@ -122,6 +124,7 @@ namespace ts {
122124
resolveTypeReferenceDirectives,
123125
removeResolutionsOfFile,
124126
invalidateResolutionOfFile,
127+
setFilesWithInvalidatedNonRelativeUnresolvedImports,
125128
createHasInvalidatedResolution,
126129
updateTypeRootsWatch,
127130
closeTypeRootsWatch,
@@ -165,6 +168,16 @@ namespace ts {
165168
return collected;
166169
}
167170

171+
function isFileWithInvalidatedNonRelativeUnresolvedImports(path: Path) {
172+
if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
173+
return false;
174+
}
175+
176+
// Invalidated if file has unresolved imports
177+
const value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
178+
return value && !!value.length;
179+
}
180+
168181
function createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution {
169182
if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) {
170183
// Any file asked would have invalidated resolution
@@ -173,7 +186,8 @@ namespace ts {
173186
}
174187
const collected = filesWithInvalidatedResolutions;
175188
filesWithInvalidatedResolutions = undefined;
176-
return path => collected && collected.has(path);
189+
return path => (collected && collected.has(path)) ||
190+
isFileWithInvalidatedNonRelativeUnresolvedImports(path);
177191
}
178192

179193
function clearPerDirectoryResolutions() {
@@ -184,6 +198,7 @@ namespace ts {
184198

185199
function finishCachingPerDirectoryResolution() {
186200
allFilesHaveInvalidatedResolution = false;
201+
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
187202
directoryWatchesOfFailedLookups.forEach((watcher, path) => {
188203
if (watcher.refCount === 0) {
189204
directoryWatchesOfFailedLookups.delete(path);
@@ -237,13 +252,15 @@ namespace ts {
237252

238253
const resolvedModules: R[] = [];
239254
const compilerOptions = resolutionHost.getCompilationSettings();
240-
255+
const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
241256
const seenNamesInFile = createMap<true>();
242257
for (const name of names) {
243258
let resolution = resolutionsInFile.get(name);
244259
// Resolution is valid if it is present and not invalidated
245260
if (!seenNamesInFile.has(name) &&
246-
allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated) {
261+
allFilesHaveInvalidatedResolution || !resolution || resolution.isInvalidated ||
262+
// If the name is unresolved import that was invalidated, recalculate
263+
(hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && !getResolutionWithResolvedFileName(resolution))) {
247264
const existingResolution = resolution;
248265
const resolutionInDirectory = perDirectoryResolution.get(name);
249266
if (resolutionInDirectory) {
@@ -284,7 +301,7 @@ namespace ts {
284301
if (oldResolution === newResolution) {
285302
return true;
286303
}
287-
if (!oldResolution || !newResolution || oldResolution.isInvalidated) {
304+
if (!oldResolution || !newResolution) {
288305
return false;
289306
}
290307
const oldResult = getResolutionWithResolvedFileName(oldResolution);
@@ -577,6 +594,11 @@ namespace ts {
577594
);
578595
}
579596

597+
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: Map<ReadonlyArray<string>>) {
598+
Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
599+
filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
600+
}
601+
580602
function invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath: Path, isCreatingWatchedDirectory: boolean) {
581603
let isChangedFailedLookupLocation: (location: string) => boolean;
582604
if (isCreatingWatchedDirectory) {

src/compiler/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ namespace ts {
18921892
kind: SyntaxKind.DebuggerStatement;
18931893
}
18941894

1895-
export interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement {
1895+
export interface MissingDeclaration extends DeclarationStatement {
18961896
kind: SyntaxKind.MissingDeclaration;
18971897
name?: Identifier;
18981898
}
@@ -3193,7 +3193,8 @@ namespace ts {
31933193
export type AnyValidImportOrReExport =
31943194
| (ImportDeclaration | ExportDeclaration) & { moduleSpecifier: StringLiteral }
31953195
| ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral } }
3196-
| RequireOrImportCall;
3196+
| RequireOrImportCall
3197+
| ImportTypeNode & { argument: LiteralType };
31973198

31983199
/* @internal */
31993200
export type RequireOrImportCall = CallExpression & { arguments: [StringLiteralLike] };

0 commit comments

Comments
 (0)