Skip to content

Commit 1b12a85

Browse files
committed
Merge branch 'master' into inputFiles
2 parents ec817f5 + 0ddcab3 commit 1b12a85

21 files changed

+976
-270
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Ken Howard <[email protected]>
121121
Kevin Lang <[email protected]>
122122
kimamula <[email protected]> # Kenji Imamula
123123
Kitson Kelly <[email protected]>
124+
Krishnadas Babu <[email protected]>
124125
Klaus Meinhardt <[email protected]>
125126
Kyle Kelley <[email protected]>
126127
Lorant Pinter <[email protected]>

CONTRIBUTING.md

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ In general, things we find useful when reviewing suggestions are:
4747

4848
# Instructions for Contributing Code
4949

50+
## Tips
51+
52+
### Faster clones
53+
54+
The TypeScript repository is relatively large. To save some time, you might want to clone it without the repo's full history using `git clone --depth=1`.
55+
56+
### Using local builds
57+
58+
Run `gulp build` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.
59+
5060
## Contributing bug fixes
5161

5262
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.

Gulpfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ gulp.task(
274274
// Generate Markdown spec
275275
const specMd = "doc/spec.md";
276276
gulp.task(specMd, /*help*/ false, [word2mdJs], () =>
277-
exec("cscript", ["//nologo", word2mdJs, path.resolve(specMd), path.resolve("doc/TypeScript Language Specification.docx")]));
277+
exec("cscript", ["//nologo", word2mdJs, path.resolve("doc/TypeScript Language Specification.docx"), path.resolve(specMd)]));
278278

