Skip to content

Commit e90db46

Browse files
committed
merge with origin/master
2 parents a69dcd1 + 1868caa commit e90db46

36 files changed

Lines changed: 402 additions & 210 deletions

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
# Instructions for Logging Issues
2+
3+
## 1. Read the FAQ
4+
5+
Please [read the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) before logging new issues, even if you think you have found a bug.
6+
7+
Issues that ask questions answered in the FAQ will be closed without elaboration.
8+
9+
## 2. Search for Duplicates
10+
11+
[Search the existing issues](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) before logging a new one.
12+
13+
## 3. Do you have a question?
14+
15+
The issue tracker is for **issues**, in other words, bugs and suggestions.
16+
If you have a *question*, please use [http://stackoverflow.com/questions/tagged/typescript](Stack Overflow), [https://gitter.im/Microsoft/TypeScript](Gitter), your favorite search engine, or other resources.
17+
Due to increased traffic, we can no longer answer questions in the issue tracker.
18+
19+
## 4. Did you find a bug?
20+
21+
When logging a bug, please be sure to include the following:
22+
* What version of TypeScript you're using (run `tsc --v`)
23+
* If at all possible, an *isolated* way to reproduce the behavior
24+
* The behavior you expect to see, and the actual behavior
25+
26+
You can try out the nightly build of TypeScript (`npm install typescript@next`) to see if the bug has already been fixed.
27+
28+
## 5. Do you have a suggestion?
29+
30+
We also accept suggestions in the issue tracker.
31+
Be sure to [check the FAQ](https://github.com/Microsoft/TypeScript/wiki/FAQ) and [search](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue) first.
32+
33+
In general, things we find useful when reviewing suggestins are:
34+
* A description of the problem you're trying to solve
35+
* An overview of the suggested solution
36+
* Examples of how the suggestion would work in various places
37+
* Code examples showing e.g. "this would be an error, this wouldn't"
38+
* Code examples showing the generated JavaScript (if applicable)
39+
* If relevant, precedent in other languages can be useful for establishing context and expected behavior
40+
41+
# Instructions for Contributing Code
42+
143
## Contributing bug fixes
244

345
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.

src/compiler/checker.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,9 @@ namespace ts {
762762

763763
if (!result) {
764764
if (nameNotFoundMessage) {
765-
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
765+
if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) {
766+
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
767+
}
766768
}
767769
return undefined;
768770
}
@@ -799,6 +801,40 @@ namespace ts {
799801
return result;
800802
}
801803

804+
function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean {
805+
if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(<Identifier>errorLocation)) || isInTypeQuery(errorLocation))) {
806+
return false;
807+
}
808+
809+
const container = getThisContainer(errorLocation, /* includeArrowFunctions */ true);
810+
let location = container;
811+
while (location) {
812+
if (isClassLike(location.parent)) {
813+
const symbol = getSymbolOfNode(location.parent);
814+
let classType: Type;
815+
if (location.flags & NodeFlags.Static) {
816+
classType = getTypeOfSymbol(symbol);
817+
if (getPropertyOfType(classType, name)) {
818+
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), symbolToString(symbol));
819+
return true;
820+
}
821+
}
822+
else {
823+
if (location === container) {
824+
classType = (<InterfaceType>getDeclaredTypeOfSymbol(symbol)).thisType;
825+
if (getPropertyOfType(classType, name)) {
826+
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
827+
return true;
828+
}
829+
}
830+
}
831+
}
832+
833+
location = location.parent;
834+
}
835+
return false;
836+
}
837+
802838
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
803839
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0);
804840
// Block-scoped variables cannot be used before their definition

src/compiler/core.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,9 @@ namespace ts {
616616
return path.substr(0, rootLength) + normalized.join(directorySeparator);
617617
}
618618

619-
export function getDirectoryPath(path: string) {
619+
export function getDirectoryPath(path: Path): Path;
620+
export function getDirectoryPath(path: string): string;
621+
export function getDirectoryPath(path: string): any {
620622
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
621623
}
622624

@@ -874,4 +876,11 @@ namespace ts {
874876
}
875877
return copiedList;
876878
}
879+
880+
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
881+
return useCaseSensitivefileNames
882+
? ((fileName) => fileName)
883+
: ((fileName) => fileName.toLowerCase());
884+
}
885+
877886
}

src/compiler/diagnosticMessages.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,34 +1767,42 @@
17671767
"category": "Error",
17681768
"code": 2661
17691769
},
1770-
"Invalid module name in augmentation, module '{0}' cannot be found.": {
1770+
"Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?": {
17711771
"category": "Error",
17721772
"code": 2662
17731773
},
1774-
"Module augmentation cannot introduce new names in the top level scope.": {
1774+
"Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?": {
17751775
"category": "Error",
17761776
"code": 2663
17771777
},
1778-
"Exports and export assignments are not permitted in module augmentations.": {
1778+
"Invalid module name in augmentation, module '{0}' cannot be found.": {
17791779
"category": "Error",
17801780
"code": 2664
17811781
},
1782-
"Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.": {
1782+
"Module augmentation cannot introduce new names in the top level scope.": {
17831783
"category": "Error",
17841784
"code": 2665
17851785
},
1786-
"'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.": {
1786+
"Exports and export assignments are not permitted in module augmentations.": {
17871787
"category": "Error",
17881788
"code": 2666
17891789
},
1790-
"Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.": {
1790+
"Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.": {
17911791
"category": "Error",
17921792
"code": 2667
17931793
},
1794-
"Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.": {
1794+
"'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.": {
17951795
"category": "Error",
17961796
"code": 2668
17971797
},
1798+
"Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.": {
1799+
"category": "Error",
1800+
"code": 2669
1801+
},
1802+
"Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.": {
1803+
"category": "Error",
1804+
"code": 2670
1805+
},
17981806
"Import declaration '{0}' is using private name '{1}'.": {
17991807
"category": "Error",
18001808
"code": 4000

0 commit comments

Comments
 (0)