mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-14 18:39:19 -05:00
Merge remote-tracking branch 'origin/master' into far_display_parts
This commit is contained in:
@@ -1023,8 +1023,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration {
|
||||
return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
|
||||
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration | undefined {
|
||||
return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
|
||||
}
|
||||
|
||||
function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol {
|
||||
@@ -1191,6 +1191,7 @@ namespace ts {
|
||||
if (!links.target) {
|
||||
links.target = resolvingSymbol;
|
||||
const node = getDeclarationOfAliasSymbol(symbol);
|
||||
Debug.assert(!!node);
|
||||
const target = getTargetOfAliasDeclaration(node);
|
||||
if (links.target === resolvingSymbol) {
|
||||
links.target = target || unknownSymbol;
|
||||
@@ -1226,6 +1227,7 @@ namespace ts {
|
||||
if (!links.referenced) {
|
||||
links.referenced = true;
|
||||
const node = getDeclarationOfAliasSymbol(symbol);
|
||||
Debug.assert(!!node);
|
||||
if (node.kind === SyntaxKind.ExportAssignment) {
|
||||
// export default <symbol>
|
||||
checkExpressionCached((<ExportAssignment>node).expression);
|
||||
@@ -18761,7 +18763,13 @@ namespace ts {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
// Merge in UMD exports with first-in-wins semantics (see #9771)
|
||||
const source = file.symbol.globalExports;
|
||||
for (const id in source) {
|
||||
if (!(id in globals)) {
|
||||
globals[id] = source[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -885,7 +885,7 @@ namespace ts {
|
||||
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
|
||||
|
||||
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
|
||||
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
|
||||
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -1132,8 +1132,10 @@ namespace ts {
|
||||
// it if it's not a well known symbol. In that case, the text of the name will be exactly
|
||||
// what we want, namely the name expression enclosed in brackets.
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If optional property emit ?
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) {
|
||||
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
|
||||
// we don't want to emit property declaration with "?"
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
|
||||
@@ -2339,6 +2339,7 @@ namespace ts {
|
||||
token() === SyntaxKind.LessThanToken ||
|
||||
token() === SyntaxKind.QuestionToken ||
|
||||
token() === SyntaxKind.ColonToken ||
|
||||
token() === SyntaxKind.CommaToken ||
|
||||
canParseSemicolon();
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1101,7 +1101,7 @@ namespace ts {
|
||||
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
|
||||
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
|
||||
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
|
||||
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
|
||||
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
|
||||
let currentNodeModulesDepth = 0;
|
||||
|
||||
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
|
||||
|
||||
@@ -403,6 +403,7 @@ namespace ts {
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@@ -429,6 +430,7 @@ namespace ts {
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
allowJs: false,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@@ -450,7 +452,8 @@ namespace ts {
|
||||
{
|
||||
compilerOptions:
|
||||
{
|
||||
allowJs: true
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
@@ -469,7 +472,8 @@ namespace ts {
|
||||
{
|
||||
compilerOptions:
|
||||
{
|
||||
allowJs: true
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2
|
||||
},
|
||||
errors: <Diagnostic[]>[]
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ namespace ts {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
// Some comments
|
||||
"outDir": "bin"
|
||||
}
|
||||
"files": ["file1.ts"]
|
||||
|
||||
@@ -280,11 +280,14 @@ namespace ts {
|
||||
let pos = this.pos;
|
||||
const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode;
|
||||
const processNode = (node: Node) => {
|
||||
if (pos < node.pos) {
|
||||
const isJSDocTagNode = isJSDocTag(node);
|
||||
if (!isJSDocTagNode && pos < node.pos) {
|
||||
pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner);
|
||||
}
|
||||
children.push(node);
|
||||
pos = node.end;
|
||||
if (!isJSDocTagNode) {
|
||||
pos = node.end;
|
||||
}
|
||||
};
|
||||
const processNodes = (nodes: NodeArray<Node>) => {
|
||||
if (pos < nodes.pos) {
|
||||
@@ -299,10 +302,6 @@ namespace ts {
|
||||
processNode(jsDocComment);
|
||||
}
|
||||
}
|
||||
// For syntactic classifications, all trivia are classcified together, including jsdoc comments.
|
||||
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
|
||||
// Restoring the scanner position ensures that.
|
||||
pos = this.pos;
|
||||
forEachChild(this, processNode, processNodes);
|
||||
if (pos < this.end) {
|
||||
this.addSyntheticNodes(children, pos, this.end);
|
||||
|
||||
@@ -930,7 +930,8 @@ namespace ts {
|
||||
const options: TranspileOptions = {
|
||||
fileName: "config.js",
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ES6
|
||||
target: ScriptTarget.ES6,
|
||||
removeComments: true
|
||||
},
|
||||
reportDiagnostics: true
|
||||
};
|
||||
|
||||
@@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty {
|
||||
constructor(x: string);
|
||||
}
|
||||
export declare class ConstructorWithOptionalParameterProperty {
|
||||
x?: string;
|
||||
x: string;
|
||||
constructor(x?: string);
|
||||
}
|
||||
export declare class ConstructorWithParameterInitializer {
|
||||
@@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
|
||||
constructor(x: string);
|
||||
}
|
||||
declare class GlobalConstructorWithOptionalParameterProperty {
|
||||
x?: string;
|
||||
x: string;
|
||||
constructor(x?: string);
|
||||
}
|
||||
declare class GlobalConstructorWithParameterInitializer {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/errorForConflictingExportEqualsValue.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorForConflictingExportEqualsValue.ts (1 errors) ====
|
||||
export var x;
|
||||
export = {};
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [errorForConflictingExportEqualsValue.ts]
|
||||
export var x;
|
||||
export = {};
|
||||
|
||||
|
||||
//// [errorForConflictingExportEqualsValue.js]
|
||||
"use strict";
|
||||
module.exports = {};
|
||||
@@ -0,0 +1,26 @@
|
||||
/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'.
|
||||
|
||||
|
||||
==== /index.ts (1 errors) ====
|
||||
/// <reference path="/typings/index.d.ts" />
|
||||
import * as foo from "shortid";
|
||||
foo.x // found in index.d.ts
|
||||
foo.y // ignored from shortid/index.js
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'.
|
||||
|
||||
|
||||
==== /node_modules/shortid/node_modules/z/index.js (0 errors) ====
|
||||
// z will not be found because maxNodeModulesJsDepth: 0
|
||||
module.exports = { z: 'no' };
|
||||
|
||||
==== /node_modules/shortid/index.js (0 errors) ====
|
||||
var z = require('z');
|
||||
var y = { y: 'foo' };
|
||||
module.exports = y;
|
||||
|
||||
==== /typings/index.d.ts (0 errors) ====
|
||||
declare module "shortid" {
|
||||
export var x: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
[
|
||||
"======== Resolving module 'shortid' from '/index.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module 'shortid' from 'node_modules' folder.",
|
||||
"File '/node_modules/shortid.ts' does not exist.",
|
||||
"File '/node_modules/shortid.tsx' does not exist.",
|
||||
"File '/node_modules/shortid.d.ts' does not exist.",
|
||||
"File '/node_modules/shortid.js' does not exist.",
|
||||
"File '/node_modules/shortid.jsx' does not exist.",
|
||||
"File '/node_modules/shortid/package.json' does not exist.",
|
||||
"File '/node_modules/shortid/index.ts' does not exist.",
|
||||
"File '/node_modules/shortid/index.tsx' does not exist.",
|
||||
"File '/node_modules/shortid/index.d.ts' does not exist.",
|
||||
"File '/node_modules/shortid/index.js' exist - use it as a name resolution result.",
|
||||
"File '/node_modules/@types/shortid.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid.tsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid.js' does not exist.",
|
||||
"File '/node_modules/@types/shortid.jsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid/package.json' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.tsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.js' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.jsx' does not exist.",
|
||||
"Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'",
|
||||
"======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========"
|
||||
]
|
||||
@@ -1,8 +1,5 @@
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||
Types of property 'id' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
@@ -11,7 +8,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (3 errors) ====
|
||||
var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
@@ -19,13 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'.
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
~~~~
|
||||
!!! error TS1131: Property or signature expected.
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||
|
||||
@@ -3,7 +3,7 @@ var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
function bar(obj: { name: string; id: boolean }) { }
|
||||
bar({ name, id }); // error
|
||||
@@ -14,8 +14,7 @@ bar({ name, id }); // error
|
||||
var id = 10000;
|
||||
var name = "my name";
|
||||
var person = { name: name, id: id }; // error
|
||||
var person1 = name, id;
|
||||
; // error: can't use short-hand property assignment in type position
|
||||
var person1; // ok
|
||||
function foo(name, id) { return { name: name, id: id }; } // error
|
||||
function bar(obj) { }
|
||||
bar({ name: name, id: id }); // error
|
||||
|
||||
@@ -3,15 +3,12 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'.
|
||||
Types of property 'name' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,16): error TS1131: Property or signature expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,25): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||
Types of property 'name' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (3 errors) ====
|
||||
var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
@@ -25,15 +22,10 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
!!! error TS2322: Types of property 'name' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
~~~~
|
||||
!!! error TS1131: Property or signature expected.
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||
!!! error TS2322: Types of property 'name' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
@@ -5,8 +5,9 @@ var name: string = "my name";
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
|
||||
|
||||
//// [objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js]
|
||||
var id = 10000;
|
||||
@@ -14,6 +15,5 @@ var name = "my name";
|
||||
var person = { name: name, id: id }; // error
|
||||
function bar(name, id) { return { name: name, id: id }; } // error
|
||||
function foo(name, id) { return { name: name, id: id }; } // error
|
||||
var person1 = name, id;
|
||||
; // error : Can't use shorthand in the type position
|
||||
var person1; // ok
|
||||
var person2 = bar("hello", 5);
|
||||
|
||||
@@ -126,7 +126,7 @@ interface Foo {
|
||||
}
|
||||
declare function test1(x: Foo): void;
|
||||
declare class Bar {
|
||||
d?: number;
|
||||
d: number;
|
||||
e: number;
|
||||
a: number;
|
||||
b?: number;
|
||||
|
||||
10
tests/baselines/reference/parseObjectLiteralsWithoutTypes.js
Normal file
10
tests/baselines/reference/parseObjectLiteralsWithoutTypes.js
Normal file
@@ -0,0 +1,10 @@
|
||||
//// [parseObjectLiteralsWithoutTypes.ts]
|
||||
let x: { foo, bar }
|
||||
let y: { foo: number, bar }
|
||||
let z: { foo, bar: number }
|
||||
|
||||
|
||||
//// [parseObjectLiteralsWithoutTypes.js]
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
|
||||
let x: { foo, bar }
|
||||
>x : Symbol(x, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 13))
|
||||
|
||||
let y: { foo: number, bar }
|
||||
>y : Symbol(y, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 21))
|
||||
|
||||
let z: { foo, bar: number }
|
||||
>z : Symbol(z, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 13))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
|
||||
let x: { foo, bar }
|
||||
>x : { foo: any; bar: any; }
|
||||
>foo : any
|
||||
>bar : any
|
||||
|
||||
let y: { foo: number, bar }
|
||||
>y : { foo: number; bar: any; }
|
||||
>foo : number
|
||||
>bar : any
|
||||
|
||||
let z: { foo, bar: number }
|
||||
>z : { foo: any; bar: number; }
|
||||
>foo : any
|
||||
>bar : number
|
||||
|
||||
23
tests/baselines/reference/umdGlobalConflict.js
Normal file
23
tests/baselines/reference/umdGlobalConflict.js
Normal file
@@ -0,0 +1,23 @@
|
||||
//// [tests/cases/compiler/umdGlobalConflict.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
export as namespace Alpha;
|
||||
export var x: string;
|
||||
|
||||
//// [index.d.ts]
|
||||
export as namespace Alpha;
|
||||
export var y: number;
|
||||
|
||||
//// [consumer.ts]
|
||||
import * as v1 from './v1';
|
||||
import * as v2 from './v2';
|
||||
|
||||
//// [global.ts]
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
|
||||
//// [consumer.js]
|
||||
"use strict";
|
||||
//// [global.js]
|
||||
// Should be OK, first in wins
|
||||
var p = Alpha.x;
|
||||
29
tests/baselines/reference/umdGlobalConflict.symbols
Normal file
29
tests/baselines/reference/umdGlobalConflict.symbols
Normal file
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/v1/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export var x: string;
|
||||
>x : Symbol(x, Decl(index.d.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/v2/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export var y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/consumer.ts ===
|
||||
import * as v1 from './v1';
|
||||
>v1 : Symbol(v1, Decl(consumer.ts, 0, 6))
|
||||
|
||||
import * as v2 from './v2';
|
||||
>v2 : Symbol(v2, Decl(consumer.ts, 1, 6))
|
||||
|
||||
=== tests/cases/compiler/global.ts ===
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
>p : Symbol(p, Decl(global.ts, 1, 5))
|
||||
>Alpha.x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10))
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
>x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10))
|
||||
|
||||
29
tests/baselines/reference/umdGlobalConflict.types
Normal file
29
tests/baselines/reference/umdGlobalConflict.types
Normal file
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/v1/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : typeof Alpha
|
||||
|
||||
export var x: string;
|
||||
>x : string
|
||||
|
||||
=== tests/cases/compiler/v2/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : typeof
|
||||
|
||||
export var y: number;
|
||||
>y : number
|
||||
|
||||
=== tests/cases/compiler/consumer.ts ===
|
||||
import * as v1 from './v1';
|
||||
>v1 : typeof v1
|
||||
|
||||
import * as v2 from './v2';
|
||||
>v2 : typeof v2
|
||||
|
||||
=== tests/cases/compiler/global.ts ===
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
>p : string
|
||||
>Alpha.x : string
|
||||
>Alpha : typeof Alpha
|
||||
>x : string
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export var x;
|
||||
export = {};
|
||||
36
tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts
Normal file
36
tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// @module: commonjs
|
||||
// @moduleResolution: node
|
||||
// @allowJs: true
|
||||
// @traceResolution: true
|
||||
// @noEmit: true
|
||||
|
||||
// @filename: /tsconfig.json
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "bin"
|
||||
},
|
||||
"exclude": [ "node_modules" ]
|
||||
}
|
||||
// @filename: /node_modules/shortid/node_modules/z/index.js
|
||||
// z will not be found because maxNodeModulesJsDepth: 0
|
||||
module.exports = { z: 'no' };
|
||||
|
||||
// @filename: /node_modules/shortid/index.js
|
||||
var z = require('z');
|
||||
var y = { y: 'foo' };
|
||||
module.exports = y;
|
||||
|
||||
// @filename: /typings/index.d.ts
|
||||
declare module "shortid" {
|
||||
export var x: number;
|
||||
}
|
||||
|
||||
// @filename: /index.ts
|
||||
/// <reference path="/typings/index.d.ts" />
|
||||
import * as foo from "shortid";
|
||||
foo.x // found in index.d.ts
|
||||
foo.y // ignored from shortid/index.js
|
||||
|
||||
3
tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts
Normal file
3
tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
let x: { foo, bar }
|
||||
let y: { foo: number, bar }
|
||||
let z: { foo, bar: number }
|
||||
15
tests/cases/compiler/umdGlobalConflict.ts
Normal file
15
tests/cases/compiler/umdGlobalConflict.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
//@filename: v1/index.d.ts
|
||||
export as namespace Alpha;
|
||||
export var x: string;
|
||||
|
||||
//@filename: v2/index.d.ts
|
||||
export as namespace Alpha;
|
||||
export var y: number;
|
||||
|
||||
//@filename: consumer.ts
|
||||
import * as v1 from './v1';
|
||||
import * as v2 from './v2';
|
||||
|
||||
//@filename: global.ts
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
@@ -2,7 +2,7 @@
|
||||
var name: string = "my name";
|
||||
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
function bar(obj: { name: string; id: boolean }) { }
|
||||
bar({ name, id }); // error
|
||||
|
||||
@@ -4,5 +4,5 @@ var name: string = "my name";
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node"
|
||||
"moduleResolution": "node",
|
||||
"maxNodeModuleJsDepth": 2
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user