279279
gulp.task(
280280
"generate-spec",
@@ -595,7 +595,7 @@ gulp.task(
595595
project.waitForWorkToStart().then(() => {
596596
source.cancel();
597597
});
598-
598+
599599
if (cmdLineOptions.tests || cmdLineOptions.failed) {
600600
await runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, source.token);
601601
}

doc/spec.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ TypeScript is a trademark of Microsoft Corporation.
239239

240240
# <a name="1"/>1 Introduction
241241

242-
JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring.
242+
JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript's optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code refactoring.
243243

244244
TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of ECMAScript 2015 (ES2015) syntax. Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development.
245245

@@ -263,7 +263,7 @@ function f() {
263263
}
264264
```
265265

266-
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
266+
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screenshot.
267267

268268
&emsp;&emsp;![](images/image1.png)
269269

@@ -411,7 +411,7 @@ We mentioned above that the '$' function behaves differently depending on the ty
411411
412412
This signature denotes that a function may be passed as the parameter of the '$' function. When a function is passed to '$', the jQuery library will invoke that function when a DOM document is ready. Because TypeScript supports overloading, tools can use TypeScript to show all available function signatures with their documentation tips and to give the correct documentation once a function has been called with a particular signature.
413413
414-
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
414+
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screenshot.
415415
416416
&emsp;&emsp;![](images/image2.png)
417417
@@ -628,7 +628,7 @@ JavaScript implementations can use these explicit constants to generate efficien
628628

629629
An important goal of TypeScript is to provide accurate and straightforward types for existing JavaScript programming patterns. To that end, TypeScript includes generic types, discussed in the next section, and *overloading on string parameters*, the topic of this section.
630630

631-
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
631+
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screenshot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
632632

633633
&emsp;&emsp;![](images/image3.png)
634634

@@ -639,7 +639,7 @@ var span = document.createElement("span");
639639
span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property
640640
```
641641

642-
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
642+
In the following screenshot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
643643

644644
&emsp;&emsp;![](images/image4.png)
645645

scripts/build/tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ exports.cleanTestDirs = cleanTestDirs;
165165
function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, timeout, keepFailed) {
166166
const testConfigContents = JSON.stringify({
167167
test: tests ? [tests] : undefined,
168-
runner: runners ? runners.split(",") : undefined,
168+
runners: runners ? runners.split(",") : undefined,
169169
light,
170170
workerCount,
171171
stackTraceLimit,
@@ -192,4 +192,4 @@ function restoreSavedNodeEnv() {
192192

193193
function deleteTemporaryProjectOutput() {
194194
return del(path.join(exports.localBaseline, "projectOutput/"));
195-
}
195+
}

src/compiler/checker.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -4855,7 +4855,7 @@ namespace ts {
48554855

48564856
function getLiteralPropertyNameText(name: PropertyName) {
48574857
const type = getLiteralTypeFromPropertyName(name);
4858-
return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (<LiteralType>type).value : undefined;
4858+
return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (<StringLiteralType | NumberLiteralType>type).value : undefined;
48594859
}
48604860

48614861
/** Return the inferred type for a binding element */
@@ -6450,12 +6450,12 @@ namespace ts {
64506450
/**
64516451
* Gets the symbolic name for a late-bound member from its type.
64526452
*/
6453-
function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType): __String {
6453+
function getLateBoundNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String {
64546454
if (type.flags & TypeFlags.UniqueESSymbol) {
64556455
return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String;
64566456
}
64576457
if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
6458-
return escapeLeadingUnderscores("" + (<LiteralType>type).value);
6458+
return escapeLeadingUnderscores("" + (<StringLiteralType | NumberLiteralType>type).value);
64596459
}
64606460
return Debug.fail();
64616461
}
@@ -6534,9 +6534,9 @@ namespace ts {
65346534
// If we have an existing early-bound member, combine its declarations so that we can
65356535
// report an error at each declaration.
65366536
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
6537-
const name = declarationNameToString(decl.name);
6538-
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name));
6539-
error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name);
6537+
const name = !(type.flags & TypeFlags.UniqueESSymbol) && unescapeLeadingUnderscores(memberName) || declarationNameToString(decl.name);
6538+
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
6539+
error(decl.name || decl, Diagnostics.Duplicate_property_0, name);
65406540
lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late);
65416541
}
65426542
lateSymbol.nameType = type;
@@ -9814,7 +9814,7 @@ namespace ts {
98149814
if (accessNode) {
98159815
const indexNode = getIndexNodeForAccessExpression(accessNode);
98169816
if (indexType.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
9817-
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (<LiteralType>indexType).value, typeToString(objectType));
9817+
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (<StringLiteralType | NumberLiteralType>indexType).value, typeToString(objectType));
98189818
}
98199819
else if (indexType.flags & (TypeFlags.String | TypeFlags.Number)) {
98209820
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
@@ -11759,11 +11759,11 @@ namespace ts {
1175911759
if (s & TypeFlags.StringLike && t & TypeFlags.String) return true;
1176011760
if (s & TypeFlags.StringLiteral && s & TypeFlags.EnumLiteral &&
1176111761
t & TypeFlags.StringLiteral && !(t & TypeFlags.EnumLiteral) &&
11762-
(<LiteralType>source).value === (<LiteralType>target).value) return true;
11762+
(<StringLiteralType>source).value === (<StringLiteralType>target).value) return true;
1176311763
if (s & TypeFlags.NumberLike && t & TypeFlags.Number) return true;
1176411764
if (s & TypeFlags.NumberLiteral && s & TypeFlags.EnumLiteral &&
1176511765
t & TypeFlags.NumberLiteral && !(t & TypeFlags.EnumLiteral) &&
11766-
(<LiteralType>source).value === (<LiteralType>target).value) return true;
11766+
(<NumberLiteralType>source).value === (<NumberLiteralType>target).value) return true;
1176711767
if (s & TypeFlags.BigIntLike && t & TypeFlags.BigInt) return true;
1176811768
if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true;
1176911769
if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true;
@@ -13687,8 +13687,8 @@ namespace ts {
1368713687
// no flags for all other types (including non-falsy literal types).
1368813688
function getFalsyFlags(type: Type): TypeFlags {
1368913689
return type.flags & TypeFlags.Union ? getFalsyFlagsOfTypes((<UnionType>type).types) :
13690-
type.flags & TypeFlags.StringLiteral ? (<LiteralType>type).value === "" ? TypeFlags.StringLiteral : 0 :
13691-
type.flags & TypeFlags.NumberLiteral ? (<LiteralType>type).value === 0 ? TypeFlags.NumberLiteral : 0 :
13690+
type.flags & TypeFlags.StringLiteral ? (<StringLiteralType>type).value === "" ? TypeFlags.StringLiteral : 0 :
13691+
type.flags & TypeFlags.NumberLiteral ? (<NumberLiteralType>type).value === 0 ? TypeFlags.NumberLiteral : 0 :
1369213692
type.flags & TypeFlags.BigIntLiteral ? isZeroBigInt(<BigIntLiteralType>type) ? TypeFlags.BigIntLiteral : 0 :
1369313693
type.flags & TypeFlags.BooleanLiteral ? (type === falseType || type === regularFalseType) ? TypeFlags.BooleanLiteral : 0 :
1369413694
type.flags & TypeFlags.PossiblyFalsy;
@@ -13711,8 +13711,8 @@ namespace ts {
1371113711
type === regularFalseType ||
1371213712
type === falseType ||
1371313713
type.flags & (TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null) ||
13714-
type.flags & TypeFlags.StringLiteral && (<LiteralType>type).value === "" ||
13715-
type.flags & TypeFlags.NumberLiteral && (<LiteralType>type).value === 0 ||
13714+
type.flags & TypeFlags.StringLiteral && (<StringLiteralType>type).value === "" ||
13715+
type.flags & TypeFlags.NumberLiteral && (<NumberLiteralType>type).value === 0 ||
1371613716
type.flags & TypeFlags.BigIntLiteral && isZeroBigInt(<BigIntLiteralType>type) ? type :
1371713717
neverType;
1371813718
}
@@ -15100,7 +15100,7 @@ namespace ts {
1510015100
return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts;
1510115101
}
1510215102
if (flags & TypeFlags.StringLiteral) {
15103-
const isEmpty = (<LiteralType>type).value === "";
15103+
const isEmpty = (<StringLiteralType>type).value === "";
1510415104
return strictNullChecks ?
1510515105
isEmpty ? TypeFacts.EmptyStringStrictFacts : TypeFacts.NonEmptyStringStrictFacts :
1510615106
isEmpty ? TypeFacts.EmptyStringFacts : TypeFacts.NonEmptyStringFacts;
@@ -15109,7 +15109,7 @@ namespace ts {
1510915109
return strictNullChecks ? TypeFacts.NumberStrictFacts : TypeFacts.NumberFacts;
1511015110
}
1511115111
if (flags & TypeFlags.NumberLiteral) {
15112-
const isZero = (<LiteralType>type).value === 0;
15112+
const isZero = (<NumberLiteralType>type).value === 0;
1511315113
return strictNullChecks ?
1511415114
isZero ? TypeFacts.ZeroNumberStrictFacts : TypeFacts.NonZeroNumberStrictFacts :
1511515115
isZero ? TypeFacts.ZeroNumberFacts : TypeFacts.NonZeroNumberFacts;
@@ -22294,7 +22294,7 @@ namespace ts {
2229422294
if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbolLike))) {
2229522295
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
2229622296
}
22297-
if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) {
22297+
if (!allTypesAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) {
2229822298
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
2229922299
}
2230022300
return booleanType;

src/compiler/diagnosticMessages.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,7 @@
24332433
"category": "Error",
24342434
"code": 2717
24352435
},
2436-
"Duplicate declaration '{0}'.": {
2436+
"Duplicate property '{0}'.": {
24372437
"category": "Error",
24382438
"code": 2718
24392439
},
@@ -2493,6 +2493,10 @@
24932493
"category": "Error",
24942494
"code": 2732
24952495
},
2496+
"Property '{0}' was also declared here.": {
2497+
"category": "Error",
2498+
"code": 2733
2499+
},
24962500
"It is highly likely that you are missing a semicolon.": {
24972501
"category": "Error",
24982502
"code": 2734

src/compiler/emitter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4377,10 +4377,10 @@ namespace ts {
43774377
}
43784378

43794379
/**
4380-
* Skips trivia such as comments and white-space that can optionally overriden by the source map source
4380+
* Skips trivia such as comments and white-space that can be optionally overridden by the source-map source
43814381
*/
43824382
function skipSourceTrivia(source: SourceMapSource, pos: number): number {
4383-
return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(sourceMapSource.text, pos);
4383+
return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(source.text, pos);
43844384
}
43854385

43864386
/**

src/lib/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.t
44

55
## Generated files
66

7-
Any files ending in `.generated.d.ts` aren't mean to be edited by hand.
7+
Any files ending in `.generated.d.ts` aren't meant to be edited by hand.
88
If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator).

0 commit comments

Comments
 (0)