Skip to content

Commit 3e07398

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into wip-master-statelessOverload
2 parents a0cdc9d + c55b9ff commit 3e07398

File tree

282 files changed

+3319
-1688
lines changed

Some content is hidden

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

282 files changed

+3319
-1688
lines changed

src/compiler/checker.ts

Lines changed: 111 additions & 70 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ namespace ts {
6767
name: "jsx",
6868
type: createMapFromTemplate({
6969
"preserve": JsxEmit.Preserve,
70+
"react-native": JsxEmit.ReactNative,
7071
"react": JsxEmit.React
7172
}),
7273
paramType: Diagnostics.KIND,
73-
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react,
74+
description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
7475
},
7576
{
7677
name: "reactNamespace",

src/compiler/core.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ namespace ts {
204204
GreaterThan = 1
205205
}
206206

207+
export function length(array: any[]) {
208+
return array ? array.length : 0;
209+
}
210+
207211
/**
208212
* Iterates through 'array' by index and performs the callback on each element of array until the callback
209213
* returns a truthy value, then returns that value.

src/compiler/declarationEmitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace ts {
3232

3333
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
3434
const declarationDiagnostics = createDiagnosticCollection();
35-
forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
35+
forEachEmittedFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
3636
return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined);
3737

3838
function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sources: SourceFile[], isBundledEmit: boolean) {
@@ -1788,7 +1788,7 @@ namespace ts {
17881788
}
17891789
else {
17901790
// Get the declaration file path
1791-
forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles);
1791+
forEachEmittedFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles);
17921792
}
17931793

17941794
if (declFileName) {

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@
27132713
"category": "Message",
27142714
"code": 6079
27152715
},
2716-
"Specify JSX code generation: 'preserve' or 'react'": {
2716+
"Specify JSX code generation: 'preserve', 'react-native', or 'react'": {
27172717
"category": "Message",
27182718
"code": 6080
27192719
},

src/compiler/emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace ts {
7373

7474
// Emit each output file
7575
performance.mark("beforePrint");
76-
forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles);
76+
forEachEmittedFile(host, emitFile, transformed, emitOnlyDtsFiles);
7777
performance.measure("printTime", "beforePrint");
7878

7979
// Clean up emit nodes on parse tree
@@ -88,7 +88,7 @@ namespace ts {
8888
sourceMaps: sourceMapDataList
8989
};
9090

91-
function emitFile(jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) {
91+
function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) {
9292
// Make sure not to write js file and source map file if any of them cannot be written
9393
if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) {
9494
if (!emitOnlyDtsFiles) {

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ namespace ts {
439439

440440
function getCommonSourceDirectory() {
441441
if (commonSourceDirectory === undefined) {
442-
const emittedFiles = filterSourceFilesInDirectory(files, isSourceFileFromExternalLibrary);
442+
const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary));
443443
if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
444444
// If a rootDir is specified and is valid use it as the commonSourceDirectory
445445
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory);
@@ -1707,7 +1707,7 @@ namespace ts {
17071707
if (!options.noEmit && !options.suppressOutputPathCheck) {
17081708
const emitHost = getEmitHost();
17091709
const emitFilesSeen = createFileMap<boolean>(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined);
1710-
forEachExpectedEmitFile(emitHost, (emitFileNames) => {
1710+
forEachEmittedFile(emitHost, (emitFileNames) => {
17111711
verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen);
17121712
verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen);
17131713
});

src/compiler/transformers/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ namespace ts {
585585
if (isGeneratedIdentifier(node)) {
586586
return node;
587587
}
588-
if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) {
588+
if (node.text !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
589589
return node;
590590
}
591591
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));

src/compiler/transformers/es5.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace ts {
1111
export function transformES5(context: TransformationContext) {
1212
const compilerOptions = context.getCompilerOptions();
1313

14-
// enable emit notification only if using --jsx preserve
14+
// enable emit notification only if using --jsx preserve or react-native
1515
let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void;
1616
let noSubstitution: boolean[];
17-
if (compilerOptions.jsx === JsxEmit.Preserve) {
17+
if (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) {
1818
previousOnEmitNode = context.onEmitNode;
1919
context.onEmitNode = onEmitNode;
2020
context.enableEmitNotification(SyntaxKind.JsxOpeningElement);
@@ -116,4 +116,4 @@ namespace ts {
116116
return undefined;
117117
}
118118
}
119-
}
119+
}

src/compiler/types.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
LastBinaryOperator = CaretEqualsToken,
423423
FirstNode = QualifiedName,
424424
FirstJSDocNode = JSDocTypeExpression,
425-
LastJSDocNode = JSDocLiteralType,
425+
LastJSDocNode = JSDocNeverKeyword,
426426
FirstJSDocTagNode = JSDocComment,
427427
LastJSDocTagNode = JSDocNeverKeyword
428428
}
@@ -2363,7 +2363,7 @@
23632363
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo;
23642364
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
23652365
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
2366-
getBaseTypes(type: InterfaceType): ObjectType[];
2366+
getBaseTypes(type: InterfaceType): BaseType[];
23672367
getReturnTypeOfSignature(signature: Signature): Type;
23682368
/**
23692369
* Gets the type of a parameter at a given position in a signature.
@@ -2718,6 +2718,7 @@
27182718
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
27192719
leftSpread?: Symbol; // Left source for synthetic spread property
27202720
rightSpread?: Symbol; // Right source for synthetic spread property
2721+
mappedTypeOrigin?: Symbol; // For a property on a mapped type, points back to the orignal 'T' from 'keyof T'.
27212722
hasNonUniformType?: boolean; // True if constituents have non-uniform types
27222723
isPartial?: boolean; // True if syntheric property of union type occurs in some but not all constituents
27232724
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
@@ -2918,9 +2919,12 @@
29182919
/* @internal */
29192920
resolvedBaseConstructorType?: Type; // Resolved base constructor type of class
29202921
/* @internal */
2921-
resolvedBaseTypes: ObjectType[]; // Resolved base types
2922+
resolvedBaseTypes: BaseType[]; // Resolved base types
29222923
}
29232924

2925+
// Object type or intersection of object types
2926+
export type BaseType = ObjectType | IntersectionType;
2927+
29242928
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
29252929
declaredProperties: Symbol[]; // Declared members
29262930
declaredCallSignatures: Signature[]; // Declared call signatures
@@ -2953,7 +2957,9 @@
29532957
export interface UnionOrIntersectionType extends Type {
29542958
types: Type[]; // Constituent types
29552959
/* @internal */
2956-
resolvedProperties: SymbolTable; // Cache of resolved properties
2960+
propertyCache: SymbolTable; // Cache of resolved properties
2961+
/* @internal */
2962+
resolvedProperties: Symbol[];
29572963
/* @internal */
29582964
resolvedIndexType: IndexType;
29592965
/* @internal */
@@ -2964,7 +2970,10 @@
29642970

29652971
export interface UnionType extends UnionOrIntersectionType { }
29662972

2967-
export interface IntersectionType extends UnionOrIntersectionType { }
2973+
export interface IntersectionType extends UnionOrIntersectionType {
2974+
/* @internal */
2975+
resolvedApparentType: Type;
2976+
}
29682977

29692978
export type StructuredType = ObjectType | UnionType | IntersectionType;
29702979

@@ -3298,7 +3307,8 @@
32983307
export const enum JsxEmit {
32993308
None = 0,
33003309
Preserve = 1,
3301-
React = 2
3310+
React = 2,
3311+
ReactNative = 3
33023312
}
33033313

33043314
export const enum NewLineKind {

0 commit comments

Comments
 (0)